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