NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
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"
36#include "NumCpp/NdArray.hpp"
37
38namespace nc
39{
40 //============================================================================
41 // Method Description:
57 template<typename dtype>
58 auto vander(const NdArray<dtype>& x, uint32 n, Increasing increasing = Increasing::YES)
59 {
61
63 for (uint32 row = 0; row < x.size(); ++row)
64 {
65 for (uint32 col = 0; col < n; ++col)
66 {
67 result(row, col) = std::pow(x[row], col);
68 }
69 }
70
71 if (increasing == Increasing::NO)
72 {
73 return fliplr(result);
74 }
75
76 return result;
77 }
78
79 //============================================================================
80 // Method Description:
95 template<typename dtype>
96 auto vander(const NdArray<dtype>& x, Increasing increasing = Increasing::YES)
97 {
98 return vander(x, x.size(), increasing);
99 }
100} // 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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
Definition Cartesian.hpp:39
auto vander(const NdArray< dtype > &x, uint32 n, Increasing increasing=Increasing::YES)
Definition vander.hpp:58
NdArray< dtype > fliplr(const NdArray< dtype > &inArray)
Definition fliplr.hpp:45
std::uint32_t uint32
Definition Types.hpp:40
Increasing
Increasing boolean.
Definition Enums.hpp:83
@ YES
Definition Enums.hpp:84
@ NO
Definition Enums.hpp:85