NumCpp  2.16.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
outer.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <algorithm>
31
34#include "NumCpp/NdArray.hpp"
35
36namespace nc
37{
38 //============================================================================
39 // Method Description:
49 template<typename dtype>
50 NdArray<dtype> outer(const NdArray<dtype>& inArray1, const NdArray<dtype>& inArray2)
51 {
53
54 const auto size1 = inArray1.size();
55 const auto size2 = inArray2.size();
56
57 auto returnArray = NdArray<dtype>(size1, size2);
58 for (uint32 row = 0; row < size1; ++row)
59 {
60 const auto array1Value = inArray1[row];
61
62 std::transform(inArray2.begin(),
63 inArray2.end(),
64 returnArray.begin(row),
65 [array1Value](dtype value) -> dtype { return array1Value * value; });
66 }
67
68 return returnArray;
69 }
70} // 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:139
size_type size() const noexcept
Definition: NdArrayCore.hpp:4604
iterator end() noexcept
Definition: NdArrayCore.hpp:1623
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:776
Definition: Cartesian.hpp:40
NdArray< dtype > outer(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: outer.hpp:50
std::uint32_t uint32
Definition: Types.hpp:40