v0.15.5
Loading...
Searching...
No Matches
lambert_w.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//Sources:
8//
9//Lambert W function - Wikipedia, the free encyclopedia
10//
11//Lagrange inversion theorem - Wikipedia, the free encyclopedia
12//
13//Numerical Evaluation of the Lambert W Function
14//and Application to Generation of Generalized
15//Gaussian Noise With Exponent 1/2
16// - François Chapeau-Blondeau, Member, IEEE, and Abdelilah Monir
17//(p2160 IEEE TRANSACTIONS ON SIGNAL PROCESSING, VOL. 50, NO. 9, SEPTEMBER 2002)
18//
19//Having Fun with Lambert W(x) Function
20// - Darko Veberic a,b,c
21// a University of Nova Gorica, Slovenia
22// b IK, Forschungszentrum Karlsruhe, Germany
23// c J. Stefan Institute, Ljubljana, Slovenia
24//(arXiv:1003.1628v1 [cs.MS] 8 Mar 2010)
25
26#ifndef BOOST_MATH_LAMBERT_W_HPP_INCLUDED
27#define BOOST_MATH_LAMBERT_W_HPP_INCLUDED
28
29#include <complex>
30#include <boost/math/tools/promotion.hpp>
32
33namespace boost
34{
35namespace math
36{
37 //Returns W(z) with the default policy for real argument z.
38 template<class ArgumentType>
39 inline typename tools::promote_args<ArgumentType,int>::type
40 lambert_w(const ArgumentType& z)
41 {
42 return lambw::_with_real_range_checks<ArgumentType,int>(z,0,
43 policies::policy<>());
44 }
45
46 //Returns W_k(z) with the default policy for real argument z.
47 template<class ArgumentType, class IndexType>
48 inline typename tools::promote_args<ArgumentType,IndexType>::type
49 lambert_w(const ArgumentType& z, const IndexType& k)
50 {
51 return lambw::_with_real_range_checks<ArgumentType,IndexType>(z,k,
52 policies::policy<>());
53 }
54
55 //Returns W_k(z) with the policy pol for real argument z.
56 template<class ArgumentType, class IndexType, class Policy>
57 inline typename tools::promote_args<ArgumentType,IndexType>::type
58 lambert_w(const ArgumentType& z, const IndexType& k, const Policy& pol)
59 {
60 BOOST_FPU_EXCEPTION_GUARD
61
62 typedef typename tools::promote_args<ArgumentType,IndexType>::type
63 result_type;
64
65 typedef typename policies::evaluation<result_type, Policy>::type
66 value_type;
67
68 typedef typename policies::normalise<
69 Policy,
70 policies::promote_float<false>,
71 policies::promote_double<false>,
72 policies::discrete_quantile<>,
73 policies::assert_undefined<> >::type forwarding_policy;
74
75 return
76 policies::checked_narrowing_cast<result_type, forwarding_policy>(
77 lambw::_with_real_range_checks<result_type,result_type,Policy>(
78 static_cast<value_type>(z),
79 static_cast<value_type>(k),
80 forwarding_policy()),
81 "boost::math::lambert_w<%1%,%1%>(%1%,%1%)");
82 }
83
84 //Returns W(z) with the default policy for complex argument z.
85 template<class ArgumentType>
86 inline std::complex<ArgumentType>
87 lambert_w(const std::complex<ArgumentType> &z)
88 {
89 return lambw::_with_complex_range_checks<ArgumentType,int>(z,0,
90 policies::policy<>());
91 }
92
93 //Return W_k(z) with the default policy for complex argument z.
94 template<class ArgumentType, class IndexType>
95 inline std::complex<ArgumentType>
96 lambert_w(const std::complex<ArgumentType> &z, const IndexType& k)
97 {
98 return lambw::_with_complex_range_checks<ArgumentType,IndexType>(z,k,
99 policies::policy<>());
100 }
101
102 //Return W_k(z) with the policy pol for complex argument z.
103 template<class ArgumentType, class IndexType, class Policy>
104 inline std::complex<ArgumentType>
105 lambert_w(const std::complex<ArgumentType>& z, const IndexType& k,
106 const Policy& pol)
107 {
108 BOOST_FPU_EXCEPTION_GUARD
109
110 typedef typename tools::promote_args<ArgumentType, IndexType>::type
111 result_type;
112
113 typedef typename policies::evaluation<result_type, Policy>::type
114 value_type;
115
116 typedef typename policies::normalise<
117 Policy,
118 policies::promote_float<false>,
119 policies::promote_double<false>,
120 policies::discrete_quantile<>,
121 policies::assert_undefined<> >::type forwarding_policy;
122
123 return
124 policies::checked_narrowing_cast<result_type, forwarding_policy>(
125 lambw::_with_complex_range_checks<std::complex<result_type>,
126 result_type,Policy>(
127 static_cast<std::complex<value_type> >(z),
128 static_cast<value_type>(k),
129 forwarding_policy()),
130 "boost::math::lambert_w<std::complex<%1%>,%1%>(std::complex<%1%>,%1%)"
131 );
132 }
133} // namespace math
134} // namespace boost
135
136#endif // BOOST_MATH_LAMBERT_W_HPP_INCLUDED
FTensor::Index< 'k', 3 > k
std::complex< ArgumentType > _with_complex_range_checks(const std::complex< ArgumentType > &z, const IndexType &k, const Policy &pol)
tools::promote_args< ArgumentType, int >::type lambert_w(const ArgumentType &z)
Definition lambert_w.hpp:40