1 [section:high_precision Using Boost.Math with High-Precision Floating-Point Libraries]
3 The special functions, distributions, constants and tools in this library
4 can be used with a number of high-precision libraries, including:
14 The last four have some license restrictions;
15 only __multiprecision when using the `cpp_float` backend
16 can provide an unrestricted [@http://www.boost.org/LICENSE_1_0.txt Boost] license.
18 At present, the price of a free license is slightly lower speed.
20 Of course, the main cost of higher precision is very much decreased
21 (usually at least hundred-fold) computation speed, and big increases in memory use.
23 Some libraries offer true
24 [@http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic arbitrary-precision arithmetic]
25 where the precision is limited only by available memory and compute time, but most are used
26 at some arbitrarily-fixed precision, say 100 decimal digits, like __multiprecision `cpp_dec_float_100`.
28 __multiprecision can operate in both ways, but the most popular choice is likely to be about a hundred
29 decimal digits, though examples of computing about a million digits have been demonstrated.
31 [section:why_high_precision Why use a high-precision library rather than built-in floating-point types?]
33 For nearly all applications, the built-in floating-point types, `double`
34 (and `long double` if this offers higher precision than `double`)
35 offer enough precision, typically a dozen decimal digits.
37 Some reasons why one would want to use a higher precision:
39 * A much more precise result (many more digits) is just a requirement.
40 * The range of the computed value exceeds the range of the type: factorials are the textbook example.
41 * Using `double` is (or may be) too inaccurate.
42 * Using `long double` (or may be) is too inaccurate.
43 * Using an extended-precision type implemented in software as
44 [@http://en.wikipedia.org/wiki/Double-double_(arithmetic)#Double-double_arithmetic double-double]
45 ([@http://en.wikipedia.org/wiki/Darwin_(operating_system) Darwin]) is sometimes unpredictably inaccurate.
46 * Loss of precision or inaccuracy caused by extreme arguments or
47 [@http://en.wikipedia.org/wiki/Loss_of_significance cancellation errors].
48 * An accuracy as good as possible for a chosen built-in floating-point type is required.
49 * As a reference value, for example, to determine the inaccuracy
50 of a value computed with a built-in floating point type,
51 (perhaps even using some quick'n'dirty algorithm).
52 The accuracy of many functions and distributions in Boost.Math has been measured in this way
53 from tables of very high precision (up to 1000 decimal digits).
55 Many functions and distributions have differences from exact values
56 that are only a few least significant bits - computation noise.
57 Others, often those for which analytical solutions are not available,
58 require approximations and iteration:
59 these may lose several decimal digits of precision.
61 Much larger loss of precision can occur for [@http://en.wikipedia.org/wiki/Boundary_case boundary]
62 or [@http://en.wikipedia.org/wiki/Corner_case corner cases],
63 often caused by [@http://en.wikipedia.org/wiki/Loss_of_significance cancellation errors].
65 (Some of the worst and most common examples of
66 [@http://en.wikipedia.org/wiki/Loss_of_significance cancellation error or loss of significance]
67 can be avoided by using __complements: see __why_complements).
69 If you require a value which is as accurate as can be represented in the floating-point type,
71 [@https://en.wikipedia.org/wiki/Floating-point_arithmetic#Representable_numbers,_conversion_and_rounding closest representable value]
72 correctly rounded to nearest,
73 and has an error less than 1/2 a
74 [@http://en.wikipedia.org/wiki/Least_significant_bit least significant bit] or
75 [@http://en.wikipedia.org/wiki/Unit_in_the_last_place ulp]
76 it may be useful to use a higher-precision type,
77 for example, `cpp_dec_float_50`, to generate this value.
78 Conversion of this value to a built-in floating-point type ('float', `double` or `long double`)
79 will not cause any further loss of precision.
80 A decimal digit string will also be 'read' precisely by the compiler
81 into a built-in floating-point type to the nearest representable value.
83 [note In contrast, reading a value from an `std::istream` into a built-in floating-point type
84 is [*not guaranteed by the C++ Standard] to give the nearest representable value.]
86 William Kahan coined the term
87 [@http://en.wikipedia.org/wiki/Rounding#The_table-maker.27s_dilemma Table-Maker's Dilemma]
88 for the problem of correctly rounding functions.
89 Using a much higher precision (50 or 100 decimal digits)
90 is a practical way of generating (almost always) correctly rounded values.
92 [endsect] [/section:why_high_precision Why use a high-precision library rather than built-in floating-point types?]
94 [section:use_multiprecision Using Boost.Multiprecision]
96 [*All new projects are recommended to use __multiprecision.]
98 [import ../../example/big_seventh.cpp]
100 [big_seventh_example_1]
101 [big_seventh_example_2]
102 The full source of this example is at [@../../example/big_seventh.cpp big_seventh.cpp]
104 [import ../../example/fft_sines_table.cpp]
106 [fft_sines_table_example_1]
107 [fft_sines_table_example_2]
108 [fft_sines_table_example_3
113 [fft_sines_table_example_output]
115 [fft_sines_table_example_check]
117 The full source of this example is at [@../../example/fft_sines_table.cpp fft_sines_table.cpp]
119 [/TODO another example needed here]
121 [/import ../../example/ibeta_mp_example.cpp]
123 [/ibeta_mp_example_1]
125 [/The program output is:]
129 [endsect] [/section:use_multiprecision Using Boost.Multiprecision]
131 [section:float128 Using with GCC's __float128 datatype]
133 At present support for GCC's native `__float128` datatype is extremely limited: the numeric constants
134 will all work with that type, and that's about it. If you want to use the distributions or special
135 functions then you will need to provide your own wrapper header that:
137 * Provides `std::numeric_limits<__float128>` support.
138 * Provides overloads of the standard library math functions for type `__float128`
139 and which forward to the libquadmath equivalents.
141 Ultimately these facilities should be provided by GCC and `libstdc++`.
143 [endsect] [/section:float128 Using with GCC's __float128 datatype]
146 [section:use_mpfr Using With MPFR or GMP - High-Precision Floating-Point Library]
148 The special functions and tools in this library can be used with
149 [@http://www.mpfr.org MPFR] (an arbitrary precision number type based on the __GMP),
150 either via the bindings in [@../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp],
151 or via [@../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpreal.hpp].
153 [*New projects are recommended to use __multiprecision with GMP/MPFR backend instead.]
155 In order to use these bindings you will need to have installed [@http://www.mpfr.org MPFR]
156 plus its dependency the [@http://gmplib.org GMP library]. You will also need one of the
157 two supported C++ wrappers for MPFR:
158 [@http://math.berkeley.edu/~wilken/code/gmpfrxx/ gmpfrxx (or mpfr_class)],
159 or [@http://www.holoborodko.com/pavel/mpfr/ mpfr-C++ (mpreal)].
161 Unfortunately neither `mpfr_class` nor `mpreal` quite satisfy our conceptual requirements,
162 so there is a very thin set of additional interfaces and some helper traits defined in
163 [@../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp] and
164 [@../../../../boost/math/bindings/mpreal.hpp boost/math/bindings/mpreal.hpp]
165 that you should use in place of including 'gmpfrxx.h' or 'mpreal.h' directly.
166 The classes `mpfr_class` or `mpreal` are
167 then usable unchanged once this header is included, so for example `mpfr_class`'s
168 performance-enhancing expression templates are preserved and fully supported by this library:
170 #include <boost/math/bindings/mpfr.hpp>
171 #include <boost/math/special_functions/gamma.hpp>
175 mpfr_class::set_dprec(500); // 500 bit precision
177 // Note that the argument to tgamma is
178 // an expression template - that's just fine here.
180 mpfr_class v = boost::math::tgamma(sqrt(mpfr_class(2)));
181 std::cout << std::setprecision(50) << v << std::endl;
184 Alternatively use with `mpreal` would look like:
186 #include <boost/math/bindings/mpreal.hpp>
187 #include <boost/math/special_functions/gamma.hpp>
191 mpfr::mpreal::set_precision(500); // 500 bit precision
192 mpfr::mpreal v = boost::math::tgamma(sqrt(mpfr::mpreal(2)));
193 std::cout << std::setprecision(50) << v << std::endl;
196 There is a concept checking test program for mpfr support
197 [@../../../../libs/math/test/mpfr_concept_check.cpp here] and
198 [@../../../../libs/math/test/mpreal_concept_check.cpp here].
200 [endsect] [/section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library]
202 [section:e_float Using e_float Library]
204 __multiprecision was a development from the __e_float library by Christopher Kormanyos.
206 e_float can still be used with Boost.Math library via the header:
208 <boost/math/bindings/e_float.hpp>
210 And the type `boost::math::ef::e_float`:
211 this type is a thin wrapper class around ::e_float which provides the necessary
212 syntactic sugar to make everything "just work".
214 There is also a concept checking test program for e_float support
215 [@../../../../libs/math/test/e_float_concept_check.cpp here].
217 [*New projects are recommended to use __multiprecision with `cpp_float` backend instead.]
219 [endsect] [/section:e_float Using e_float Library]
221 [section:use_ntl Using NTL Library]
223 [@http://shoup.net/ntl/doc/RR.txt NTL::RR]
224 (an arbitrarily-fixed precision floating-point number type),
225 can be used via the bindings in
226 [@../../../../boost/math/bindings/rr.hpp boost/math/bindings/rr.hpp].
227 For details, see [@http://shoup.net/ntl/ NTL: A Library for doing Number Theory by
230 [*New projects are recommended to use __multiprecision instead.]
232 Unfortunately `NTL::RR` doesn't quite satisfy our conceptual requirements,
233 so there is a very thin wrapper class `boost::math::ntl::RR` defined in
234 [@../../../../boost/math/bindings/rr.hpp boost/math/bindings/rr.hpp] that you
235 should use in place of `NTL::RR`. The class is intended to be a drop-in
236 replacement for the "real" NTL::RR that adds some syntactic sugar to keep
237 this library happy, plus some of the standard library functions not implemented
240 For those functions that are based upon the __lanczos, the bindings
241 defines a series of approximations with up to 61 terms and accuracy
242 up to approximately 3e-113. This therefore sets the upper limit for accuracy
243 to the majority of functions defined this library when used with `NTL::RR`.
245 There is a concept checking test program for NTL support
246 [@../../../../libs/math/test/ntl_concept_check.cpp here].
248 [endsect] [/section:use_ntl Using With NTL - a High-Precision Floating-Point Library]
250 [section:using_test Using without expression templates for Boost.Test and others]
252 As noted in the __multiprecision documentation, certain program constructs will not compile
253 when using expression templates. One example that many users may encounter
254 is Boost.Test (1.54 and earlier) when using macro BOOST_CHECK_CLOSE and BOOST_CHECK_CLOSE_FRACTION.
256 If, for example, you wish to use any multiprecision type like `cpp_dec_float_50`
257 in place of `double` to give more precision,
258 you will need to override the default `boost::multiprecision::et_on` with
259 `boost::multiprecision::et_off`.
261 [import ../../example/test_cpp_float_close_fraction.cpp]
263 [expression_template_1]
265 A full example code is at [@../../example/test_cpp_float_close_fraction.cpp test_cpp_float_close_fraction.cpp]
267 [endsect] [/section:using_test Using without expression templates for Boost.Test and others]
268 [endsect] [/section:high_precision Using With High-Precision Floating-Point Libraries]
270 [section:real_concepts Conceptual Requirements for Real Number Types]
272 The functions and statistical distributions in this library can be used with
273 any type ['RealType] that meets the conceptual requirements given below. All
274 the built-in floating-point types like `double` will meet these requirements.
275 (Built-in types are also called __fundamental_types).
277 User-defined types that meet the conceptual requirements can also be used.
278 For example, with [link math_toolkit.high_precision.use_ntl a thin wrapper class]
279 one of the types provided with [@http://shoup.net/ntl/ NTL (RR)] can be used.
280 But now that __multiprecision library is available,
281 this has become the preferred real-number type,
282 typically __cpp_dec_float or __cpp_bin_float.
284 Submissions of binding to other extended precision types would also still be welcome.
286 The guiding principal behind these requirements is that a ['RealType]
287 behaves just like a built-in floating-point type.
289 [h4 Basic Arithmetic Requirements]
291 These requirements are common to all of the functions in this library.
293 In the following table /r/ is an object of type `RealType`, /cr/ and
295 of type `const RealType`, and /ca/ is an object of type `const arithmetic-type`
296 (arithmetic types include all the built in integers and floating point types).
299 [[Expression][Result Type][Notes]]
300 [[`RealType(cr)`][RealType]
301 [RealType is copy constructible.]]
302 [[`RealType(ca)`][RealType]
303 [RealType is copy constructible from the arithmetic types.]]
304 [[`r = cr`][RealType&][Assignment operator.]]
305 [[`r = ca`][RealType&][Assignment operator from the arithmetic types.]]
306 [[`r += cr`][RealType&][Adds cr to r.]]
307 [[`r += ca`][RealType&][Adds ar to r.]]
308 [[`r -= cr`][RealType&][Subtracts cr from r.]]
309 [[`r -= ca`][RealType&][Subtracts ca from r.]]
310 [[`r *= cr`][RealType&][Multiplies r by cr.]]
311 [[`r *= ca`][RealType&][Multiplies r by ca.]]
312 [[`r /= cr`][RealType&][Divides r by cr.]]
313 [[`r /= ca`][RealType&][Divides r by ca.]]
314 [[`-r`][RealType][Unary Negation.]]
315 [[`+r`][RealType&][Identity Operation.]]
316 [[`cr + cr2`][RealType][Binary Addition]]
317 [[`cr + ca`][RealType][Binary Addition]]
318 [[`ca + cr`][RealType][Binary Addition]]
319 [[`cr - cr2`][RealType][Binary Subtraction]]
320 [[`cr - ca`][RealType][Binary Subtraction]]
321 [[`ca - cr`][RealType][Binary Subtraction]]
322 [[`cr * cr2`][RealType][Binary Multiplication]]
323 [[`cr * ca`][RealType][Binary Multiplication]]
324 [[`ca * cr`][RealType][Binary Multiplication]]
325 [[`cr / cr2`][RealType][Binary Subtraction]]
326 [[`cr / ca`][RealType][Binary Subtraction]]
327 [[`ca / cr`][RealType][Binary Subtraction]]
328 [[`cr == cr2`][bool][Equality Comparison]]
329 [[`cr == ca`][bool][Equality Comparison]]
330 [[`ca == cr`][bool][Equality Comparison]]
331 [[`cr != cr2`][bool][Inequality Comparison]]
332 [[`cr != ca`][bool][Inequality Comparison]]
333 [[`ca != cr`][bool][Inequality Comparison]]
334 [[`cr <= cr2`][bool][Less than equal to.]]
335 [[`cr <= ca`][bool][Less than equal to.]]
336 [[`ca <= cr`][bool][Less than equal to.]]
337 [[`cr >= cr2`][bool][Greater than equal to.]]
338 [[`cr >= ca`][bool][Greater than equal to.]]
339 [[`ca >= cr`][bool][Greater than equal to.]]
340 [[`cr < cr2`][bool][Less than comparison.]]
341 [[`cr < ca`][bool][Less than comparison.]]
342 [[`ca < cr`][bool][Less than comparison.]]
343 [[`cr > cr2`][bool][Greater than comparison.]]
344 [[`cr > ca`][bool][Greater than comparison.]]
345 [[`ca > cr`][bool][Greater than comparison.]]
346 [[`boost::math::tools::digits<RealType>()`][int]
347 [The number of digits in the significand of RealType.]]
348 [[`boost::math::tools::max_value<RealType>()`][RealType]
349 [The largest representable number by type RealType.]]
350 [[`boost::math::tools::min_value<RealType>()`][RealType]
351 [The smallest representable number by type RealType.]]
352 [[`boost::math::tools::log_max_value<RealType>()`][RealType]
353 [The natural logarithm of the largest representable number by type RealType.]]
354 [[`boost::math::tools::log_min_value<RealType>()`][RealType]
355 [The natural logarithm of the smallest representable number by type RealType.]]
356 [[`boost::math::tools::epsilon<RealType>()`][RealType]
357 [The machine epsilon of RealType.]]
362 # The functions `log_max_value` and `log_min_value` can be
363 synthesised from the others, and so no explicit specialisation is required.
364 # The function `epsilon` can be synthesised from the others, so no
365 explicit specialisation is required provided the precision
366 of RealType does not vary at runtime (see the header
367 [@../../../../boost/math/bindings/rr.hpp boost/math/bindings/rr.hpp]
368 for an example where the precision does vary at runtime).
369 # The functions `digits`, `max_value` and `min_value`, all get synthesised
370 automatically from `std::numeric_limits`. However, if `numeric_limits`
371 is not specialised for type RealType, then you will get a compiler error
372 when code tries to use these functions, /unless/ you explicitly specialise them.
373 For example if the precision of RealType varies at runtime, then
374 `numeric_limits` support may not be appropriate, see
375 [@../../../../boost/math/bindings/rr.hpp boost/math/bindings/rr.hpp] for examples.
378 If `std::numeric_limits<>` is *not specialized*
379 for type /RealType/ then the default float precision of 6 decimal digits
380 will be used by other Boost programs including:
382 Boost.Test: giving misleading error messages like
384 ['"difference between {9.79796} and {9.79796} exceeds 5.42101e-19%".]
386 Boost.LexicalCast and Boost.Serialization when converting the number
387 to a string, causing potentially serious loss of accuracy on output.
389 Although it might seem obvious that RealType should require `std::numeric_limits`
390 to be specialized, this is not sensible for
391 `NTL::RR` and similar classes where the [*number of digits is a runtime parameter]
392 (whereas for `numeric_limits` everything has to be fixed at compile time).
395 [h4 Standard Library Support Requirements]
397 Many (though not all) of the functions in this library make calls
398 to standard library functions, the following table summarises the
399 requirements. Note that most of the functions in this library
400 will only call a small subset of the functions listed here, so if in
401 doubt whether a user-defined type has enough standard library
402 support to be useable the best advise is to try it and see!
404 In the following table /r/ is an object of type `RealType`,
405 /cr1/ and /cr2/ are objects of type `const RealType`, and
406 /i/ is an object of type `int`.
409 [[Expression][Result Type]]
410 [[`fabs(cr1)`][RealType]]
411 [[`abs(cr1)`][RealType]]
412 [[`ceil(cr1)`][RealType]]
413 [[`floor(cr1)`][RealType]]
414 [[`exp(cr1)`][RealType]]
415 [[`pow(cr1, cr2)`][RealType]]
416 [[`sqrt(cr1)`][RealType]]
417 [[`log(cr1)`][RealType]]
418 [[`frexp(cr1, &i)`][RealType]]
419 [[`ldexp(cr1, i)`][RealType]]
420 [[`cos(cr1)`][RealType]]
421 [[`sin(cr1)`][RealType]]
422 [[`asin(cr1)`][RealType]]
423 [[`tan(cr1)`][RealType]]
424 [[`atan(cr1)`][RealType]]
425 [[`fmod(cr1)`][RealType]]
426 [[`round(cr1)`][RealType]]
427 [[`iround(cr1)`][int]]
428 [[`trunc(cr1)`][RealType]]
429 [[`itrunc(cr1)`][int]]
432 Note that the table above lists only those standard library functions known to
433 be used (or likely to be used in the near future) by this library.
434 The following functions: `acos`, `atan2`, `fmod`, `cosh`, `sinh`, `tanh`, `log10`,
435 `lround`, `llround`, `ltrunc`, `lltrunc` and `modf`
436 are not currently used, but may be if further special functions are added.
438 Note that the `round`, `trunc` and `modf` functions are not part of the
439 current C++ standard: they are part of the additions added to C99 which will
440 likely be in the next C++ standard. There are Boost versions of these provided
441 as a backup, and the functions are always called unqualified so that
442 argument-dependent-lookup can take place.
444 In addition, for efficient and accurate results, a __lanczos is highly desirable.
445 You may be able to adapt an existing approximation from
446 [@../../../../boost/math/special_functions/lanczos.hpp
447 boost/math/special_functions/lanczos.hpp] or
448 [@../../../../boost/math/bindings/detail/big_lanczos.hpp
449 boost/math/bindings/detail/big_lanczos.hpp]:
450 in the former case you will need change
451 `static_cast`'s to `lexical_cast`'s, and the constants to /strings/
452 (in order to ensure the coefficients aren't truncated to `long doubl`e)
453 and then specialise `lanczos_traits` for type T. Otherwise you may have to hack
454 [@../../tools/lanczos_generator.cpp
455 libs/math/tools/lanczos_generator.cpp] to find a suitable
456 approximation for your RealType. The code will still compile if you don't do
457 this, but both accuracy and efficiency will be somewhat compromised in any
458 function that makes use of the gamma\/beta\/erf family of functions.
460 [endsect] [/section:real_concepts Conceptual Requirements for Real Number Types]
462 [section:dist_concept Conceptual Requirements for Distribution Types]
464 A ['DistributionType] is a type that implements the following conceptual
465 requirements, and encapsulates a statistical distribution.
467 Please note that this documentation should not be used as a substitute
469 [link math_toolkit.dist_ref reference documentation], and
470 [link math_toolkit.stat_tut tutorial] of the statistical
473 In the following table, ['d] is an object of type `DistributionType`,
474 ['cd] is an object of type `const DistributionType` and ['cr] is an
475 object of a type convertible to `RealType`.
478 [[Expression][Result Type][Notes]]
479 [[DistributionType::value_type][RealType]
480 [The real-number type /RealType/ upon which the distribution operates.]]
481 [[DistributionType::policy_type][RealType]
482 [The __Policy to use when evaluating functions that depend on this distribution.]]
483 [[d = cd][Distribution&][Distribution types are assignable.]]
484 [[Distribution(cd)][Distribution][Distribution types are copy constructible.]]
485 [[pdf(cd, cr)][RealType][Returns the PDF of the distribution.]]
486 [[cdf(cd, cr)][RealType][Returns the CDF of the distribution.]]
487 [[cdf(complement(cd, cr))][RealType]
488 [Returns the complement of the CDF of the distribution,
489 the same as: `1-cdf(cd, cr)`]]
490 [[quantile(cd, cr)][RealType][Returns the quantile (or percentile) of the distribution.]]
491 [[quantile(complement(cd, cr))][RealType]
492 [Returns the quantile (or percentile) of the distribution, starting from
493 the complement of the probability, the same as: `quantile(cd, 1-cr)`]]
494 [[chf(cd, cr)][RealType][Returns the cumulative hazard function of the distribution.]]
495 [[hazard(cd, cr)][RealType][Returns the hazard function of the distribution.]]
496 [[kurtosis(cd)][RealType][Returns the kurtosis of the distribution.]]
497 [[kurtosis_excess(cd)][RealType][Returns the kurtosis excess of the distribution.]]
498 [[mean(cd)][RealType][Returns the mean of the distribution.]]
499 [[mode(cd)][RealType][Returns the mode of the distribution.]]
500 [[skewness(cd)][RealType][Returns the skewness of the distribution.]]
501 [[standard_deviation(cd)][RealType][Returns the standard deviation of the distribution.]]
502 [[variance(cd)][RealType][Returns the variance of the distribution.]]
505 [endsect] [/ section:dist_concept Conceptual Requirements for Distribution Types]
507 [section:archetypes Conceptual Archetypes for Reals and Distributions]
509 There are a few concept archetypes available:
511 * Real concept for floating-point types.
512 * Distribution concept for statistical distributions.
514 [h5:real_concept Real concept]
516 `std_real_concept` is an archetype for theReal types,
517 including the built-in float, double, long double.
519 ``#include <boost/concepts/std_real_concept.hpp>``
525 class std_real_concept;
530 The main purpose in providing this type is to verify
531 that standard library functions are found via a using declaration -
532 bringing those functions into the current scope -
533 and not just because they happen to be in global scope.
535 In order to ensure that a call to say `pow` can be found
536 either via argument dependent lookup, or failing that then
537 in the std namespace: all calls to standard library functions
538 are unqualified, with the std:: versions found via a `using` declaration
539 to make them visible in the current scope. Unfortunately it's all
540 to easy to forget the `using` declaration, and call the double version of
541 the function that happens to be in the global scope by mistake.
543 For example if the code calls ::pow rather than std::pow,
544 the code will cleanly compile, but truncation of long doubles to
545 double will cause a significant loss of precision.
546 In contrast a template instantiated with std_real_concept will *only*
547 compile if the all the standard library functions used have
548 been brought into the current scope with a using declaration.
550 [h6 Testing the real concept]
552 There is a test program
553 [@../../test/std_real_concept_check.cpp libs/math/test/std_real_concept_check.cpp]
554 that instantiates every template in this library with type
555 `std_real_concept` to verify its usage of standard library functions.
557 ``#include <boost/math/concepts/real_concept.hpp>``
567 `real_concept` is an archetype for
568 [link math_toolkit.real_concepts user defined real types],
569 it declares its standard library functions in its own
570 namespace: these will only be found if they are called unqualified
571 allowing argument dependent lookup to locate them. In addition
572 this type is useable at runtime:
573 this allows code that would not otherwise be exercised by the built-in
574 floating point types to be tested. There is no std::numeric_limits<>
575 support for this type, since numeric_limits is not a conceptual requirement
576 for [link math_toolkit.real_concepts RealType]s.
578 NTL RR is an example of a type meeting the requirements that this type
579 models, but note that use of a thin wrapper class is required: refer to
580 [link math_toolkit.high_precision.use_ntl "Using With NTL - a High-Precision Floating-Point Library"].
582 There is no specific test case for type `real_concept`, instead, since this
583 type is usable at runtime, each individual test case as well as testing
584 `float`, `double` and `long double`, also tests `real_concept`.
586 [h6:distribution_concept Distribution Concept]
588 Distribution Concept models statistical distributions.
590 ``#include <boost/math/concepts/distribution.hpp>``
596 template <class RealType>
597 class distribution_archetype;
599 template <class Distribution>
600 struct DistributionConcept;
604 The class template `distribution_archetype` is a model of the
605 [link math_toolkit.dist_concept Distribution concept].
607 The class template `DistributionConcept` is a
608 [@../../../../libs/concept_check/index.html concept checking class]
609 for distribution types.
611 [h6 Testing the distribution concept]
614 [@../../test/compile_test/distribution_concept_check.cpp distribution_concept_check.cpp]
615 is responsible for using `DistributionConcept` to verify that all the
616 distributions in this library conform to the
617 [link math_toolkit.dist_concept Distribution concept].
619 The class template `DistributionConcept` verifies the existence
620 (but not proper function) of the non-member accessors
621 required by the [link math_toolkit.dist_concept Distribution concept].
622 These are checked by calls like
624 v = pdf(dist, x); // (Result v is ignored).
626 And in addition, those that accept two arguments do the right thing when the
627 arguments are of different types (the result type is always the same as the
628 distribution's value_type). (This is implemented by some additional
629 forwarding-functions in derived_accessors.hpp, so that there is no need for
630 any code changes. Likewise boilerplate versions of the
631 hazard\/chf\/coefficient_of_variation functions are implemented in
634 [endsect] [/section:archetypes Conceptual Archetypes for Reals and Distributions]
636 Copyright 2006, 2010, 2012 John Maddock and Paul A. Bristow.
637 Distributed under the Boost Software License, Version 1.0.
638 (See accompanying file LICENSE_1_0.txt or copy at
639 http://www.boost.org/LICENSE_1_0.txt).