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
kaiser.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
32#if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
33
35#include "NumCpp/NdArray.hpp"
37#include "NumCpp/Utils/sqr.hpp"
38
39namespace nc
40{
41 //============================================================================
42 // Method Description:
51 inline NdArray<double> kaiser(int32 m, double beta)
52 {
53 if (m < 1)
54 {
55 return {};
56 }
57
58 const auto mDouble = static_cast<double>(m);
59 const auto mMinus1 = mDouble - 1.;
60 const auto mMinus1Over2 = mMinus1 / 2.;
61 const auto mMinus1Squared = utils::sqr(mMinus1);
62 const auto i0Beta = special::bessel_in(0, beta);
63
65 int32 i = 0;
67 {
68 auto value = beta * std::sqrt(1. - (4. * utils::sqr(n)) / mMinus1Squared);
69 result[i++] = special::bessel_in(0, value) / i0Beta;
70 }
71
72 return result;
73 }
74} // namespace nc
75
76#endif // #if defined(__cpp_lib_math_special_functions) || !defined(NUMCPP_NO_USE_BOOST)
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
auto bessel_in(dtype1 inV, dtype2 inX)
Definition bessel_in.hpp:57
constexpr dtype sqr(dtype inValue) noexcept
Definition sqr.hpp:42
Definition Cartesian.hpp:40
NdArray< dtype > linspace(dtype inStart, dtype inStop, uint32 inNum=50, EndPoint endPoint=EndPoint::YES)
Definition linspace.hpp:61
NdArray< double > kaiser(int32 m, double beta)
Definition kaiser.hpp:51
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::int32_t int32
Definition Types.hpp:36