2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Remove -Wcomment in Lambert-W examples. [CI SKIP]

This commit is contained in:
Nick Thompson
2019-01-22 11:01:25 -07:00
parent 0a3ea43fcc
commit 4ea55eb029

View File

@@ -36,7 +36,7 @@ typedef number<cpp_dec_float<1000> > cpp_dec_float_1000; // 1000 decimal digit t
using boost::multiprecision::cpp_bin_float_double; // == double
using boost::multiprecision::cpp_bin_float_double_extended; // 80-bit long double emulation.
using boost::multiprecision::cpp_bin_float_quad; // 128-bit quad precision.
//[lambert_w_simple_examples_includes
#include <boost/math/special_functions/lambert_w.hpp> // For lambert_w function.
@@ -62,7 +62,7 @@ void show_value(T z)
std::cout.setf(std::ios_base::showpoint); // Include any trailing zeros.
std::cout << z;
// Restore:
std::cout.precision(precision);
std::cout.precision(precision);
std::cout.flags(flags);
} // template<typename T> void show_value(T z)
@@ -73,7 +73,7 @@ int main()
std::cout << "Lambert W simple examples." << std::endl;
using boost::math::constants::exp_minus_one; //-1/e, the branch point, a singularity ~= -0.367879.
// using statements needed for changing error handling policy.
using boost::math::policies::policy;
using boost::math::policies::make_policy;
@@ -83,13 +83,13 @@ int main()
using boost::math::policies::ignore_error;
using boost::math::policies::throw_on_error;
{
{
//[lambert_w_simple_examples_0
std::cout.precision(std::numeric_limits<double>::max_digits10);
// Show all potentially significant decimal digits,
std::cout << std::showpoint << std::endl;
std::cout << std::showpoint << std::endl;
// and show significant trailing zeros too.
double z = 10.;
double r = lambert_w0(z); // Default policy for double.
std::cout << "lambert_w0(z) = " << r << std::endl;
@@ -100,26 +100,26 @@ int main()
// Other floating-point types can be used too, here float.
// It is convenient to use a function like `show_value`
// to display all potentially significant decimal digits
// for the type, including any significant trailing zeros.
// for the type, including any significant trailing zeros.
//[lambert_w_simple_examples_1
float z = 10.F;
float r;
r = lambert_w0(z); // Default policy digits10 = 7, digits2 = 24
std::cout << "lambert_w0(";
show_value(z);
std::cout << ") = ";
std::cout << ") = ";
show_value(r);
std::cout << std::endl; // lambert_w0(10.0000000) = 1.74552798
//] //[/lambert_w_simple_examples_1]
}
{
{
// Example of an integer argument to lambert_w,
// showing that an integer is correctly promoted to a double.
//[lambert_w_simple_examples_2
std::cout.precision(std::numeric_limits<double>::max_digits10);
double r = lambert_w0(10); // Pass an int argument "10" that should be promoted to double argument.
std::cout << "lambert_w0(10) = " << r << std::endl; // lambert_w0(10) = 1.7455280027406994
double rp = lambert_w0(10);
double rp = lambert_w0(10);
std::cout << "lambert_w0(10) = " << rp << std::endl;
// lambert_w0(10) = 1.7455280027406994
auto rr = lambert_w0(10); // C++11 needed.
@@ -130,15 +130,15 @@ int main()
{
// Using multiprecision types to get much higher precision is painless.
//[lambert_w_simple_examples_3
cpp_dec_float_50 z("10");
// Note construction using a decimal digit string "10",
cpp_dec_float_50 z("10");
// Note construction using a decimal digit string "10",
// NOT a floating-point double literal 10.
cpp_dec_float_50 r;
r = lambert_w0(z);
std::cout << "lambert_w0("; show_value(z); std::cout << ") = ";
r = lambert_w0(z);
std::cout << "lambert_w0("; show_value(z); std::cout << ") = ";
show_value(r);
std::cout << std::endl;
// lambert_w0(10.000000000000000000000000000000000000000000000000000000000000000000000000000000) =
// lambert_w0(10.000000000000000000000000000000000000000000000000000000000000000000000000000000) =
// 1.7455280027406993830743012648753899115352881290809413313533156980404446940000000
//] //[/lambert_w_simple_examples_3]
}
@@ -148,7 +148,7 @@ int main()
cpp_dec_float_50 z(0.7777777777777777777777777777777777777777777777777777777777777777777777777);
// Compiler evaluates the nearest double-precision binary representation,
// from the max_digits10 of the floating_point literal double 0.7777777777777777777777777777...,
// so any extra digits in the multiprecision type
// so any extra digits in the multiprecision type
// beyond max_digits10 (usually 17) are random and meaningless.
cpp_dec_float_50 r;
r = lambert_w0(z);
@@ -172,7 +172,7 @@ int main()
// lambert_w0(0.90000000000000002220446049250313080847263336181640625000000000000000000000000000)
// = 0.52983296563343440510607251781038939952850341796875000000000000000000000000000000
std::cout << "lambert_w0(0.9) = " << lambert_w0(static_cast<double>(0.9))
// lambert_w0(0.9)
// lambert_w0(0.9)
// = 0.52983296563343441
<< std::endl;
//] //[/lambert_w_simple_examples_4a]
@@ -197,7 +197,7 @@ int main()
cpp_dec_float_1000 z("2.0");
cpp_dec_float_1000 r;
r = lambert_w0(z);
std::cout << "lambert_w0(z) = " << r << std::endl;
std::cout << "lambert_w0(z) = " << r << std::endl;
// 0.8526055020137254913464724146953174668984533001514035087721073946525150656742630448965773783502494847334503972691804119834761668851953598826198984364998343940330324849743119327028383008883133161249045727544669202220292076639777316648311871183719040610274221013237163543451621208284315007250267190731048119566857455987975973474411544571619699938899354169616378479326962044241495398851839432070255805880208619490399218130868317114428351234208216131218024303904457925834743326836272959669122797896855064630871955955318383064292191644322931561534814178034773896739684452724587331245831001449498844495771266728242975586931792421997636537572767708722190588748148949667744956650966402600446780664924889043543203483210769017254907808218556111831854276511280553252641907484685164978750601216344998778097446525021666473925144772131644151718261199915247932015387685261438125313159125475113124470774926288823525823567568542843625471594347837868505309329628014463491611881381186810879712667681285740515197493390563
// Wolfram alpha command N[productlog[0, 2.0],1000] gives the identical result:
// 0.8526055020137254913464724146953174668984533001514035087721073946525150656742630448965773783502494847334503972691804119834761668851953598826198984364998343940330324849743119327028383008883133161249045727544669202220292076639777316648311871183719040610274221013237163543451621208284315007250267190731048119566857455987975973474411544571619699938899354169616378479326962044241495398851839432070255805880208619490399218130868317114428351234208216131218024303904457925834743326836272959669122797896855064630871955955318383064292191644322931561534814178034773896739684452724587331245831001449498844495771266728242975586931792421997636537572767708722190588748148949667744956650966402600446780664924889043543203483210769017254907808218556111831854276511280553252641907484685164978750601216344998778097446525021666473925144772131644151718261199915247932015387685261438125313159125475113124470774926288823525823567568542843625471594347837868505309329628014463491611881381186810879712667681285740515197493390563
@@ -212,13 +212,13 @@ int main()
std::cout.precision(std::numeric_limits<double>::max_digits10);
// Show all potentially significant decimal digits,
std::cout << std::showpoint << std::endl;
std::cout << std::showpoint << std::endl;
// and show significant trailing zeros too.
double z = +1;
std::cout << "Lambert W (" << z << ") = " << lambert_w0(z) << std::endl;
std::cout << "Lambert W (" << z << ") = " << lambert_w0(z) << std::endl;
// Lambert W (1.0000000000000000) = 0.56714329040978384
std::cout << "\nLambert W (" << z << ", my_throw_policy()) = "
<< lambert_w0(z, my_throw_policy()) << std::endl;
std::cout << "\nLambert W (" << z << ", my_throw_policy()) = "
<< lambert_w0(z, my_throw_policy()) << std::endl;
// Lambert W (1.0000000000000000, my_throw_policy()) = 0.56714329040978384
//] //[/lambert_w_simple_example_error_policies]
}
@@ -230,7 +230,7 @@ int main()
double r = lambert_wm1(z);
std::cout << "lambert_wm1(+1.) = " << r << std::endl;
//] [/lambert_w_simple_examples_out_of_range]
// Error in function boost::math::lambert_wm1<RealType>(<RealType>):
// Error in function boost::math::lambert_wm1<RealType>(<RealType>):
// Argument z = 1 is out of range (z <= 0) for Lambert W-1 branch! (Try Lambert W0 branch?)
}
}
@@ -239,7 +239,7 @@ int main()
std::cout << ex.what() << std::endl;
}
} // int main()
/*
Output:
@@ -248,9 +248,4 @@ Error in function boost::math::lambert_wm1<RealType>(<RealType>):
Argument z = 1 is out of range (z <= 0) for Lambert W-1 branch! (Try Lambert W0 branch?)
//] [/lambert_w_simple_examples_error_message_1]
/*
*/