/usr/include/boost/math/special_functions
NameSizeModeActions
detail/-0755rm
acosh.hpp36930644editdlrm
airy.hpp162700644editdlrm
asinh.hpp39350644editdlrm
atanh.hpp41040644editdlrm
bernoulli.hpp53890644editdlrm
bessel.hpp284050644editdlrm
bessel_iterators.hpp68930644editdlrm
bessel_prime.hpp132380644editdlrm
beta.hpp525940644editdlrm
binomial.hpp25080644editdlrm
cardinal_b_spline.hpp47960644editdlrm
cbrt.hpp52000644editdlrm
chebyshev.hpp47600644editdlrm
chebyshev_transform.hpp62090644editdlrm
cos_pi.hpp23280644editdlrm
daubechies_scaling.hpp150360644editdlrm
daubechies_wavelet.hpp96710644editdlrm
digamma.hpp223180644editdlrm
ellint_1.hpp67000644editdlrm
ellint_2.hpp63770644editdlrm
ellint_3.hpp120480644editdlrm
ellint_d.hpp59650644editdlrm
ellint_rc.hpp31350644editdlrm
ellint_rd.hpp62800644editdlrm
ellint_rf.hpp52550644editdlrm
ellint_rg.hpp41250644editdlrm
ellint_rj.hpp88620644editdlrm
erf.hpp566600644editdlrm
expint.hpp750660644editdlrm
expm1.hpp113350644editdlrm
factorials.hpp80540644editdlrm
fpclassify.hpp198710644editdlrm
gamma.hpp704880644editdlrm
gegenbauer.hpp20150644editdlrm
hankel.hpp69940644editdlrm
hermite.hpp17780644editdlrm
heuman_lambda.hpp28910644editdlrm
hypergeometric_0F1.hpp42830644editdlrm
hypergeometric_1F0.hpp23830644editdlrm
hypergeometric_1F1.hpp318540644editdlrm
hypergeometric_2F0.hpp61270644editdlrm
hypergeometric_pFq.hpp85180644editdlrm
hypot.hpp22460644editdlrm
jacobi.hpp18840644editdlrm
jacobi_elliptic.hpp101900644editdlrm
jacobi_zeta.hpp22730644editdlrm
laguerre.hpp36510644editdlrm
lambert_w.hpp959980644editdlrm
lanczos.hpp3129740644editdlrm
legendre.hpp112750644editdlrm
legendre_stieltjes.hpp69010644editdlrm
log1p.hpp162710644editdlrm
math_fwd.hpp736710644editdlrm
modf.hpp16280644editdlrm
next.hpp289610644editdlrm
nonfinite_num_facets.hpp185720644editdlrm
owens_t.hpp498870644editdlrm
polygamma.hpp32090644editdlrm
pow.hpp34260644editdlrm
powm1.hpp24420644editdlrm
prime.hpp915940644editdlrm
relative_difference.hpp54550644editdlrm
round.hpp43610644editdlrm
sign.hpp56480644editdlrm
sinc.hpp34090644editdlrm
sinhc.hpp46430644editdlrm
sin_pi.hpp23110644editdlrm
spherical_harmonic.hpp63580644editdlrm
sqrt1pm1.hpp11490644editdlrm
trigamma.hpp214110644editdlrm
trunc.hpp54500644editdlrm
ulp.hpp33240644editdlrm
zeta.hpp537760644editdlrm
Edit: /usr/include/boost/math/special_functions/chebyshev_transform.hpp (6209B)
// (C) Copyright Nick Thompson 2017. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_MATH_SPECIAL_CHEBYSHEV_TRANSFORM_HPP #define BOOST_MATH_SPECIAL_CHEBYSHEV_TRANSFORM_HPP #include #include #include #include #include #ifdef BOOST_HAS_FLOAT128 #include #endif namespace boost { namespace math { namespace detail{ template struct fftw_cos_transform; template<> struct fftw_cos_transform { fftw_cos_transform(int n, double* data1, double* data2) { plan = fftw_plan_r2r_1d(n, data1, data2, FFTW_REDFT10, FFTW_ESTIMATE); } ~fftw_cos_transform() { fftw_destroy_plan(plan); } void execute(double* data1, double* data2) { fftw_execute_r2r(plan, data1, data2); } static double cos(double x) { return std::cos(x); } static double fabs(double x) { return std::fabs(x); } private: fftw_plan plan; }; template<> struct fftw_cos_transform { fftw_cos_transform(int n, float* data1, float* data2) { plan = fftwf_plan_r2r_1d(n, data1, data2, FFTW_REDFT10, FFTW_ESTIMATE); } ~fftw_cos_transform() { fftwf_destroy_plan(plan); } void execute(float* data1, float* data2) { fftwf_execute_r2r(plan, data1, data2); } static float cos(float x) { return std::cos(x); } static float fabs(float x) { return std::fabs(x); } private: fftwf_plan plan; }; template<> struct fftw_cos_transform { fftw_cos_transform(int n, long double* data1, long double* data2) { plan = fftwl_plan_r2r_1d(n, data1, data2, FFTW_REDFT10, FFTW_ESTIMATE); } ~fftw_cos_transform() { fftwl_destroy_plan(plan); } void execute(long double* data1, long double* data2) { fftwl_execute_r2r(plan, data1, data2); } static long double cos(long double x) { return std::cos(x); } static long double fabs(long double x) { return std::fabs(x); } private: fftwl_plan plan; }; #ifdef BOOST_HAS_FLOAT128 template<> struct fftw_cos_transform<__float128> { fftw_cos_transform(int n, __float128* data1, __float128* data2) { plan = fftwq_plan_r2r_1d(n, data1, data2, FFTW_REDFT10, FFTW_ESTIMATE); } ~fftw_cos_transform() { fftwq_destroy_plan(plan); } void execute(__float128* data1, __float128* data2) { fftwq_execute_r2r(plan, data1, data2); } static __float128 cos(__float128 x) { return cosq(x); } static __float128 fabs(__float128 x) { return fabsq(x); } private: fftwq_plan plan; }; #endif } template class chebyshev_transform { public: template chebyshev_transform(const F& f, Real a, Real b, Real tol = 500 * std::numeric_limits::epsilon(), size_t max_refinements = 15) : m_a(a), m_b(b) { if (a >= b) { throw std::domain_error("a < b is required.\n"); } using boost::math::constants::half; using boost::math::constants::pi; using std::cos; using std::abs; Real bma = (b-a)*half(); Real bpa = (b+a)*half(); size_t n = 256; std::vector vf; size_t refinements = 0; while(refinements < max_refinements) { vf.resize(n); m_coeffs.resize(n); detail::fftw_cos_transform plan(static_cast(n), vf.data(), m_coeffs.data()); Real inv_n = 1/static_cast(n); for(size_t j = 0; j < n/2; ++j) { // Use symmetry cos((j+1/2)pi/n) = - cos((n-1-j+1/2)pi/n) Real y = detail::fftw_cos_transform::cos(pi()*(j+half())*inv_n); vf[j] = f(y*bma + bpa)*inv_n; vf[n-1-j]= f(bpa-y*bma)*inv_n; } plan.execute(vf.data(), m_coeffs.data()); Real max_coeff = 0; for (auto const & coeff : m_coeffs) { if (detail::fftw_cos_transform::fabs(coeff) > max_coeff) { max_coeff = detail::fftw_cos_transform::fabs(coeff); } } size_t j = m_coeffs.size() - 1; while (abs(m_coeffs[j])/max_coeff < tol) { --j; } // If ten coefficients are eliminated, the we say we've done all // we need to do: if (n - j > 10) { m_coeffs.resize(j+1); return; } n *= 2; ++refinements; } } Real operator()(Real x) const { using boost::math::constants::half; if (x > m_b || x < m_a) { throw std::domain_error("x not in [a, b]\n"); } Real z = (2*x - m_a - m_b)/(m_b - m_a); return chebyshev_clenshaw_recurrence(m_coeffs.data(), m_coeffs.size(), z); } // Integral over entire domain [a, b] Real integrate() const { Real Q = m_coeffs[0]/2; for(size_t j = 2; j < m_coeffs.size(); j += 2) { Q += -m_coeffs[j]/((j+1)*(j-1)); } return (m_b - m_a)*Q; } const std::vector& coefficients() const { return m_coeffs; } Real prime(Real x) const { Real z = (2*x - m_a - m_b)/(m_b - m_a); Real dzdx = 2/(m_b - m_a); if (m_coeffs.size() < 2) { return 0; } Real b2 = 0; Real d2 = 0; Real b1 = m_coeffs[m_coeffs.size() -1]; Real d1 = 0; for(size_t j = m_coeffs.size() - 2; j >= 1; --j) { Real tmp1 = 2*z*b1 - b2 + m_coeffs[j]; Real tmp2 = 2*z*d1 - d2 + 2*b1; b2 = b1; b1 = tmp1; d2 = d1; d1 = tmp2; } return dzdx*(z*d1 - d2 + b1); } private: std::vector m_coeffs; Real m_a; Real m_b; }; }} #endif