Skip to content

Commit 55bf069

Browse files
authored
Fix mistakes (#729)
* Update Jamfile.v2 * Update introduction.qbk * Update tutorial.qbk * Update tutorial_cpp_int.qbk * Update tutorial_gmp_int.qbk * Update tutorial_tommath.qbk * Update integer_examples.cpp * Update tutorial_cpp_bin_float.qbk * Update tutorial_cpp_dec_float.qbk * Update tutorial_gmp_float.qbk * Update tutorial_mpfr_float.qbk * Update tutorial_float128.qbk * Update tutorial_float_builtin_ctor.qbk * Update big_seventh.cpp * Update tutorial_float_eg.qbk * Update floating_point_examples.cpp * Update mpfr_precision.cpp * Update gauss_laguerre_quadrature.cpp * Update tutorial_interval_mpfi.qbk * Update tutorial_cpp_complex.qbk * Update tutorial_mpc_complex.qbk * Update tutorial_float128_complex.qbk * Update tutorial_complex_adaptor.qbk * Update tutorial_rational.qbk * Update tutorial_tommath_rational.qbk * Update tutorial_logged_adaptor.qbk * Update tutorial_debug_adaptor.qbk * Update tutorial_visualizers.qbk * Update tutorial_fwd.qbk * Update tutorial_conversions.qbk * Update tutorial_random.qbk * Update random_snips.cpp * Update tutorial_constexpr.qbk * Update tutorial_import_export.qbk * Update cpp_int_import_export.cpp * Update tutorial_mixed_precision.qbk * Update tutorial_variable_precision.qbk * Update scoped_precision_example.cpp * Update tutorial_numeric_limits.qbk * Update tutorial_numeric_limits.qbk * Update numeric_limits_snips.cpp * Update numeric_limits_snips.cpp * Update tutorial_numeric_limits.qbk * Update numeric_limits_snips.cpp * Update numeric_limits_snips.cpp * Update tutorial_io.qbk * Update reference_number.qbk * Update reference_cpp_bin_float.qbk * Update reference_cpp_double_fp_backend.qbk * Update reference_internal_support.qbk * Update reference_backend_requirements.qbk * Update performance.qbk * Update performance_overhead.qbk * Update performance_real_world.qbk * Update performance_integer_real_world.qbk * Update performance_rational_real_world.qbk * Update reference_number.qbk * Update tutorial_numeric_limits.qbk * Update reference_backend_requirements.qbk
1 parent 3d32b38 commit 55bf069

Some content is hidden

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

51 files changed

+246
-246
lines changed

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/introduction.qbk

Lines changed: 15 additions & 15 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,7 +206,7 @@ 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
211211
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
@@ -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/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

doc/performance_real_world.qbk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ increases contension inside new/delete.
2323
[[cpp_dec_float_50 (3 concurrent threads)][5.66114 (0.524077s)][424]]
2424
[[mpf_float_50][1.03648 (0.0959515s)][640961]]
2525
[[mpf_float_50 (3 concurrent threads)][1.50439 (0.139268s)][2563517]]
26-
[[mpf_float_50 (no expression templates][1 (0.0925745s)][1019039]]
27-
[[mpf_float_50 (no expression templates (3 concurrent threads)][1.52451 (0.141131s)][4075842]]
26+
[[mpf_float_50 (no expression templates)][1 (0.0925745s)][1019039]]
27+
[[mpf_float_50 (no expression templates) (3 concurrent threads)][1.52451 (0.141131s)][4075842]]
2828
[[mpfr_float_50][1.2513 (0.115838s)][583054]]
2929
[[mpfr_float_50 (3 concurrent threads)][1.61301 (0.149324s)][2330876]]
30-
[[mpfr_float_50 (no expression templates][1.42667 (0.132073s)][999594]]
31-
[[mpfr_float_50 (no expression templates (3 concurrent threads)][2.00203 (0.185337s)][4000039]]
30+
[[mpfr_float_50 (no expression templates)][1.42667 (0.132073s)][999594]]
31+
[[mpfr_float_50 (no expression templates) (3 concurrent threads)][2.00203 (0.185337s)][4000039]]
3232
[[static_mpfr_float_50][1.18358 (0.10957s)][22930]]
3333
[[static_mpfr_float_50 (3 concurrent threads)][1.38802 (0.128496s)][93140]]
3434
[[static_mpfr_float_50 (no expression templates)][1.14598 (0.106089s)][46861]]
@@ -41,9 +41,9 @@ increases contension inside new/delete.
4141
[[cpp_bin_float_50 (3 concurrent threads)][3.50535 (56.6s)][28]]
4242
[[cpp_dec_float_50][4.82763 (77.9505s)][0]]
4343
[[mpf_float_50][1.06817 (17.2475s)][123749688]]
44-
[[mpf_float_50 (no expression templates][1 (16.1468s)][152610085]]
44+
[[mpf_float_50 (no expression templates)][1 (16.1468s)][152610085]]
4545
[[mpfr_float_50][1.18754 (19.1749s)][118401290]]
46-
[[mpfr_float_50 (no expression templates][1.36782 (22.0858s)][152816346]]
46+
[[mpfr_float_50 (no expression templates)][1.36782 (22.0858s)][152816346]]
4747
[[static_mpfr_float_50][1.04471 (16.8686s)][113395]]
4848
]
4949

0 commit comments

Comments
 (0)