]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/lambert_w_basic_example.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / math / example / lambert_w_basic_example.cpp
1 // Copyright Paul A. Bristow 2018
2
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 // Example of most basic call of both lambert W functions.
8 // Only requires C++03
9 // (and optionally a call of max_digits10 to show precision).
10
11 #include <boost/math/special_functions/lambert_w.hpp> // For lambert_w0 and wm1 functions.
12
13 #include <iostream>
14 #include <iomanip>
15
16 int main()
17 {
18 double z = 2.0;
19 double w0 = boost::math::lambert_w0(z);
20 std::cout.setf(std::ios_base::showpoint); // Include any trailing zeros.
21 std::cout.precision(std::numeric_limits<double>::max_digits10); // Show all possibly significant digits.
22 // Avoid using max_digfigs10 so as many old compilers can run the most basic lambert_w0 test?
23 // Require to get max_digits10
24 // [ run lambert_w_basic_example.cpp : : : [ requires cxx11_numeric_limits ] ]
25 std::cout << " lambert_w0(" << z << ") = " << w0 << std::endl; // lambert_w0(2.00000) = 0.852606
26 z = -0.2;
27 double wm1 = boost::math::lambert_wm1(z);
28 std::cout << " lambert_wm1(" << z << ") = " << wm1 << std::endl; // lambert_wm1(-0.200000) = -2.54264
29 return 0;
30 } // int main()