NumCpp  2.9.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 <algorithm>
31 
34 #include "NumCpp/NdArray.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
48  template<typename dtype>
49  dtype inner(const NdArray<dtype>& a, const NdArray<dtype>& b)
50  {
52 
53  if (a.size() != b.size())
54  {
55  THROW_INVALID_ARGUMENT_ERROR("Inputs 'a' and 'b' must have the same size");
56  }
57 
58  return std::inner_product(a.cbegin(), a.cend(), b.cbegin(), dtype{ 0 });
59  }
60 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:49
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:4105
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
Definition: Coordinate.hpp:45
dtype inner(const NdArray< dtype > &a, const NdArray< dtype > &b)
Definition: inner.hpp:49