NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bartlett.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
33#include "NumCpp/NdArray.hpp"
34
35namespace nc
36{
37 //============================================================================
38 // Method Description:
49 {
50 if (m < 1)
51 {
52 return {};
53 }
54
55 const auto mDouble = static_cast<double>(m);
56 const auto mMinus1Over2 = (mDouble - 1.) / 2.;
57 const auto mMinus1Over2Inv = 1. / mMinus1Over2;
58
60 int32 i = 0;
61 for (auto n : linspace(0., mDouble - 1., m, EndPoint::YES))
62 {
63 result[i++] = mMinus1Over2Inv * (mMinus1Over2 - std::abs(n - mMinus1Over2));
64 }
65
66 return result;
67 }
68} // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
Definition Cartesian.hpp:40
NdArray< double > bartlett(int32 m)
Definition bartlett.hpp:48
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, EndPoint endPoint=EndPoint::YES)
Definition linspace.hpp:61
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::int32_t int32
Definition Types.hpp:36