diff --git a/doc/html/boost_multiprecision/intro.html b/doc/html/boost_multiprecision/intro.html new file mode 100644 index 00000000..6a2d9aaf --- /dev/null +++ b/doc/html/boost_multiprecision/intro.html @@ -0,0 +1,476 @@ + + + +Introduction + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Introduction +

+

+ The Multiprecision library comes in two distinct parts: an expression-template-enabled + front end mp_number that handles + all the operator overloading, expression evaluation optimization, and code + reduction, and a selection of backends that implement the actual arithmetic + operations, and need conform only to the reduced interface requirements of + the front end. +

+

+ The library is often used by using one of the predfined typedefs: for example + if you wanted an arbitrary precision integer type using GMP as the underlying + implementation then you could use: +

+
#include <boost/multiprecision/gmp.hpp>  // Defines the wrappers around the GMP library's types
+
+boost::multiprecision::mpz_int myint;    // Arbitrary precision integer type.
+
+

+ Alternatively one can compose your own multiprecision type, by combining mp_number with one of the predefined backend + types. For example, suppose you wanted a 300 decimal digit floating point type + based on the MPFR library, in this case there's no predefined typedef with + that level of precision, so instead we compose our own: +

+
#include <boost/multiprecision/mpfr.hpp>  // Defines the Backend type that wraps MPFR
+
+namespace mp = boost::multiprecision;     // Reduce the typing a bit later...
+
+typedef mp::mp_number<mp::mpfr_float_backend<300> >  my_float;
+
+my_float a, b, c; // These variables have 300 decimal digits precision
+
+
+ + Expression + Templates +
+

+ Class mp_number is expression-template-enabled: + that means that rather than having a multiplication operator that looks like + this: +

+
template <class Backend>
+mp_number<Backend> operator * (const mp_number<Backend>& a, const mp_number<Backend>& b)
+{
+   mp_number<Backend> result(a);
+   result *= b;
+   return result;
+}
+
+

+ Instead the operator looks more like this: +

+
template <class Backend>
+unmentionable-type operator * (const mp_number<Backend>& a, const mp_number<Backend>& b);
+
+

+ Where the "unmentionable" return type is an implementation detail + that, rather than containing the result of the multiplication, contains instructions + on how to compute the result. In effect it's just a pair of references to the + arguments of the function, plus some compile-time information that stores what + the operation is. +

+

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

