Skip to content

Commit 529dfac

Browse files
authored
Merge pull request #745 from boostorg/develop
Merge to Master for 1.90
2 parents e0c1125 + 29a192e commit 529dfac

File tree

108 files changed

+3921
-2112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3921
-2112
lines changed

.github/workflows/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
#timeout-minutes: 120
6262
runs-on: ${{matrix.os}}
6363
container: ${{matrix.container}}
64-
env: {B2_USE_CCACHE: 1}
64+
env: {B2_USE_CCACHE: 0}
6565

6666
steps:
6767
- name: Setup environment

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ requiring extended range and precision.
2626

2727
Multiprecision consists of a generic interface to the mathematics
2828
of large numbers as well as a selection of big number backends.
29-
This includes interfaces to GMP, MPFR, MPIR and TomMath
29+
These include interfaces to GMP, MPFR, MPIR and TomMath
3030
and also Multiprecision's own collection of Boost-licensed,
3131
header-only backends for integers, rationals, floats and complex-floats.
3232

@@ -42,6 +42,9 @@ This usually provides better performance than using types configured without exp
4242

4343
The full documentation is available on [boost.org](http://www.boost.org/doc/libs/release/libs/multiprecision/index.html).
4444

45+
A practical, comprehensive, instructive, clear and very helpful video regarding the use of Multiprecision
46+
can be found [here](https://www.youtube.com/watch?v=mK4WjpvLj4c).
47+
4548
## Using Multiprecision
4649

4750
<p align="center">

config/Jamfile.v2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# copyright John Maddock 2008
22
# Distributed under the Boost Software License, Version 1.0.
33
# (See accompanying file LICENSE_1_0.txt or copy at
4-
# http://www.boost.org/LICENSE_1_0.txt.
4+
# http://www.boost.org/LICENSE_1_0.txt)
55

66
import-search /boost/config/checks ;
77

doc/html/boost_multiprecision/tut/interval.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
There is one currently only one interval number type supported - <a href="http://perso.ens-lyon.fr/nathalie.revol/software.html" target="_top">MPFI</a>.
3333
</p>
3434
<p>
35-
[ section:mpfi mpfi_float]
35+
[section:mpfi mpfi_float]
3636
</p>
3737
</div>
3838
<div class="copyright-footer">Copyright © 2002-2020 John

doc/introduction.qbk

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ but a header-only Boost license version is always available (if somewhat slower)
6060

6161
Should you just wish to 'cut to the chase' just to get bigger integers and/or bigger and more precise reals as simply and portably as possible,
6262
close to 'drop-in' replacements for the __fundamental_type analogs,
63-
then use a fully Boost-licensed number type, and skip to one of more of :
63+
then use a fully Boost-licensed number type, and skip to one or more of:
6464

6565
* __cpp_int for multiprecision integers,
6666
* __cpp_rational for rational types,
@@ -133,8 +133,8 @@ Conversions are also allowed:
133133

134134
However conversions that are inherently lossy are either declared explicit or else forbidden altogether:
135135

136-
d = 3.14; // Error implicit conversion from double not allowed.
137-
d = static_cast<mp::int512_t>(3.14); // OK explicit construction is allowed
136+
d = 3.14; // Error, implicit conversion from double not allowed.
137+
d = static_cast<mp::int512_t>(3.14); // OK, explicit construction is allowed
138138

139139
Mixed arithmetic will fail if the conversion is either ambiguous or explicit:
140140

@@ -195,9 +195,9 @@ of references to the arguments of the function, plus some compile-time informati
195195
is.
196196

197197
The great advantage of this method is the ['elimination of temporaries]: for example, the "naive" implementation
198-
of `operator*` above, requires one temporary for computing the result, and at least another one to return it. It's true
198+
of `operator*` above requires one temporary for computing the result, and at least another one to return it. It's true
199199
that sometimes this overhead can be reduced by using move-semantics, but it can't be eliminated completely. For example,
200-
lets suppose we're evaluating a polynomial via Horner's method, something like this:
200+
let's suppose we're evaluating a polynomial via Horner's method, something like this:
201201

202202
T a[7] = { /* some values */ };
203203
//....
@@ -206,9 +206,9 @@ lets suppose we're evaluating a polynomial via Horner's method, something like t
206206
If type `T` is a `number`, then this expression is evaluated ['without creating a single temporary value]. In contrast,
207207
if we were using the [mpfr_class] C++ wrapper for [mpfr] - then this expression would result in no less than 11
208208
temporaries (this is true even though [mpfr_class] does use expression templates to reduce the number of temporaries somewhat). Had
209-
we used an even simpler wrapper around [mpfr] like [mpreal] things would have been even worse and no less that 24 temporaries
209+
we used an even simpler wrapper around [mpfr] like [mpreal] things would have been even worse and no less than 24 temporaries
210210
are created for this simple expression (note - we actually measure the number of memory allocations performed rather than
211-
the number of temporaries directly, note also that the [mpf_class] wrapper that will be supplied with GMP-5.1 reduces the number of
211+
the number of temporaries directly, note also that the [mpf_class] wrapper supplied with GMP-5.1 or later reduces the number of
212212
temporaries to pretty much zero). Note that if we compile with expression templates disabled and rvalue-reference support
213213
on, then actually still have no wasted memory allocations as even though temporaries are created, their contents are moved
214214
rather than copied.
@@ -247,7 +247,7 @@ is created in this case.
247247

248248
Given the comments above, you might be forgiven for thinking that expression-templates are some kind of universal-panacea:
249249
sadly though, all tricks like this have their downsides. For one thing, expression template libraries
250-
like this one, tend to be slower to compile than their simpler cousins, they're also harder to debug
250+
like this one tend to be slower to compile than their simpler cousins, they're also harder to debug
251251
(should you actually want to step through our code!), and rely on compiler optimizations being turned
252252
on to give really good performance. Also, since the return type from expressions involving `number`s
253253
is an "unmentionable implementation detail", you have to be careful to cast the result of an expression
@@ -256,23 +256,23 @@ to the actual number type when passing an expression to a template function. Fo
256256
template <class T>
257257
void my_proc(const T&);
258258

259-
Then calling:
259+
Then calling
260260

261261
my_proc(a+b);
262262

263-
Will very likely result in obscure error messages inside the body of `my_proc` - since we've passed it
263+
will very likely result in obscure error messages inside the body of `my_proc` - since we've passed it
264264
an expression template type, and not a number type. Instead we probably need:
265265

266266
my_proc(my_number_type(a+b));
267267

268268
Having said that, these situations don't occur that often - or indeed not at all for non-template functions.
269269
In addition, all the functions in the Boost.Math library will automatically convert expression-template arguments
270-
to the underlying number type without you having to do anything, so:
270+
to the underlying number type without you having to do anything, so
271271

272272
mpfr_float_100 a(20), delta(0.125);
273273
boost::math::gamma_p(a, a + delta);
274274

275-
Will work just fine, with the `a + delta` expression template argument getting converted to an `mpfr_float_100`
275+
will work just fine, with the `a + delta` expression template argument getting converted to an `mpfr_float_100`
276276
internally by the Boost.Math library.
277277

278278
[caution In C++11 you should never store an expression template using:
@@ -299,7 +299,7 @@ dramatic as the reduction in number of temporaries would suggest. For example,
299299
we see the following typical results for polynomial execution:
300300

301301
[table Evaluation of Order 6 Polynomial.
302-
[[Library] [Relative Time] [Relative number of memory allocations]]
302+
[[Library] [Relative Time] [Relative Number of Memory Allocations]]
303303
[[number] [1.0 (0.00957s)] [1.0 (2996 total)]]
304304
[[[mpfr_class]] [1.1 (0.0102s)] [4.3 (12976 total)]]
305305
[[[mpreal]] [1.6 (0.0151s)] [9.3 (27947 total)]]
@@ -311,13 +311,13 @@ a number of reasons for this:
311311
* The cost of extended-precision multiplication and division is so great, that the times taken for these tend to
312312
swamp everything else.
313313
* The cost of an in-place multiplication (using `operator*=`) tends to be more than an out-of-place
314-
`operator*` (typically `operator *=` has to create a temporary workspace to carry out the multiplication, where
315-
as `operator*` can use the target variable as workspace). Since the expression templates carry out their
314+
`operator*` (typically `operator *=` has to create a temporary workspace to carry out the multiplication,
315+
whereas `operator*` can use the target variable as workspace). Since the expression templates carry out their
316316
magic by converting out-of-place operators to in-place ones, we necessarily take this hit. Even so the
317317
transformation is more efficient than creating the extra temporary variable, just not by as much as
318318
one would hope.
319319

320-
Finally, note that `number` takes a second template argument, which, when set to `et_off` disables all
320+
Finally, note that `number` takes a second template argument, which, when set to `et_off`, disables all
321321
the expression template machinery. The result is much faster to compile, but slower at runtime.
322322

323323
We'll conclude this section by providing some more performance comparisons between these three libraries,

doc/multiprecision.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
[def __compiler_support [@https://en.cppreference.com/w/cpp/compiler_support compiler support]]
133133
[def __ULP [@http://en.wikipedia.org/wiki/Unit_in_the_last_place Unit in the last place (ULP)]]
134134
[def __Mathematica [@http://www.wolfram.com/products/mathematica/index.html Wolfram Mathematica]]
135-
[def __WolframAlpha [@http://www.wolframalpha.com/ Wolfram Alpha]]
135+
[def __WolframAlphaGLCoefs [@https://www.wolframalpha.com/input?i=Fit%5B%7B%7B21.0%2C+3.5%7D%2C+%7B51.0%2C+11.1%7D%2C+%7B101.0%2C+22.5%7D%2C+%7B201.0%2C+46.8%7D%7D%2C+%7B1%2C+d%2C+d%5E2%7D%2C+d%5D+FullSimplify%5B%25%5D Wolfram Alpha Gauss-Laguerre coefficients]]
136136
[def __Boost_Serialization [@https://www.boost.org/doc/libs/release/libs/serialization/doc/index.html Boost.Serialization]]
137137
[def __Boost_Math [@https://www.boost.org/doc/libs/release/libs/math/doc/index.html Boost.Math]]
138138
[def __Boost_Multiprecision [@https://www.boost.org/doc/libs/release/libs/multiprecision/doc/index.html Boost.Multiprecision]]

doc/performance.qbk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Distributed under the Boost Software License, Version 1.0.
77
(See accompanying file LICENSE_1_0.txt or copy at
8-
http://www.boost.org/LICENSE_1_0.txt).
8+
http://www.boost.org/LICENSE_1_0.txt.)
99
]
1010

1111
[section:perf Performance Comparison]
@@ -30,7 +30,7 @@ share similar relative performances.
3030

3131
The backends which effectively wrap GMP/MPIR and MPFR
3232
retain the superior performance of the low-level big-number engines.
33-
When these are used (in association with at least some level of optmization)
33+
When these are used (in association with at least some level of optimization)
3434
they achieve and retain the expected low-level performances.
3535

3636
At low digit counts, however, it is noted that the performances of __cpp_int,
@@ -47,7 +47,7 @@ the performances of the Boost-licensed, self-written backends.
4747
At around a few hundred to several thousands of digits,
4848
factors of about two through five are observed,
4949
whereby GMP/MPIR-based calculations are (performance-wise)
50-
supreior ones.
50+
superior ones.
5151

5252
At a few thousand decimal digits, the upper end of
5353
the Boost backends is reached. At the moment,

doc/performance_integer_real_world.qbk

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ type which was custom written for this specific task:
1818

1919
[table
2020
[[Integer Type][Relative Performance (Actual time in parenthesis)]]
21-
[[checked_int1024_t][1.53714(0.0415328s)]]
22-
[[checked_int256_t][1.20715(0.0326167s)]]
23-
[[checked_int512_t][1.2587(0.0340095s)]]
24-
[[cpp_int][1.80575(0.0487904s)]]
25-
[[extended_int][1.35652(0.0366527s)]]
26-
[[int1024_t][1.36237(0.0368107s)]]
27-
[[int256_t][1(0.0270196s)]]
28-
[[int512_t][1.0779(0.0291243s)]]
29-
[[mpz_int][3.83495(0.103619s)]]
30-
[[tom_int][41.6378(1.12504s)]]
21+
[[checked_int1024_t][1.53714 (0.0415328s)]]
22+
[[checked_int256_t][1.20715 (0.0326167s)]]
23+
[[checked_int512_t][1.2587 (0.0340095s)]]
24+
[[cpp_int][1.80575 (0.0487904s)]]
25+
[[extended_int][1.35652 (0.0366527s)]]
26+
[[int1024_t][1.36237 (0.0368107s)]]
27+
[[int256_t][1 (0.0270196s)]]
28+
[[int512_t][1.0779 (0.0291243s)]]
29+
[[mpz_int][3.83495 (0.103619s)]]
30+
[[tom_int][41.6378 (1.12504s)]]
3131
]
3232

3333
Note how for this use case, any dynamic allocation is a performance killer.
@@ -38,18 +38,18 @@ since that is the rate limiting step:
3838

3939
[table
4040
[[Integer Type][Relative Performance (Actual time in parenthesis)]]
41-
[[checked_uint1024_t][9.52301(0.0422246s)]]
42-
[[cpp_int][11.2194(0.0497465s)]]
43-
[[cpp_int (1024-bit cache)][10.7941(0.0478607s)]]
44-
[[cpp_int (128-bit cache)][11.0637(0.0490558s)]]
45-
[[cpp_int (256-bit cache)][11.5069(0.0510209s)]]
46-
[[cpp_int (512-bit cache)][10.3303(0.0458041s)]]
47-
[[cpp_int (no Expression templates)][16.1792(0.0717379s)]]
48-
[[mpz_int][1.05106(0.00466034s)]]
49-
[[mpz_int (no Expression templates)][1(0.00443395s)]]
50-
[[tom_int][5.10595(0.0226395s)]]
51-
[[tom_int (no Expression templates)][61.9684(0.274765s)]]
52-
[[uint1024_t][9.32113(0.0413295s)]]
41+
[[checked_uint1024_t][9.52301 (0.0422246s)]]
42+
[[cpp_int][11.2194 (0.0497465s)]]
43+
[[cpp_int (1024-bit cache)][10.7941 (0.0478607s)]]
44+
[[cpp_int (128-bit cache)][11.0637 (0.0490558s)]]
45+
[[cpp_int (256-bit cache)][11.5069 (0.0510209s)]]
46+
[[cpp_int (512-bit cache)][10.3303 (0.0458041s)]]
47+
[[cpp_int (no Expression templates)][16.1792 (0.0717379s)]]
48+
[[mpz_int][1.05106 (0.00466034s)]]
49+
[[mpz_int (no Expression templates)][1 (0.00443395s)]]
50+
[[tom_int][5.10595 (0.0226395s)]]
51+
[[tom_int (no Expression templates)][61.9684 (0.274765s)]]
52+
[[uint1024_t][9.32113 (0.0413295s)]]
5353
]
5454

5555
It's interesting to note that expression templates have little effect here - perhaps because the actual expressions involved

doc/performance_overhead.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for the [@../../performance/voronoi_performance.cpp voronoi-diagram builder test
3434

3535
[table
3636
[[Type][Relative time]]
37-
[[`int64_t`][[*1.0](0.0128646s)]]
37+
[[`int64_t`][[*1.0] (0.0128646s)]]
3838
[[`number<arithmetic_backend<int64_t>, et_off>`][1.005 (0.0129255s)]]
3939
]
4040

doc/performance_rational_real_world.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ calculate the n'th Bernoulli number via mixed rational/integer arithmetic to giv
5555
[[198][167.594528][0.8947434429][1.326461858]]
5656
]
5757

58-
In this use case, most the of the rational numbers are fairly small and so the times taken are dominated by
58+
In this use case, most of the rational numbers are fairly small and so the times taken are dominated by
5959
the number of allocations performed. The following table illustrates how well each type performs on suppressing
6060
allocations:
6161

0 commit comments

Comments
 (0)