NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
outer.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <algorithm>
31
33#include "NumCpp/NdArray.hpp"
34
35namespace nc
36{
37 //============================================================================
38 // Method Description:
48 template<typename dtype>
49 NdArray<dtype> outer(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
50 {
52
53 const auto size1 = inArray1.size();
54 const auto size2 = inArray2.size();
55
56 auto returnArray = NdArray<dtype>(size1, size2);
57 for (uint32 row = 0; row < size1; ++row)
58 {
59 const auto array1Value = inArray1[row];
60
61 std::transform(inArray2.begin(),
62 inArray2.end(),
63 returnArray.begin(row),
64 [array1Value](dtype value) -> dtype { return array1Value * value; });
65 }
66
67 return returnArray;
68 }
69} // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
iterator end() noexcept
Definition NdArrayCore.hpp:1619
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
Definition Cartesian.hpp:39
NdArray< dtype > outer(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition outer.hpp:49
std::uint32_t uint32
Definition Types.hpp:40