NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
inner.hpp
Go to the documentation of this file.
1
28#pragma once
29
33#include "NumCpp/NdArray.hpp"
34
35namespace nc
36{
37 //============================================================================
38 // Method Description:
47 template<typename dtype>
48 dtype inner(const NdArray<dtype>& a, const NdArray<dtype>& b)
49 {
51
52 if (a.size() != b.size())
53 {
54 THROW_INVALID_ARGUMENT_ERROR("Inputs 'a' and 'b' must have the same size");
55 }
56
57 return stl_algorithms::transform_reduce(a.cbegin(), a.cend(), b.cbegin(), dtype{ 0 });
58 }
59} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#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
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
T transform_reduce(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, T init)
Definition StlAlgorithms.hpp:825
Definition Cartesian.hpp:39
dtype inner(const NdArray< dtype > &a, const NdArray< dtype > &b)
Definition inner.hpp:48