NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
inner.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/NdArray.hpp"
33 
34 #include <algorithm>
35 namespace 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 std::inner_product(a.cbegin(), a.cend(), b.cbegin(), dtype{ 0 });
58  }
59 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
size_type size() const noexcept
Definition: NdArrayCore.hpp:4296
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1216
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
Definition: Coordinate.hpp:45
dtype inner(const NdArray< dtype > &a, const NdArray< dtype > &b)
Definition: inner.hpp:48