NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
vander.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31#include <utility>
32
33#include "NumCpp/Core/Enums.hpp"
37#include "NumCpp/NdArray.hpp"
39
40namespace nc
41{
42 //============================================================================
43 // Method Description:
59 template<typename dtype>
60 auto vander(const NdArray<dtype>& x, uint32 n, Increasing increasing = Increasing::YES)
61 {
63
65 for (uint32 row = 0; row < x.size(); ++row)
66 {
67 for (uint32 col = 0; col < n; ++col)
68 {
69 result(row, col) = std::pow(x[row], col);
70 }
71 }
72
73 if (increasing == Increasing::NO)
74 {
75 return fliplr(result);
76 }
77
78 return result;
79 }
80
81 //============================================================================
82 // Method Description:
97 template<typename dtype>
98 auto vander(const NdArray<dtype>& x, Increasing increasing = Increasing::YES)
99 {
100 return vander(x, x.size(), increasing);
101 }
102} // namespace nc
#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
Definition: Cartesian.hpp:40
auto vander(const NdArray< dtype > &x, uint32 n, Increasing increasing=Increasing::YES)
Definition: vander.hpp:60
NdArray< dtype > fliplr(const NdArray< dtype > &inArray)
Definition: fliplr.hpp:46
std::uint32_t uint32
Definition: Types.hpp:40
Increasing
Increasing boolean.
Definition: Enums.hpp:83