NumCpp
2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
multi_dot.hpp
Go to the documentation of this file.
1
#pragma once
29
30
#include "
NumCpp/Core/Internal/Error.hpp
"
31
#include "
NumCpp/Core/Internal/StaticAsserts.hpp
"
32
#include "
NumCpp/Functions/dot.hpp
"
33
#include "
NumCpp/NdArray.hpp
"
34
35
#include <initializer_list>
36
#include <string>
37
38
namespace
nc
39
{
40
namespace
linalg
41
{
42
//============================================================================
43
// Method Description:
55
template
<
typename
dtype>
56
NdArray<dtype>
multi_dot
(
const
std::initializer_list<
NdArray<dtype>
>& inList)
57
{
58
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
(dtype);
59
60
typename
std::initializer_list<NdArray<dtype> >::iterator iter = inList.begin();
61
62
if
(inList.size() == 0)
63
{
64
THROW_INVALID_ARGUMENT_ERROR
(
"input empty list of arrays."
);
65
}
66
else
if
(inList.size() == 1)
67
{
68
return
iter->copy();
69
}
70
71
NdArray<dtype>
returnArray = dot<dtype>(*iter, *(iter + 1));
72
iter += 2;
73
for
(; iter < inList.end(); ++iter)
74
{
75
returnArray =
dot
(returnArray, *iter);
76
}
77
78
return
returnArray;
79
}
80
}
// namespace linalg
81
}
// namespace nc
StaticAsserts.hpp
Error.hpp
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition:
StaticAsserts.hpp:50
nc::dot
NdArray< dtype > dot(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition:
dot.hpp:47
nc::NdArray< dtype >
nc::linalg::multi_dot
NdArray< dtype > multi_dot(const std::initializer_list< NdArray< dtype > > &inList)
Definition:
multi_dot.hpp:56
NdArray.hpp
dot.hpp
nc
Definition:
Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition:
Error.hpp:36
include
NumCpp
Linalg
multi_dot.hpp
Generated by
1.8.17