+
T a[7] = { /* some values */ };
+//....
+y = (((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0];
+
+

+ If type T is an mp_number, then this expression is evaluated + without creating a single temporary value, in contrast + if we were using the C++ wrapper that ships with GMP - mpf_class + - then this expression would result in no less than 11 temporaries (this is + true even though mpf_class does use expression templates to reduce the number + of temporaries somewhat). Had we used an even simpler wrapper around GMP or + MPFR like mpclass things would + have been even worse and no less that 24 temporaries are created for this simple + expression (note - we actually measure the number of memory allocations performed + rather than the number of temporaries directly). +

+

+ This library also extends expression template support to standard library functions + like abs or sin + with mp_number arguments. This + means that an expression such as: +

+
y = abs(x);
+
+

+ can be evaluated without a single temporary being calculated. Even expressions + like: +

+
y = sin(x);
+
+

+ get this treatment, so that variable 'y' is used as "working storage" + within the implementation of sin, + thus reducing the number of temporaries used by one. Of course, should you + write: +

+
x = sin(x);
+
+

+ Then we clearly can't use x + as working storage during the calculation, so then a temporary variable is + created in this case. +

+

+ Given the comments above, you might be forgiven for thinking that expression-templates + are some kind of universal-panacea: sadly though, all tricks like this have + their downsides. For one thing, expression template libraries like this one, + tend to be slower to compile than their simpler cousins, they're also harder + to debug (should you actually want to step through our code!), and rely on + compiler optimizations being turned on to give really good performance. Also + since the return type from expressions involving mp_number's + is an "unmentionable implementation detail", you have to be careful + to cast the result of an expression to the actual number type when passing + an expression to a template function. For example given: +

+
template <class T>
+void my_proc(const T&);
+
+

+ Then calling: +

+
my_proc(a+b);
+
+

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

+
my_proc(my_mp_number_type(a+b));
+
+

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

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

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

+

+ One other potential pitfall that's only possible in C++11: you should never + store an expression template using: +

+
auto my_expression = a + b - c;
+
+

+ Unless you're absolutely sure that the lifetimes of a, + b and c + will outlive that of my_expression. +

+

+ And finally.... the performance improvements from an expression template library + like this are often not as dramatic as the reduction in number of temporaries + would suggest. For example if we compare this library with mpfr_class + and mpreal, with all three + using the underlying MPFR library at 50 decimal digits precision then we see + the following typical results for polynomial execution: +

+
+

Table 1.1. Evaluation of Order 6 Polynomial.

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +
+

+ Library +

+
+

+ Relative Time +

+
+

+ Relative number of memory allocations +

+
+

+ mp_number +

+
+

+ 1.0 (0.00793s) +

+
+

+ 1.0 (2996 total) +

+
+

+ mpfr_class +

+
+

+ 1.2 (0.00931s) +

+
+

+ 4.3 (12976 total) +

+
+

+ mpreal +

+
+

+ 1.9 (0.0148s) +

+
+

+ 9.3 (27947 total) +

+
+
+

+ As you can see the execution time increases a lot more slowly than the number + of memory allocations. There are a number of reasons for this: +

+
+

+ We'll conclude this section by providing some more performance comparisons + between these three libraries, again, all are using MPFR to carry out the underlying + arithmetic, and all are operating at the same precision (50 decimal places): +

+
+

Table 1.2. Evaluation of Boost.Math's Bessel function test data

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +
+

+ Library +

+
+

+ Relative Time +

+
+

+ Relative Number of Memory Allocations +

+
+

+ mp_number +

+
+

+ 1.0 (6.21s) +

+
+

+ 1.0 (2685469) +

+
+

+ mpfr_class +

+
+

+ 1.04 (6.45s) +

+
+

+ 1.47 (3946007) +

+
+

+ mpreal +

+
+

+ 1.53 (9.52s) +

+
+

+ 4.92 (13222940) +

+
+
+
+

Table 1.3. Evaluation of Boost.Math's Non-Central T distribution test data

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +
+

+ Library +

+
+

+ Relative Time +

+
+

+ Relative Number of Memory Allocations +

+
+

+ mp_number +

+
+

+ 1.0 (269s) +

+
+

+ 1.0 (139082551) +

+
+

+ mpfr_class +

+
+

+ 1.04 (278s) +

+
+

+ 1.81 (252400791) +

+
+

+ mpreal +

+
+

+ 1.49 (401s) +

+
+

+ 3.22 (447009280) +

+
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/ref.html b/doc/html/boost_multiprecision/ref.html new file mode 100644 index 00000000..5bff5c01 --- /dev/null +++ b/doc/html/boost_multiprecision/ref.html @@ -0,0 +1,40 @@ + + + +Reference + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Reference +

+
+
mp_number
+
Backend Requirements
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/ref/backendconc.html b/doc/html/boost_multiprecision/ref/backendconc.html new file mode 100644 index 00000000..a15e98a4 --- /dev/null +++ b/doc/html/boost_multiprecision/ref/backendconc.html @@ -0,0 +1,2024 @@ + + + +Backend Requirements + + + + + + + +
+
+
+PrevUpHome +
+
+

+Backend Requirements +

+

+ The requirements on the Backend + template argument to mp_number + are split up into compulsary requirements, and optional requirements that + are either to improve performance or provide optional features. +

+

+ In the following tables, type B is the Backend + template arument to mp_number, + b is a variable of B, cb and cb2 + are constant variables of type B, a + is a variable of Arithmetic type, s + is a variable of type const char*, ui is a variable of type unsigned, bb + is a variable of type bool, + pa is a variable of type + pointer-to-arithmetc-type, exp + is a variable of type B::exp_type, pexp + is a variable of type B::exp_type*. +

+
+

Table 1.4. Compulsary Requirements on the Backend type.

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Return Type +

+
+

+ Comments +

+
+

+ B::signed_types +

+
+

+ mpl::list<type-list> +

+
+

+ A list of signed integral types that can be assigned to type B. + The types shall be listed in order of size, smallest first, and + shall terminate in the type that is std::intmax_t. +

+
+

+ B::unsigned_types +

+
+

+ mpl::list<type-list> +

+
+

+ A list of unsigned integral types that can be assigned to type + B. The types shall be listed in order of size, smallest first, + and shall terminate in the type that is std::uintmax_t. +

+
+

+ B::real_types +

+
+

+ mpl::list<type-list> +

+
+

+ A list of floating point types that can be assigned to type B.The + types shall be listed in order of size, smallest first, and shall + terminate in type long double. +

+
+

+ B::exponent_type +

+
+

+ A signed integral type. +

+
+

+ The type of the exponent of type B. +

+
+

+ B() +

+
+ +

+ Default constructor. +

+
+

+ B(cb) +

+
+ +

+ Copy Constructor. +

+
+

+ b = + b +

+
+

+ B& +

+
+

+ Assignment operator. +

+
+

+ b = + a +

+
+

+ B& +

+
+

+ Assignment from an Arithmetic type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ b = + s +

+
+

+ B& +

+
+

+ Assignment from a string. +

+
+

+ b.swap(b) +

+
+

+ void +

+
+

+ Swaps the contents of it's arguments. +

+
+

+ cb.str(ui, + bb) +

+
+

+ std::string +

+
+

+ Returns the string representation of b + with ui digits + and in scientific format if bb + is true. If ui is zero, then returns as many + digits as are required to reconstruct the original value. +

+
+

+ b.negate() +

+
+

+ void +

+
+

+ Negates b. +

+
+

+ cb.compare(cb2) +

+
+

+ int +

+
+

+ Compares cb and + cb2, returns a + value less than zero if cb + < cb2, + a value greater than zero if cb + > cb2 + and zero if cb == cb2. +

+
+

+ cb.compare(a) +

+
+

+ int +

+
+

+ Compares cb and + a, returns a value + less than zero if cb + < a, + a value greater than zero if cb + > a + and zero if cb == a. + The type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ add(b, + cb) +

+
+

+ void +

+
+

+ Adds cb to b. +

+
+

+ subtract(b, + cb) +

+
+

+ void +

+
+

+ Subtracts cb from + b. +

+
+

+ multiply(b, + cb) +

+
+

+ void +

+
+

+ Multiplies b by + cb. +

+
+

+ divide(b, + cb) +

+
+

+ void +

+
+

+ Divides b by cb. +

+
+

+ modulus(b, + cb) +

+
+

+ void +

+
+

+ Computes b %= + cb, only required when + B is an integer + type. +

+
+

+ bitwise_and(b, + cb) +

+
+

+ void +

+
+

+ Computes b &= + cb, only required when + B is an integer + type. +

+
+

+ bitwise_or(b, + cb) +

+
+

+ void +

+
+

+ Computes b |= + cb, only required when + B is an integer + type. +

+
+

+ bitwise_xor(b, + cb) +

+
+

+ void +

+
+

+ Computes b ^= + cb, only required when + B is an integer + type. +

+
+

+ complement(b, + cb) +

+
+

+ void +

+
+

+ Computes the ones-complement of cb + and stores the result in b, + only required when B + is an integer type. +

+
+

+ left_shift(b, + ui) +

+
+

+ void +

+
+

+ Computes b <<= + ui, only required when + B is an integer + type. +

+
+

+ right_shift(b, + ui) +

+
+

+ void +

+
+

+ Computes b >>= + ui, only required when + B is an integer + type. +

+
+

+ convert_to(pa, + cb) +

+
+

+ void +

+
+

+ Converts cb to + the type of *pa + and store the result in *pa. Type B + shall support conversion to at least types std::intmax_t, + std::uintmax_t and long + long. Conversion to other + arithmetic types can then be synthesised using other operations. + Conversions to other types are entirely optional. +

+
+

+ eval_frexp(b, + cb, + pexp) +

+
+

+ void +

+
+

+ Stores values in b + and *pexp + such that the value of cb + is b * 2*pexp, only required when B + is a floating point type. +

+
+

+ eval_ldexp(b, + cb, + exp) +

+
+

+ void +

+
+

+ Stores a value in b + that is cb * 2exp, only required when B + is a floating point type. +

+
+

+ eval_floor(b, + cb) +

+
+

+ void +

+
+

+ Stores the floor of cb + in b, only required + when B is a floating + point type. +

+
+

+ eval_ceil(b, + cb) +

+
+

+ void +

+
+

+ Stores the ceiling of cb + in b, only required + when B is a floating + point type. +

+
+

+ eval_sqrt(b, + cb) +

+
+

+ void +

+
+

+ Stores the square root of cb + in b, only required + when B is a floating + point type. +

+
+
+
+

Table 1.5. Optional Requirements on the Backend Type

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Expression +

+
+

+ Returns +

+
+

+ Comments +

+
+

+ add(b, + a) +

+
+

+ void +

+
+

+ Adds a to b. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::real_types. +

+
+

+ subtract(b, + a) +

+
+

+ void +

+
+

+ Subtracts a from + b. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ multiply(b, + a) +

+
+

+ void +

+
+

+ Multiplies b by + a. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ divide(b, + a) +

+
+

+ void +

+
+

+ Divides b by a. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::real_types. +

+
+

+ modulus(b, + a) +

+
+

+ void +

+
+

+ Computes b %= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_and(b, + a) +

+
+

+ void +

+
+

+ Computes b &= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_or(b, + a) +

+
+

+ void +

+
+

+ Computes b |= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_xor(b, + a) +

+
+

+ void +

+
+

+ Computes b ^= + cb, only required when + B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ add(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Add cb to cb2 and stores the result in + b. +

+
+

+ subtract(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Subtracts cb2 from + cb and stores the + result in b. +

+
+

+ multiply(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Multiplies cb by + cb2 and stores + the result in b. +

+
+

+ divide(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Divides cb by + cb2 and stores + the result in b. +

+
+

+ add(b, + cb, + a) +

+
+

+ void +

+
+

+ Add cb to a and stores the result in b. The type of a shall be listed in one of the + type lists B::signed_types, B::unsigned_types + or B::real_types. +

+
+

+ subtract(b, + cb, + a) +

+
+

+ void +

+
+

+ Subtracts a from + cb and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ multiply(b, + cb, + a) +

+
+

+ void +

+
+

+ Multiplies cb by + a and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ divide(b, + cb, + a) +

+
+

+ void +

+
+

+ Divides cb by + a and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ modulus(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Computes cb % + cb2 and stores the result + in b, only required + when B is an integer + type. +

+
+

+ bitwise_and(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Computes cb & + cb2 and stores the result + in b, only required + when B is an integer + type. +

+
+

+ bitwise_or(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Computes cb | + cb2 and stores the result + in b, only required + when B is an integer + type. +

+
+

+ bitwise_xor(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Computes cb ^ + cb2 and stores the result + in b, only required + when B is an integer + type. +

+
+

+ add(b, + a, + cb) +

+
+

+ void +

+
+

+ Add a to cb and stores the result in + b. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ subtract(b, + a, + cb) +

+
+

+ void +

+
+

+ Subtracts cb from + a and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ multiply(b, + a, + cb) +

+
+

+ void +

+
+

+ Multiplies a by + cb and stores the + result in b. The + type of a shall + be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ divide(b, + a, + cb) +

+
+

+ void +

+
+

+ Divides a by cb and stores the result in + b. The type of + a shall be listed + in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ modulus(b, + cb, + a) +

+
+

+ void +

+
+

+ Computes cb % + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_and(b, + cb, + a) +

+
+

+ void +

+
+

+ Computes cb & + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_or(b, + cb, + a) +

+
+

+ void +

+
+

+ Computes cb | + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_xor(b, + cb, + a) +

+
+

+ void +

+
+

+ Computes cb ^ + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ modulus(b, + a, + cb) +

+
+

+ void +

+
+

+ Computes cb % + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_and(b, + a, + cb) +

+
+

+ void +

+
+

+ Computes cb & + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_or(b, + a, + cb) +

+
+

+ void +

+
+

+ Computes cb | + a and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ bitwise_xor(b, + a, + cb) +

+
+

+ void +

+
+

+ Computes a ^ + cb and stores the result + in b, only required + when B is an integer + type. The type of a + shall be listed in one of the type lists B::signed_types, + B::unsigned_types or B::real_types. +

+
+

+ left_shift(b, + cb, + ui) +

+
+

+ void +

+
+

+ Computes cb << + ui and stores the result + in b, only required + when B is an integer + type. +

+
+

+ right_shift(b, + cb, + ui) +

+
+

+ void +

+
+

+ Computes cb >> + ui and stores the result + in b, only required + when B is an integer + type. +

+
+

+ increment(b) +

+
+

+ void +

+
+

+ Increments the value of b + by one. +

+
+

+ decrement(b) +

+
+

+ void +

+
+

+ Decrements the value of b + by one. +

+
+

+ is_zero(cb) +

+
+

+ bool +

+
+

+ Returns true if cb is zero, otherwise false +

+
+

+ get_sign(cb) +

+
+

+ int +

+
+

+ Returns a value < zero if cb + is negative, a value > zero if cb + is positive, and zero if cb + is zero. +

+
+

+ eval_abs(b, + cb) +

+
+

+ void +

+
+

+ Set b to the absolute + value of cb. +

+
+

+ eval_fabs(b, + cb) +

+
+

+ void +

+
+

+ Set b to the absolute + value of cb. +

+
+

+ eval_fpclassify(cb) +

+
+

+ int +

+
+

+ Returns one of the same values returned by std::fpclassify. + Only required when B + is an floating point type. +

+
+

+ eval_trunc(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::trunc + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_round(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::round + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_exp(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::exp + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_log(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::log + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_log10(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::log10 + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_sin(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::sin + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_cos(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::cos + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_tan(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::exp + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_asin(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::asin + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_acos(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::acos + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_atan(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::atan + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_sinh(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::sinh + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_cosh(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::cosh + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_tanh(b, + cb) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::tanh + on argument cb + and stores the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_fmod(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::fmod + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_pow(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::pow + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating point type. +

+
+

+ eval_atan2(b, + cb, + cb2) +

+
+

+ void +

+
+

+ Performs the equivalent operation to std::atan + on arguments cb + and cb2, and store + the result in b. + Only required when B + is an floating point type. +

+
+
+
+
+ + + +
+
+
+PrevUpHome +
+ + diff --git a/doc/html/boost_multiprecision/ref/mp_number.html b/doc/html/boost_multiprecision/ref/mp_number.html new file mode 100644 index 00000000..613feeaa --- /dev/null +++ b/doc/html/boost_multiprecision/ref/mp_number.html @@ -0,0 +1,411 @@ + + + +mp_number + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+mp_number +

+
+ + Synopsis +
+
namespace boost{ namespace multiprecision{
+
+template <class Backend>
+class mp_number
+{
+   mp_number();
+   mp_number(see-below);
+   mp_number& operator=(see-below);
+
+   /* Other number-type operators here */
+
+   // Use in Boolean context:
+   operator convertible-to-bool-type()const;
+   // swap:
+   void swap(mp_number& other);
+   // Sign:
+   bool is_zero()const;
+   int sign()const;
+   // string conversion:
+   std::string str()const;
+   // Generic conversion mechanism
+   template <class T>
+   T convert_to()const;
+   // precision control:
+   static unsigned default_precision();
+   static void default_precision(unsigned digits10);
+   unsigned precision()const;
+   void precision(unsigned digits10);
+   // Comparison:
+   int compare(const mp_number<Backend>& o)const;
+   template <class V>
+   typename enable_if<is_arithmetic<V>, int>::type compare(const V& o)const;
+   // Access to the underlying implementation:
+   Backend& backend();
+   const Backend& backend()const;
+};
+
+// Swap:
+template <class Backend>
+void swap(mp_number<Backend>& a, mp_number<Backend>& b);
+
+// iostream support:
+template <class Backend>
+std::ostream& operator << (std::ostream& os, const mp_number<Backend>& r);
+std::ostream& operator << (std::ostream& os, const unmentionable-expression-template-type& r);
+template <class Backend>
+std::istream& operator >> (std::istream& is, mp_number<Backend>& r);
+
+// Non-member function standard library support:
+unmentionable-expression-template-type    abs    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    fabs   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sqrt   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    floor  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    ceil   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    trunc  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    itrunc (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    ltrunc (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    lltrunc(const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    round  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    iround (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    lround (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    llround(const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    exp    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    log    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    log10    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    cos    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sin    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    tan    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    acos   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    asin   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    atan   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    cosh   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sinh   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    tanh   (const mp_number-or-expression-template-type&);
+
+unmentionable-expression-template-type    ldexp (const mp_number-or-expression-template-type&, int);
+unmentionable-expression-template-type    frexp (const mp_number-or-expression-template-type&, int*);
+unmentionable-expression-template-type    pow   (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    fmod  (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    atan2 (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+
+}} // namespaces
+
+namespace boost{ namespace math{
+
+// Boost.Math interoperability functions:
+int                                              fpclassify     (const mp_number-or-expression-template-type&, int);
+bool                                             isfinite       (const mp_number-or-expression-template-type&, int);
+bool                                             isnan          (const mp_number-or-expression-template-type&, int);
+bool                                             isinf          (const mp_number-or-expression-template-type&, int);
+bool                                             isnormal       (const mp_number-or-expression-template-type&, int);
+
+}} // namespaces
+
+// numeric_limits support:
+namespace std{
+
+template <class Backend>
+struct numeric_limits<boost::multiprecision<Backend> >
+{
+   /* Usual members here */
+};
+
+}
+
+
+ + Description +
+
mp_number();
+mp_number(see-below);
+mp_number& operator=(see-below);
+
+

+ Type mp_number is default + constructible, and both copy constructible and assignable from: +

+
+
/* Other number-type operators here */
+
+

+ The following arithmetic operations are support for real-numbered types: +

+
+

+ For integer types the following operators are also supported: +

+

+ Binary %, %, |, |, &, &, ^, ^, + <<, <<, >>, >>. +

+

+ Note that with the exception of the logical operators and unary + the result + of applying an operator to mp_number is an "unmentionable" expression + template type. +

+

+ Binary operators, must have at least one argument that is of type mp_number or an expression template derived + from mp_number. One argument + may optionally be of arithmetic type. +

+

+ Note that type mp_number + (and all expression templates derived from it) may be used in a Boolian context. +

+
operator convertible-to-bool-type()const;
+
+

+ Returns an unmentionable-type that is usable in Boolean + contexts (this allows mp_number + to be used in any Boolean context - if statements, conditional statements, + or as an argument to a logical operator - without type mp_number + being convertible to type bool. +

+
void swap(mp_number& other);
+
+

+ Swaps *this + with other. +

+
bool is_zero()const;
+
+

+ Returns true is *this is zero, + otherwise false. +

+
int sign()const;
+
+

+ Returns a value less than zero if *this is negative, a value greater than zero + if *this + is positive, and zero if *this + is zero. +

+
std::string str(unsigned precision, bool scientific = true)const;
+
+

+ Returns the number formatted as a string, with at least precision + digits, and in scientific format if scientific is true. +

+
template <class T>
+T convert_to()const;
+
+

+ Provides a generic conversion mechanism to convert *this to type T. + Type T may be any arithmetic + type. Optionally other types may also be supported by specific Backend types. +

+
static unsigned default_precision();
+static void default_precision(unsigned digits10);
+unsigned precision()const;
+void precision(unsigned digits10);
+
+

+ These functions are only available if the Backend template parameter supports + runtime changes to precision. They get and set the default precision and + the precision of *this + respectively. +

+
int compare(const mp_number<Backend>& o)const;
+template <class V>
+typename enable_if<is_arithmetic<V>, int>::type compare(const V& other)const;
+
+

+ Returns: +

+
+
Backend& backend();
+const Backend& backend()const;
+
+

+ Returns the underlying backend instance used by *this. +

+
+ + swap +
+
template <class Backend>
+void swap(mp_number<Backend>& a, mp_number<Backend>& b);
+
+

+ Swaps a and b. +

+
+ + Iostream + Support +
+
template <class Backend>
+std::ostream& operator << (std::ostream& os, const mp_number<Backend>& r);
+template <class Backend>
+std::ostream& operator << (std::ostream& os, const unmentionable-expression-template& r);
+template <class Backend>
+inline std::istream& operator >> (std::istream& is, mp_number<Backend>& r)
+
+

+ These operators provided formatted input-output operations on mp_number types, and expression templates + derived from them. +

+
+ + Non-member + standard library function support +
+
unmentionable-expression-template-type    abs    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    fabs   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sqrt   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    floor  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    ceil   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    trunc  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    itrunc (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    ltrunc (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    lltrunc(const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    round  (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    iround (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    lround (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    llround(const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    exp    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    log    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    log10    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    cos    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sin    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    tan    (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    acos   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    asin   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    atan   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    cosh   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    sinh   (const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    tanh   (const mp_number-or-expression-template-type&);
+
+unmentionable-expression-template-type    ldexp (const mp_number-or-expression-template-type&, int);
+unmentionable-expression-template-type    frexp (const mp_number-or-expression-template-type&, int*);
+unmentionable-expression-template-type    pow   (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    fmod  (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+unmentionable-expression-template-type    atan2 (const mp_number-or-expression-template-type&, const mp_number-or-expression-template-type&);
+
+

+ These functions all behave exactly as their standard library counterparts + do: their argument is either an instance of mp_number + or an expression template derived from it; their return value is always an + expression template. +

+

+ These functions are normally implemented by the Backend type. However, default + versions are provided for Backend types that don't have native support for + these functions. Please note however, that this default support requires + the precision of the type to be a compile time constant - this means for + example that the GMP MPF Backend will not work with these functions when + that type is used at variable precision. +

+

+ Also note that with the exception of abs + that these functions can only be used with floating point Backend types. +

+
+ + Boost.Math + Interoperabilty Support +
+
namespace boost{ namespace math{
+
+int                                              fpclassify     (const mp_number-or-expression-template-type&, int);
+bool                                             isfinite       (const mp_number-or-expression-template-type&, int);
+bool                                             isnan          (const mp_number-or-expression-template-type&, int);
+bool                                             isinf          (const mp_number-or-expression-template-type&, int);
+bool                                             isnormal       (const mp_number-or-expression-template-type&, int);
+
+}} // namespaces
+
+

+ These functions behave exacts as their Boost.Math equivalents. Other Boost.Math + functions and templates may also be specialized or overloaded to ensure interoperability. +

+
+ + std::numeric_limits + support +
+
namespace std{
+
+template <class Backend>
+struct numeric_limits<boost::multiprecision<Backend> >
+{
+   /* Usual members here */
+};
+
+}
+
+

+ Class template std::numeric_limits is specialized for all instantiations + of mp_number whose precision + is known at compile time, plus those types whose precision is unlimited (though + it is much less useful in those cases). It is not specialized for types whose + precision can vary at compile time (such as mpf_float). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/tut.html b/doc/html/boost_multiprecision/tut.html new file mode 100644 index 00000000..d6d8a0bb --- /dev/null +++ b/doc/html/boost_multiprecision/tut.html @@ -0,0 +1,45 @@ + + + +Tutorial + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Tutorial +

+
+
Integer Types
+
Real Numbers
+
Rational Number Types
+
+

+ In order to use this library you need to make two choices: what kind of number + do I want, and which backend do I want to perform the actual arithmetic? +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/tut/ints.html b/doc/html/boost_multiprecision/tut/ints.html new file mode 100644 index 00000000..bccd2e4f --- /dev/null +++ b/doc/html/boost_multiprecision/tut/ints.html @@ -0,0 +1,177 @@ + + + +Integer Types + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Integer Types +

+

+ The following backends provide integer arithmetic: +

+
++++++++ + + + + + + + + + + + + + + + + +
+

+ Backend Type +

+
+

+ Header +

+
+

+ Radix +

+
+

+ Dependencies +

+
+

+ Pros +

+
+

+ Cons +

+
+

+ gmp_int +

+
+

+ boost/multiprecision/gmp.hpp +

+
+

+ 2 +

+
+

+ GMP +

+
+

+ Very fast and efficient backend. +

+
+

+ Dependency on GNU licenced GMP library. +

+
+
+ + gmp_int +
+
namespace boost{ namespace multiprecision{
+
+class gmp_int;
+
+typedef mp_number<gmp_int >         mpz_int;
+
+}} // namespaces
+
+

+ The gmp_int backend is used + via the typedef boost::multiprecision::mpz_int. It acts as a thin wrapper around + the GMP mpz_t to provide + an integer type that is a drop-in replacement for the native C++ integer + types, but with unlimited precision. +

+

+ As well as the usual conversions from arithmetic and string types, type + mpz_int is copy constructible + and asignable from: +

+
+

+ It's also possible to access the underlying mpz_t + via the data() member function of gmp_int. +

+
+ + Example: +
+

+ +

+
#include <boost/multiprecision/gmp.hpp>
+
+using namespace boost::multiprecision;
+
+mpz_int v = 1;
+
+// Do some arithmetic:
+for(unsigned i = 1; i <= 1000; ++i)
+   v *= i;
+
+std::cout << v << std::endl; // prints 1000!
+
+// Access the underlying representation:
+mpz_t z;
+mpz_init(z);
+mpz_set(z, v.backend().data());
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/tut/rational.html b/doc/html/boost_multiprecision/tut/rational.html new file mode 100644 index 00000000..4f5308d5 --- /dev/null +++ b/doc/html/boost_multiprecision/tut/rational.html @@ -0,0 +1,188 @@ + + + +Rational Number Types + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Rational Number Types +

+

+ The following backends provide rational number arithmetic: +

+
++++++++ + + + + + + + + + + + + + + + + +
+

+ Backend Type +

+
+

+ Header +

+
+

+ Radix +

+
+

+ Dependencies +

+
+

+ Pros +

+
+

+ Cons +

+
+

+ gmp_rational +

+
+

+ boost/multiprecision/gmp.hpp +

+
+

+ 2 +

+
+

+ GMP +

+
+

+ Very fast and efficient backend. +

+
+

+ Dependency on GNU licenced GMP library. +

+
+
+ + gmp_rational +
+
namespace boost{ namespace multiprecision{
+
+class gmp_rational;
+
+typedef mp_number<gmp_rational >         mpq_rational;
+
+}} // namespaces
+
+

+ The gmp_rational backend + is used via the typedef boost::multiprecision::mpq_rational. + It acts as a thin wrapper around the GMP mpq_t + to provide a rational number type that is a drop-in replacement for the native + C++ number types, but with unlimited precision. +

+

+ As well as the usual conversions from arithmetic and string types, instances + of mp_number<gmp_rational> + are copy constructible and assignable from: +

+
+

+ There are also non-member functions: +

+
mpz_int numerator(const mpq_rational&);
+mpz_int denominator(const mpq_rational&);
+
+

+ Which return the numerator and denominator of the number. +

+

+ It's also possible to access the underlying mpq_t + via the data() member function of mpq_rational. +

+
+ + Example: +
+

+ +

+
#include <boost/multiprecision/gmp.hpp>
+
+using namespace boost::multiprecision;
+
+mpq_rational v = 1;
+
+// Do some arithmetic:
+for(unsigned i = 1; i <= 1000; ++i)
+   v *= i;
+v /= 10;
+
+std::cout << v << std::endl; // prints 1000! / 10
+std::cout << numerator(v) << std::endl;
+std::cout << denominator(v) << std::endl;
+
+// Access the underlying data:
+mpq_t q;
+mpq_init(q);
+mpq_set(q, v.backend().data());
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_multiprecision/tut/reals.html b/doc/html/boost_multiprecision/tut/reals.html new file mode 100644 index 00000000..a5df3c35 --- /dev/null +++ b/doc/html/boost_multiprecision/tut/reals.html @@ -0,0 +1,420 @@ + + + +Real Numbers + + + + + + + + +
+
+
+PrevUpHomeNext +
+
+

+Real Numbers +

+

+ The following backends provide real number arithmetic: +

+
++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ Backend Type +

+
+

+ Header +

+
+

+ Radix +

+
+

+ Dependencies +

+
+

+ Pros +

+
+

+ Cons +

+
+

+ mpf_float<N> +

+
+

+ boost/multiprecision/gmp.hpp +

+
+

+ 2 +

+
+

+ GMP +

+
+

+ Very fast and efficient backend. +

+
+

+ Dependency on GNU licenced GMP library. +

+
+

+ mpfr_float<N> +

+
+

+ boost/multiprecision/mpfr.hpp +

+
+

+ 2 +

+
+

+ GMP and MPFR +

+
+

+ Very fast and efficient backend, with it's own standard library + implementation. +

+
+

+ Dependency on GNU licenced GMP and MPFR libraries. +

+
+

+ cpp_float<N> +

+
+

+ boost/multiprecision/cpp_float.hpp +

+
+

+ 10 +

+
+

+ None +

+
+

+ Header only, all C++ implementation. +

+
+

+ Approximately 2x slower than the MPFR or GMP libraries. +

+
+
+ + gmp_float +
+
namespace boost{ namespace multiprecision{
+
+template <unsigned Digits10>
+class gmp_float;
+
+typedef mp_number<gmp_float<50> >    mpf_float_50;
+typedef mp_number<gmp_float<100> >   mpf_float_100;
+typedef mp_number<gmp_float<500> >   mpf_float_500;
+typedef mp_number<gmp_float<1000> >  mpf_float_1000;
+typedef mp_number<gmp_float<0> >     mpf_float;
+
+}} // namespaces
+
+

+ The gmp_float backend is + used in conjunction with mp_number: + It acts as a thin wrapper around the GMP mpf_t + to provide an real-number type that is a drop-in replacement for the native + C++ floating-point types, but with much greater precision. +

+

+ Type gmp_float can be used + at fixed precision by specifying a non-zero Digits10 + template parameter, or at variable precision by setting the template argument + to zero. The typedefs mpf_float_50, mpf_float_100, mpf_float_500, mpf_float_1000 + provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision + respectively. The typedef mpf_float provides a variable precision type whose + precision can be controlled via the mp_number's + member functions. +

+
+ + + + + +
[Note]Note

+ This type only provides standard library and numeric_limits + support when the precision is fixed at compile time. +

+

+ As well as the usual conversions from arithmetic and string types, instances + of mp_number<mpf_float<N> > are copy constructible and assignable + from: +

+
+

+ It's also possible to access the underlying mpf_t + via the data() member function of gmp_float. +

+
+ + GMP example: +
+

+ +

+
#include <boost/multiprecision/gmp.hpp>
+
+using namespace boost::multiprecision;
+
+// Operations at variable precision and limited standard library support:
+mpf_float a = 2;
+mpf_float::default_precision(1000);
+std::cout << mpf_float::default_precision() << std::endl;
+std::cout << sqrt(a) << std::endl; // print root-2
+
+// Operations at fixed precision and full standard library support:
+mpf_float_100 b = 2;
+std::cout << std::numeric_limits<mpf_float_100>::digits << std::endl;
+std::cout << log(b) << std::endl; // print log(2)
+
+// Access the underlying representation:
+mpf_t f;
+mpf_init(f);
+mpf_set(f, a.backend().data());
+
+

+

+
+ + mpfr_float +
+
namespace boost{ namespace multiprecision{
+
+template <unsigned Digits10>
+class mpfr_float_backend;
+
+typedef mp_number<mpfr_float_backend<50> >    mpfr_float_50;
+typedef mp_number<mpfr_float_backend<100> >   mpfr_float_100;
+typedef mp_number<mpfr_float_backend<500> >   mpfr_float_500;
+typedef mp_number<mpfr_float_backend<1000> >  mpfr_float_1000;
+typedef mp_number<mpfr_float_backend<0> >     mpfr_float;
+
+}} // namespaces
+
+

+ The mpfr_float_backend type + is used in conjunction with mp_number: + It acts as a thin wrapper around the MPFR mpfr_t + to provide an real-number type that is a drop-in replacement for the native + C++ floating-point types, but with much greater precision. +

+

+ Type mpfr_float_backend can + be used at fixed precision by specifying a non-zero Digits10 + template parameter, or at variable precision by setting the template argument + to zero. The typedefs mpfr_float_50, mpfr_float_100, mpfr_float_500, mpfr_float_1000 + provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision + respectively. The typedef mpfr_float provides a variable precision type whose + precision can be controlled via the mp_number's + member functions. +

+
+ + + + + +
[Note]Note

+ This type only provides numeric_limits + support when the precision is fixed at compile time. +

+

+ As well as the usual conversions from arithmetic and string types, instances + of mp_number<mpfr_float_backend<N> > are copy constructible and assignable + from: +

+
+

+ It's also possible to access the underlying mpf_t + via the data() member function of gmp_float. +

+
+ + MPFR example: +
+

+ +

+
#include <boost/multiprecision/mpfr.hpp>
+
+using namespace boost::multiprecision;
+
+// Operations at variable precision and no numeric_limits support:
+mpfr_float a = 2;
+mpfr_float::default_precision(1000);
+std::cout << mpfr_float::default_precision() << std::endl;
+std::cout << sqrt(a) << std::endl; // print root-2
+
+// Operations at fixed precision and full numeric_limits support:
+mpfr_float_100 b = 2;
+std::cout << std::numeric_limits<mpfr_float_100>::digits << std::endl;
+std::cout << log(b) << std::endl; // print log(2)
+
+// Access the underlying data:
+mpfr_t r;
+mpfr_init(r);
+mpfr_set(r, b.backend().data(), GMP_RNDN);
+
+

+

+
+ + cpp_float +
+
namespace boost{ namespace multiprecision{
+
+template <unsigned Digits10>
+class cpp_float;
+
+typedef mp_number<cpp_float<50> > cpp_float_50;
+typedef mp_number<cpp_float<100> > cpp_float_100;
+
+}} // namespaces
+
+

+ The cpp_float backend is + used in conjunction with mp_number: + It acts as an entirely C++ (header only and dependency free) real-number + type that is a drop-in replacement for the native C++ floating-point types, + but with much greater precision. +

+

+ Type cpp_float can be used + at fixed precision by specifying a non-zero Digits10 + template parameter. The typedefs cpp_float_50 and cpp_float_100 provide arithmetic + types at 50 and 100 decimal digits precision respectively. +

+

+ There is full standard library and numeric_limits + support available for this type. +

+
+ + cpp_float + example: +
+

+ +

+
#include <boost/multiprecision/cpp_float.hpp>
+
+using namespace boost::multiprecision;
+
+// Operations at fixed precision and full numeric_limits support:
+cpp_float_100 b = 2;
+std::cout << std::numeric_limits<cpp_float_100>::digits << std::endl;
+std::cout << log(b) << std::endl; // print log(2)
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/index.html b/doc/html/index.html new file mode 100644 index 00000000..1b43772d --- /dev/null +++ b/doc/html/index.html @@ -0,0 +1,54 @@ + + + +Chapter 1. Boost.Multiprecision + + + + + + +
+
+
Next
+
+
+

+Chapter 1. Boost.Multiprecision

+

+various authors +

+
+
+

+ 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) +

+
+
+
+

Table of Contents

+
+
Introduction
+
Tutorial
+
+
Integer Types
+
Real Numbers
+
Rational Number Types
+
+
Reference
+
+
mp_number
+
Backend Requirements
+
+
+
+
+ + + +

Last revised: July 08, 2011 at 18:51:46 +0100

+
+
Next
+ + diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk index fdcd45e6..2e5e7b9e 100644 --- a/doc/multiprecision.qbk +++ b/doc/multiprecision.qbk @@ -20,7 +20,7 @@ [import ../example/gmp_snips.cpp] [import ../example/mpfr_snips.cpp] -[import ../example/mp_float_snips.cpp] +[import ../example/cpp_float_snips.cpp] [section:intro Introduction] @@ -233,7 +233,7 @@ The following backends provide real number arithmetic: [[Backend Type][Header][Radix][Dependencies][Pros][Cons]] [[`mpf_float`][boost/multiprecision/gmp.hpp][2][GMP][Very fast and efficient backend.][Dependency on GNU licenced GMP library.]] [[`mpfr_float`][boost/multiprecision/mpfr.hpp][2][GMP and MPFR][Very fast and efficient backend, with it's own standard library implementation.][Dependency on GNU licenced GMP and MPFR libraries.]] -[[`mp_float`][boost/multiprecision/mp_float.hpp][10][None][Header only, all C++ implementation.][Approximately 2x slower than the MPFR or GMP libraries.]] +[[`cpp_float`][boost/multiprecision/cpp_float.hpp][10][None][Header only, all C++ implementation.][Approximately 2x slower than the MPFR or GMP libraries.]] ] [h4 gmp_float] @@ -315,31 +315,31 @@ It's also possible to access the underlying `mpf_t` via the data() member functi [mpfr_eg] -[h4 mp_float] +[h4 cpp_float] namespace boost{ namespace multiprecision{ template - class mp_float; + class cpp_float; - typedef mp_number > mp_float_50; - typedef mp_number > mp_float_100; + typedef mp_number > cpp_float_50; + typedef mp_number > cpp_float_100; }} // namespaces -The `mp_float` backend is used in conjunction with `mp_number`: It acts as an entirely C++ (header only and dependency free) +The `cpp_float` backend is used in conjunction with `mp_number`: It acts as an entirely C++ (header only and dependency free) real-number type that is a drop-in replacement for the native C++ floating-point types, but with much greater precision. -Type `mp_float` can be used at fixed precision by specifying a non-zero `Digits10` template parameter. -The typedefs mp_float_50 and mp_float_100 provide arithmetic types at 50 and 100 decimal digits precision +Type `cpp_float` can be used at fixed precision by specifying a non-zero `Digits10` template parameter. +The typedefs cpp_float_50 and cpp_float_100 provide arithmetic types at 50 and 100 decimal digits precision respectively. There is full standard library and `numeric_limits` support available for this type. -[h5 mp_float example:] +[h5 cpp_float example:] -[mp_float_eg] +[cpp_float_eg] [endsect] @@ -548,7 +548,7 @@ Returns `true` is `*this` is zero, otherwise `false`. int sign()const; -Returns a value less than zero if `*this` is negative, a value greater than zero if `*this is positive, and zero +Returns a value less than zero if `*this` is negative, a value greater than zero if `*this` is positive, and zero if `*this` is zero. std::string str(unsigned precision, bool scientific = true)const; diff --git a/example/mp_float_snips.cpp b/example/cpp_float_snips.cpp similarity index 100% rename from example/mp_float_snips.cpp rename to example/cpp_float_snips.cpp