Library was designed for professional computations. MPFRCPP uses functors (functions-objects) to allow user change parameters such as precision and round mode more efficiently. Functions are based on NumericFunction
class; NumericFunctions
is a special container for synchronous changing of parameters.
Yes, MPFR function syntax is common, but MPFR definitions are too complex and some MPFR items are macro.
MPFRCPP goes as a sources set only since almost every MPFRCPP function or method are declared as inline
. If you want to increase compilation time, use the pre-compiled headers feature.
Base
, Precision
, RoundMode
classes instead of primitive scalar types?If base, precision, round mode are simple integers differ by typedef
(as they are in MPFR, GMP and first versions of MPFRCPP), it's very hard to prevent potential errors with polymorphic methods and default parameters.
For example, is Real (100)
stays for number 100
or number with mantissa width of 100
?
You can do everything allowed by LGPL. Please, take time to share your patches with me — maybe it will be useful to include them in further versions.
Since MPFRCPP is a wrapper to MPFR and GMP, you need to link mpfr
and lgmp
libraries. In g++ you need to add references -lmpfr and -lgmp:
g++ foo.c -lmpfrcpp -lmpfr -lgmp
Your stack size limit may be too small. Increase it with the limit, unlimit or ulimit command, depending on your shell.
mpfrcpp::Real
with POD-type number.You should compare mpfrcpp::Real
with other types explicitly:
x > mpfrcpp::Real(y)
If you found this too strict, you can apply a quick hack. For example:
template<typename T> inline bool operator<
(const mpfrcpp::Real& x,const T& y) {
return x < mpfrcpp::Real(y);
}
We are decided not to include this hack in major distribution.
ComparisonWithNaNError
.Any comparison could throw the ComparisonWithNaNError
exception. NaN result for some computation on IEEE arithmetic is usual case, but if you are trying to compare NaN result with other number, it seems to be an error. ComparisonWithNaNError
should help you to catch unserved special cases.
I plan to start work on JMPFR, the Java Branch. Contact me, if you are interested.
We are using Herb Sutter's coding standard (with some specific modifications). For example:
FooBarBaz | functor object, i.e. object of class with operator() overloaded |
---|---|
FooBarBazClass | functor class, i.e. class with operator() overloaded |
fooBarBaz | function or class method |
FooBarBaz | class |
fooBarBaz_ | protected or private class field |
Do not mix up functions and functors. For example, Asin
is a functor calculating arc-sine and asin
is the function.
NACRE stands for Numeric Analysis / Computer REsearch. It is a small library containing classes Polynomial<T>
, Complex<T>
, Rational<T>
. Matrix<T>
will be added soon. These classes are portable but simple and they were not oriented on high-performance computations.
NACRE templates are common and they could be used with MPFRCPP.