]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/agm_example.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / example / agm_example.cpp
1 // (C) Copyright Nick Thompson 2020.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include <cmath>
6 #include <iostream>
7 #include <iomanip>
8 #include <boost/math/tools/agm.hpp>
9 #include <boost/math/constants/constants.hpp>
10
11 #ifndef BOOST_MATH_STANDALONE
12 #include <boost/multiprecision/cpp_bin_float.hpp>
13 #endif
14
15 // This example computes the lemniscate constant to high precision using the agm:
16 using boost::math::tools::agm;
17 using boost::math::constants::pi;
18
19 int main() {
20 using std::sqrt;
21
22 #ifndef BOOST_MATH_STANDALONE
23 using Real = boost::multiprecision::cpp_bin_float_100;
24 #else
25 using Real = long double;
26 #endif
27
28 Real G = agm(sqrt(Real(2)), Real(1));
29 std::cout << std::setprecision(std::numeric_limits<Real>::max_digits10);
30 std::cout << " Gauss's lemniscate constant = " << pi<Real>()/G << "\n";
31 std::cout << "Expected lemniscate constant = " << "2.62205755429211981046483958989111941368275495143162316281682170380079058707041425023029553296142909344613\n";
32 }