NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
inner.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:
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: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:139
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
Definition: Cartesian.hpp:40
dtype inner(const NdArray< dtype > &a, const NdArray< dtype > &b)
Definition: inner.hpp:49