NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
vander.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <cmath>
31 #include <utility>
32 
36 #include "NumCpp/NdArray.hpp"
37 #include "NumCpp/Utils/powerf.hpp"
38 
39 namespace nc
40 {
41  //============================================================================
42  // Method Description:
58  template<typename dtype>
59  auto vander(const NdArray<dtype>& x, uint32 n, bool increasing = true)
60  {
62 
64  for (uint32 row = 0; row < x.size(); ++row)
65  {
66  for (uint32 col = 0; col < n; ++col)
67  {
68  result(row, col) = std::pow(x[row], col);
69  }
70  }
71 
72  if (!increasing)
73  {
74  return fliplr(result);
75  }
76 
77  return result;
78  }
79 
80  //============================================================================
81  // Method Description:
96  template<typename dtype>
97  auto vander(const NdArray<dtype>& x, bool increasing = true)
98  {
99  return vander(x, x.size(), increasing);
100  }
101 } // namespace nc
#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
Definition: Coordinate.hpp:45
auto vander(const NdArray< dtype > &x, uint32 n, bool increasing=true)
Definition: vander.hpp:59
NdArray< dtype > fliplr(const NdArray< dtype > &inArray)
Definition: fliplr.hpp:46
std::uint32_t uint32
Definition: Types.hpp:40