MPFR++ is a C++ interface to
MPFR, a multiple precision
arithmetic library developed in C.
MPFR stands for Multiple Precision Floating-point Reliable library.
Documentation for MPFR++
the MpfrClass class
constructors
assignment and copy
consult or modify the rounding mode or
the computing precision
constants
arithmetic operations
mathematical functions
comparisons
Input-Output
functions related to the IEEE-754 standard for floating-point arithmetic
More on memory management
Download and use MPFR++
Documentation for MPFR++
MPFR++ includes:
- the MpfrClass class
which encapsulates the MPFR type;
-
constructors
from basic numerical types, GMP types (mpz, mpq), the mpfr type
and from a string;
-
assignment and copy :
the assignment = is a logical copy, use
copy for a physical copy; (for more on this topic,
cf.
memory management)
- functions for consultation or
modification of the rounding mode or the computing precision (global or
specific to a given object):
GetDefaultRndMode, SetDefaultRndMode, GetDefaultPrecision, GetPrecision,
SetDefaultPrecision, SetPrecision;
-
constants: Pi, Log2, Euler ;
-
arithmetic operations
where one of the operands can be an object of type MpfrClass,
a numerical object with a basic or GMP type:
+,
-,
*,
/,
+=,
-=,
*=,
/=.
Less common arithmetic operations are also available:
fma for fused multiply and accumulate performs with
only one rounding error the operation x*y+z,
abs returns the absolute value of its argument;
sqrt computes a square root,
cbrt computes a cubic root,
pow computes an integer power if its second argument is an integer,
pow cpmputes a general power if its argument is of type MpfrClass,
hypot computes the hypotenuse of x and y,
i.e. the square root of the sum of the squares of x and y,
factorial computes the factorial of an integer;
-
correctly rounded mathematical functions :
random returns a random value,
agm determines the arithmetico-geometric mean of two numbers,
exp stands for the exponential,
exp2 for a power of 2 (not necessarily integer),
expm1 for the exponential of x minus 1,
log for the natural logarithm,
log2 for the radix-2 logarithm,
log10 for the radix-10 logarithm,
log1p for the logarithm of (1+x),
sin for the sine,
cos for the cosine,
tan for the tangent,
asin for the arg-sine,
acos for the arg-cosine,
atan for the arg-tangent,
sinh for the hyperbolic sine,
cosh for the hyperbolic cosine,
tanh for the hyperbolic tangent,
asinh for the hyperbolic arg-sine,
acosh for the hyperbolic arg-cosine,
atanh for the hyperbolic arg-tangent,
gamma for the Gamma function,
erf for the error function,
zeta for the Riemann Zeta function;
-
comparison operators : ==, !=, <, <=, >, >=, min, max ;
-
Input-Ouput : << and >> ;
-
functions related to the IEEE-754 standard for floating-point arithmetic:
rounding according to the four rounding modes prescribed in the standard:
round, floor, ceil, trunc
and the floating-point number immediately greater:
nextabove, smaller: nextbelow or following in a given direction:
nexttoward.
-
More on memory management:
to reduce the physical copies of objects, each object is equipped
with a reference counter. This counter contains the number of
objects which are logically different but share physically
the same value.
If an object with a reference counter equal to 1 must be modified,
it will be physically modified (through an assignment for instance).
If its reference counter is greater than 1, it cannot be physically
modified, since this would also modified the value of the other objects
referencing the same value; in this case, the object is duplicated before
being modified.
Download and use MPFR++
MPFR++,
the C++ interface for
MPFR, can be downloaded (format ``.tgz'',
last revision 27-02-2004).
Since MPFR++ is based on MPFR, which is itself built upon GMP,
you must firstly install
GMP version 4.0 or more recent and
MPFR
version 2.0 or more recent.
To use
MPFR++, include the mpfr++.H file in your programs and when
linking, do not forget mpfr++.o,
created from mpfr++.C.
Thank you for keeping me informed
of any problem you may encounter.
MPFR++ is developed by Nathalie
Revol.