v0.15.5
Loading...
Searching...
No Matches
lambert_w_tay.hpp
Go to the documentation of this file.
1
2// Copyright Balazs Cziraki 2016.
3// Use, modification and distribution are subject to the
4// Boost Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7#ifndef BOOST_MATH_LAMBERT_W_TAY_HPP_INCLUDED
8#define BOOST_MATH_LAMBERT_W_TAY_HPP_INCLUDED
9
10#include <boost/array.hpp>
11#include "lambert_w_tools.hpp"
12
13namespace boost
14{
15namespace math
16{
17namespace lambw
18{
19 //Constant that controls series evaluation length
20 const std::size_t _tay_series_L = 10;
21
22 //Computes the coefficients to use with _series_sum to calculate the Taylor series for W(z) (a.k.a. W_0(z)) at abs(z)<exp(-1)
23 //From here on W(z) is used to refer to W_0(z), since it is the most commonly used branch of the function.
24 template<class CoeffType>
25 /*BOOST_CONSTEXPR*/ CoeffType _tay_coeffs(std::size_t k)
26 {
27 using std::pow;
28
29 CoeffType n = (CoeffType)(k+1);
30 return (-pow(((n+1)/n),n-1));
31 }
32
33 //Array to store the Taylor series coefficients.
34 template<class CoeffType>
35 inline const boost::array<CoeffType,_tay_series_L>& _lw_tc()
36 {
37 static const boost::array<CoeffType,_tay_series_L> ans = _coeff_array<CoeffType,_tay_series_L>(_tay_coeffs<CoeffType>);
38 return ans;
39 }
40
41 //Returns an approximation for W(z) for abs(z)<exp(-1)
42 template<class ArgumentType,class CoeffType>
43 ArgumentType _tay(const ArgumentType &z)
44 {
45 return z*_series_sum(z,_lw_tc<CoeffType>());
46 }
47} //namespace lambw
48} //namespace math
49} //namespace boost
50
51#endif // BOOST_MATH_LAMBERT_W_TAY_HPP_INCLUDED
const double n
refractive index of diffusive medium
FTensor::Index< 'k', 3 > k
ArgumentType _tay(const ArgumentType &z)
CoeffType _tay_coeffs(std::size_t k)
const std::size_t _tay_series_L
const boost::array< CoeffType, _tay_series_L > & _lw_tc()
ArgumentType _series_sum(const ArgumentType &z, const boost::array< CoeffType, L > &c)