Merge pull request #721 from boostorg/issue716

Fix #716 and fix #717 and fix #718 and fix #723 via update docs from reviews
This commit is contained in:
Christopher Kormanyos
2025-07-12 22:09:05 +02:00
committed by GitHub
8 changed files with 24 additions and 89 deletions
+4 -1
View File
@@ -26,7 +26,7 @@ requiring extended range and precision.
Multiprecision consists of a generic interface to the mathematics
of large numbers as well as a selection of big number backends.
This includes interfaces to GMP, MPFR, MPIR and TomMath
These include interfaces to GMP, MPFR, MPIR and TomMath
and also Multiprecision's own collection of Boost-licensed,
header-only backends for integers, rationals, floats and complex-floats.
@@ -42,6 +42,9 @@ This usually provides better performance than using types configured without exp
The full documentation is available on [boost.org](http://www.boost.org/doc/libs/release/libs/multiprecision/index.html).
A practical, comprehensive, instructive, clear and very helpful video regarding the use of Multiprecision
can be found [here](https://www.youtube.com/watch?v=mK4WjpvLj4c).
## Using Multiprecision
<p align="center">
+3
View File
@@ -16,6 +16,9 @@ In order to use this library you need to make two choices:
[link boost_multiprecision.tut.floats floating-point], [link boost_multiprecision.tut.rational rational], or [link boost_multiprecision.tut.complex complex]).
* Which back-end do I want to perform the actual arithmetic (Boost-supplied, GMP, MPFR, MPC, Tommath etc)?
A practical, comprehensive, instructive, clear and very helpful video regarding the use of Multiprecision
can be found [@https://www.youtube.com/watch?v=mK4WjpvLj4c here].
[include tutorial_integer.qbk]
[include tutorial_floats.qbk]
[include tutorial_interval_mpfi.qbk]
-50
View File
@@ -1,50 +0,0 @@
[/
Copyright 2011 - 2020 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 Christopher Kormanyos.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:tommath_rational tommath_rational]
`#include <boost/multiprecision/tommath.hpp>`
namespace boost{ namespace multiprecision{
typedef rational_adpater<tommath_int> tommath_rational;
typedef number<tommath_rational > tom_rational;
}} // namespaces
The `tommath_rational` back-end is used via the typedef `boost::multiprecision::tom_rational`. It acts as a thin wrapper around
`boost::rational<tom_int>`
to provide a rational number type that is a drop-in replacement for the native C++ number types, but with unlimited precision.
The advantage of using this type rather than `boost::rational<tom_int>` directly, is that it is expression-template enabled,
greatly reducing the number of temporaries created in complex expressions.
There are also non-member functions:
tom_int numerator(const tom_rational&);
tom_int denominator(const tom_rational&);
which return the numerator and denominator of the number.
Things you should know when using this type:
* Default constructed `tom_rational`s have the value zero (this the inherited Boost.Rational behavior).
* Division by zero results in a `std::overflow_error` being thrown.
* Conversion from a string results in a `std::runtime_error` being thrown if the string can not be
interpreted as a valid rational number.
* No changes are made to [tommath]'s global state, so this type can safely coexist with other [tommath] code.
* Performance of this type has been found to be pretty poor - this need further investigation - but it appears that Boost.Rational
needs some improvement in this area.
[h5 Example:]
[mp_rat_eg]
[endsect] [/section:tommath_rational tommath_rational]
+1 -7
View File
@@ -32,13 +32,7 @@ multiprecision values can easily be inspected in the debugger by looking at the
The down side of this approach is that runtimes are much slower when using this type. Set against that it can make
debugging very much easier, certainly much easier than sprinkling code with `printf` statements.
When used in conjunction with the Visual C++ debugger visualisers, the value of a multiprecision type that uses this
backend is displayed in the debugger just a __fundamental value would be, here we're inspecting a value of type
`number<debug_adaptor<cpp_dec_float<50> > >`:
[$../debugger1.png]
Otherwise you will need to expand out the view and look at the "debug_value" member:
You will need to expand out the view and look at the "debug_value" member:
[$../debugger2.png]
-1
View File
@@ -14,6 +14,5 @@ Backend types listed in this section are predominantly designed to aid debugging
[include tutorial_logged_adaptor.qbk]
[include tutorial_debug_adaptor.qbk]
[include tutorial_visualizers.qbk]
[endsect] [/section:misc Miscellaneous Number Types.]
-1
View File
@@ -24,7 +24,6 @@ The following back-ends provide rational number arithmetic:
[include tutorial_cpp_rational.qbk]
[include tutorial_gmp_rational.qbk]
[include tutorial_tommath_rational.qbk]
[include tutorial_boost_rational.qbk]
[include tutorial_rational_adaptor.qbk]
[endsect] [/section:rational Rational Number Types]
+9 -9
View File
@@ -1,7 +1,7 @@
[/
Copyright 2011 - 2020 John Maddock.
Copyright 2011 - 2025 John Maddock.
Copyright 2013 - 2019 Paul A. Bristow.
Copyright 2013 Christopher Kormanyos.
Copyright 2013 - 2025 Christopher Kormanyos.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@@ -10,14 +10,14 @@
[section:visualizers Visual C++ Debugger Visualizers]
[important This section is seriously out of date compared to recent Visual C++ releases.]
[important This section is seriously out of date compared to recent Visual C++ releases. A modernization of Multiprecision's visualizers is planned for Visual Studio 2022 (and beyond). The legacy description has been maintained and is provided below.]
Let's face it debugger multiprecision numbers is hard - simply because we can't easily inspect the value of the numbers.
Visual C++ provides a partial solution in the shape of "visualizers" which provide improved views of complex data structures,
these visualizers need to be added to the `[Visualizer]` section of `autoexp.dat` located in the `Common7/Packages/Debugger`
directory of your Visual Studio installation. The actual visualizer code is in the sandbox
[@https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/multiprecision.vis.txt here] - just cut and paste the code
into your `autoexp.dat` file.
Let's face it debugging multiprecision numbers is challenging - simply because we can't easily inspect the value of the numbers.
Visual C++ provides a partial solution in the shape of "visualizers" which provide improved views of complex data structures.
Previously, there was preliminary support for visualizers within older versions of Visual Studio.
These legacy visualizers needed to be added to the `[Visualizer]` section of `autoexp.dat` located in the `Common7/Packages/Debugger`
directory of the local Visual Studio installation. The actual visualizer code had previously been stored in the sandbox.
[note These visualizers have only been tested with VC10, also given the ability of buggy visualizers to crash your Visual C++
debugger, make sure you back up `autoexp.dat` file before using these!!]
+7 -20
View File
@@ -1,5 +1,8 @@
///////////////////////////////////////////////////////////////
// Copyright 2018 Nick Thompson. Distributed under the Boost
// Copyright 2018 - 2025 Nick Thompson.
// Copyright 2025 John Maddock.
// Copyright 2025 Christopher Kormanyos.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
@@ -8,10 +11,11 @@ In the following, we will show how using MPC backend allows for the same operati
*/
//[cpp_complex_eg
#include <iostream>
#include <complex>
#include <boost/multiprecision/cpp_complex.hpp>
#include <complex>
#include <iostream>
template<class Complex>
void complex_number_examples()
{
@@ -35,39 +39,22 @@ void complex_number_examples()
std::cout << "Polar coordinates (phase !=0) : " << polar(r, theta) << std::endl;
std::cout << "\nElementary special functions:\n";
using std::exp;
std::cout << "exp(z1) = " << exp(z1) << std::endl;
using std::log;
std::cout << "log(z1) = " << log(z1) << std::endl;
using std::log10;
std::cout << "log10(z1) = " << log10(z1) << std::endl;
using std::pow;
std::cout << "pow(z1, z1) = " << pow(z1, z1) << std::endl;
using std::sqrt;
std::cout << "Take its square root : " << sqrt(z1) << std::endl;
using std::sin;
std::cout << "sin(z1) = " << sin(z1) << std::endl;
using std::cos;
std::cout << "cos(z1) = " << cos(z1) << std::endl;
using std::tan;
std::cout << "tan(z1) = " << tan(z1) << std::endl;
using std::asin;
std::cout << "asin(z1) = " << asin(z1) << std::endl;
using std::acos;
std::cout << "acos(z1) = " << acos(z1) << std::endl;
using std::atan;
std::cout << "atan(z1) = " << atan(z1) << std::endl;
using std::sinh;
std::cout << "sinh(z1) = " << sinh(z1) << std::endl;
using std::cosh;
std::cout << "cosh(z1) = " << cosh(z1) << std::endl;
using std::tanh;
std::cout << "tanh(z1) = " << tanh(z1) << std::endl;
using std::asinh;
std::cout << "asinh(z1) = " << asinh(z1) << std::endl;
using std::acosh;
std::cout << "acosh(z1) = " << acosh(z1) << std::endl;
using std::atanh;
std::cout << "atanh(z1) = " << atanh(z1) << std::endl;
}