MPFRCPP Extra Modules

Contents


1. Beta function [<mpfrcpp/extra/beta.hpp>]

Beta function could be defined as Beta (x,y) = Gamma(x)Gamma(y)/Gamma(x+y).

namespace mpfr {
    Real Beta (Real&, Real&) throw();
}

2. Complex Numbers [<mpfrcpp/extra/complex.hpp>]

Complex numbers implementation. Based on the GNU ISO C++ Library implementation by Gabriel Dos Reis. It's not a std::complex<T> specialization for T = mpfr::Real because of distinctions in different std::complex<T> implementations (actually, not all of them are ISO-conforming).

namespace mpfr {
    typedef class nacre::complex::Complex<Real> Complex;
    using namespace nacre::complex;
}

See the NACRE definitions.

3. FP-Comparator [<mpfrcpp/extra/fp_comparator.hpp>]

Comparison of two floating point numbers respecting to some epsilon, machine epsilon by default.

namespace mpfr {
    typedef class nacre::comparator::FpComparator<Real> FpComparator;
    using nacre::comparator;
}

See the NACRE definitions.

4. Polynomials [<mpfrcpp/extra/polynomial.hpp>]

General polynomial class, orthogonal polynomials (Chebyshev, Hermite, Laguerre, Legendre), polynomial roots (Muller method).

namespace mpfr {
    typedef class nacre::polynomial::Polynomial<Real> Polynomial;
    using namespace nacre::polynomial;
}

See the NACRE definitions.

5. Functors rounding to ±∞ [<mpfrcpp/extra/pminf.hpp>]

namespace mpfr {
    extern AbsClass AbsMInf;
    extern AbsClass AbsPInf;

    extern AcosClass AcosMInf;
    extern AcosClass AcosPInf;

    extern AcoshClass AcoshMInf;
    extern AcoshClass AcoshPInf;

    extern AgmClass AgmMInf;
    extern AgmClass AgmPInf;

    extern AsinhClass AsinhMInf;
    extern AsinhClass AsinhPInf;

    extern AtanClass AtanMInf;
    extern AtanClass AtanPInf;

    extern AtanhClass AtanhMInf;
    extern AtanhClass AtanhPInf;

    extern BesselJ0Class BesselJ0MInf;
    extern BesselJ0Class BesselJ0PInf;

    extern BesselJ1Class BesselJ1MInf;
    extern BesselJ1Class BesselJ1PInf;

    extern BesselJnClass BesselJnMInf;
    extern BesselJnClass BesselJnPInf;

    extern BesselY0Class BesselY0MInf;
    extern BesselY0Class BesselY0PInf;

    extern BesselY1Class BesselY1MInf;
    extern BesselY1Class BesselY1PInf;

    extern BesselYnClass BesselYnMInf;
    extern BesselYnClass BesselYnPInf;

    extern CbrtClass CbrtMInf;
    extern CbrtClass CbrtPInf;

    extern ConstantClass ConstantMInf;
    extern ConstantClass ConstantPInf;

    extern CosClass CosMInf;
    extern CosClass CosPInf;

    extern CoshClass CoshMInf;
    extern CoshClass CoshPInf;

    extern CotClass CotMInf;
    extern CotClass CotPInf;

    extern CothClass CothMInf;
    extern CothClass CothPInf;

    extern CscClass CscMInf;
    extern CscClass CscPInf;

    extern CschClass CschMInf;
    extern CschClass CschPInf;

    extern DivClass DivMInf;
    extern DivClass DivPInf;

    extern EintClass EintMInf;
    extern EintClass EintPInf;

    extern ErfClass ErfMInf;
    extern ErfClass ErfPInf;

    extern ErfcClass ErfcMInf;
    extern ErfcClass ErfcPInf;

    extern ExpClass ExpMInf;
    extern ExpClass ExpPInf;

    extern Exp10Class Exp10MInf;
    extern Exp10Class Exp10PInf;

    extern Exp2Class Exp2MInf;
    extern Exp2Class Exp2PInf;

    extern Expm1Class Expm1MInf;
    extern Expm1Class Expm1PInf;

    extern FactorialClass FactorialMInf;
    extern FactorialClass FactorialPInf;

    extern FmaClass FmaMInf;
    extern FmaClass FmaPInf;

    extern FmsClass FmaMInf;
    extern FmsClass FmaPInf;

    extern FracClass FracMInf;
    extern FracClass FracPInf;

    extern GammaClass GammaMInf;
    extern GammaClass GammaPInf;

    extern HypotClass HypotMInf;
    extern HypotClass HypotPInf;

    extern LngammaClass LngammaMInf;
    extern LngammaClass LngammaPInf;

    extern LogClass LogMInf;
    extern LogClass LogPInf;

    extern Log10Class Log10MInf;
    extern Log10Class Log10PInf;

    extern Log1pClass Log1pMInf;
    extern Log1pClass Log1pPInf;

    extern Log2Class Log2MInf;
    extern Log2Class Log2PInf;

    extern MulClass MulMInf;
    extern MulClass MulPInf;

    extern NegClass NegMInf;
    extern NegClass NegPInf;

    extern PowClass PowMInf;
    extern PowClass PowPInf;

    extern RemainderClass RemainderMInf;
    extern RemainderClass RemainderPInf;

    extern RootClass RootMInf;
    extern RootClass RootPInf;

    extern SecClass SecMInf;
    extern SecClass SecPInf;

    extern SechClass SechMInf;
    extern SechClass SechPInf;

    extern SinClass SinMInf;
    extern SinClass SinPInf;

    extern SinCosClass SinCosMInf;
    extern SinCosClass SinCosPInf;

    extern SinhClass SinhMInf;
    extern SinhClass SinhPInf;

    extern SqrClass SqrMInf;
    extern SqrClass SqrPInf;

    extern SqrtClass SqrtMInf;
    extern SqrtClass SqrtPInf;

    extern SubClass SubMInf;
    extern SubClass SubPInf;

    extern TanClass TanMInf;
    extern TanClass TanPInf;

    extern TanhClass TanhMInf;
    extern TanhClass TanhPInf;

    extern ZetaClass ZetaMInf;
    extern ZetaClass ZetaPInf;

    class ExtraNumericFunctions : public NumericFunctions;
    extern ExtraNumericFunctions ExtraFunctions;
}    // namespace mpfr

6. Simple Functions [<mpfrcpp/extra/simple_functions.hpp>]

Overloads the folowing functions: abs, acos, acosh, agm, asin, asinh, atan2, atan, atanh, cbrt, besselJ0, besselJ1, besselJn, besselY0, besselY1, besselYn, ceil, cos, cosh, cot, coth, csc, csch, eint, erf, erfc, exp10, exp2, exp, expm1, factorial, floor, fma, fms, frac, gamma, hypot, lngamma, log10, log1p, log2, log, pow, root, remainder, round, sec, sech, sin, sinh, sqr, sqrt, tan, tanh, trunc, zeta in the mpfrcpp namespace.

Could conflict with std_overloads.hpp, do not use with std_overloads.hpp.

namespace mpfr {
    Real abs (const Real&) throw();
    Real acos (const Real&) throw();
    Real acosh (const Real&) throw();
    Real agm (const Real&, const Real&) throw();
    Real asin (const Real&) throw();
    Real asinh (const Real&) throw();
    Real atan2 (const Real&, const Real&) throw();
    Real atan (const Real&) throw();
    Real atanh (const Real&) throw();
    Real besselJ0 (const Real&) throw();
    Real besselJ1 (const Real&) throw();
    Real besselJn (const Real&) throw();
    Real besselY0 (const Real&) throw();
    Real besselY1 (const Real&) throw();
    Real besselYn (const Real&) throw();
    Real cbrt (const Real&) throw();
    Real ceil (const Real&) throw();
    Real cos (const Real&) throw();
    Real cosh (const Real&) throw();
    Real cot (const Real&) throw();
    Real coth (const Real&) throw();
    Real csc (const Real&) throw();
    Real csch (const Real&) throw();
    Real eint (const Real&) throw();
    Real erf (const Real&) throw();
    Real erfc (const Real&) throw();
    Real exp10 (const Real&) throw();
    Real exp2 (const Real&) throw();
    Real exp (const Real&) throw();
    Real expm1 (const Real&) throw();
    Real factorial (unsigned int) throw();
    Real floor (const Real&) throw();
    Real fma (const Real&, const Real&, const Real&) throw();
    Real fms (const Real&, const Real&, const Real&) throw();
    Real frac (const Real&) throw();
    Real gamma (const Real&) throw();
    Real hypot (const Real&, const Real&) throw();
    Real lngamma (const Real&) throw();
    Real log10 (const Real&) throw();
    Real log1p (const Real&) throw();
    Real log2 (const Real&) throw();
    Real log (const Real&) throw();
    Real pow (const Real&, const Real&) throw();
    Real pow (const Real&, int&) throw();
    Real pow (const Real&, const mpz_t&) throw();
    Real pow (const Real&, const mpz_class&) throw();
    Real root (const Real&, unsigned int) throw();
    Real round (const Real&) throw();
    Real sec (const Real&) throw();
    Real sech (const Real&) throw();
    Real sin (const Real&) throw();
    Real sinh (const Real&) throw();
    Real sqr (const Real&) throw();
    Real sqrt (const Real&) throw();
    Real tan (const Real&) throw();
    Real tanh (const Real&) throw();
    Real trunc (const Real&) throw();
    Real zeta (const Real&) throw();
}     // namespace mpfr

7. Namespace std Function Overloads [<mpfrcpp/extra/std_overloads.hpp>]

Overloads the folowing functions: abs, acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, fmod, frexp, ldexp, log, log10, modf, pow, sin, sinh, sqrt, swap, tan, tanh in the std namespace.

Partial std::numeric_limits<Real> specification. Could conflict with simple_functions.hpp, do not use with simple_functions.hpp.

namespace std {
    void swap (mpfr::Real&, mpfr::Real&) throw();

    mpfr::Real abs (const mpfr::Real&) throw();
    mpfr::Real acos (const mpfr::Real&) throw();
    mpfr::Real asin (const mpfr::Real&) throw();
    mpfr::Real atan (const mpfr::Real&) throw();
    mpfr::Real atan2 (const mpfr::Real&, const mpfr::Real&);
    mpfr::Real ceil (const mpfr::Real&) throw();
    mpfr::Real cos (const mpfr::Real&) throw();
    mpfr::Real cosh (const mpfr::Real&) throw();
    mpfr::Real exp (const mpfr::Real&) throw();
    mpfr::Real fabs (const mpfr::Real&) throw();
    mpfr::Real floor (const mpfr::Real&) throw();
    mpfr::Real fmod (const mpfr::Real&, const mpfr::Real&) throw();
    mpfr::Real frexp (const mpfr::Real&, int*) throw();
    mpfr::Real ldexp (const mpfr::Real&, int) throw();
    mpfr::Real log (const mpfr::Real&) throw();
    mpfr::Real log10 (const mpfr::Real&) throw();
    mpfr::Real modf (const mpfr::Real&, mpfr::Real*) throw();
    mpfr::Real pow (const mpfr::Real&, const mpfr::Real&) throw();
    mpfr::Real pow (const mpfr::Real&, int&) throw();
    mpfr::Real sin (const mpfr::Real&) throw();
    mpfr::Real sinh (const mpfr::Real&) throw();
    mpfr::Real sqrt (const mpfr::Real&) throw();
    mpfr::Real tan (const mpfr::Real&) throw();
    mpfr::Real tanh (const mpfr::Real&) throw();
}    // namespace std

8. std::numeric_limits<mpfr::Real> [<mpfrcpp/extra/limits.hpp>]

namespace std {
    template<> class numeric_limits<mpfr::Real> {
    public:
        static const bool is_specialized = false; // FIXME
        static const int radix = 2;
        static const bool is_signed = true;
        static const bool is_integer = false;
        static const bool is_iec559 = true;
        static const bool has_infinity = true;
        static const bool has_quiet_NaN = true;
        static const bool is_bounded = true;
        static const bool is_modulo = false;
        static const bool is_exact = false;

        static mpfr::Real epsilon () throw();
        static mpfr::Real quiet_NaN() throw();
        static mpfr::Real signaling_NaN() throw();
        static mpfr::Real infinity() throw();
    };
}    // namespace std

numeric_limits<mpfr::Real>::is_specialized == false since the complete specification depends on type precision. Current code should be used to get epsilon / NaN / Infinity only.


9. boost::numeric::interval_lib specification for mpfrcpp::Real [<mpfrcpp/extra/boost_interval.hpp>]

See also http://www.boost.org/libs/numeric/interval/doc/interval.htm.

namespace boost {
namespace numeric {
namespace interval_lib {

template<> class rounded_math<mpfr::Real> {
public:
    // mathematical operations
    static mpfr::Real add_down (const mpfr::Real&, const mpfr::Real&);
    static mpfr::Real add_up (const mpfr::Real&, const mpfr::Real&);

    static mpfr::Real sub_down (const mpfr::Real&, const mpfr::Real&);
    static mpfr::Real sub_up (const mpfr::Real&, const mpfr::Real&);

    static mpfr::Real mul_down (const mpfr::Real&, const mpfr::Real&);
    static mpfr::Real mul_up (const mpfr::Real&, const mpfr::Real&);

    static mpfr::Real div_down (const mpfr::Real&, const mpfr::Real&);
    static mpfr::Real div_up (const mpfr::Real&, const mpfr::Real&);

    static mpfr::Real sqrt_down (const mpfr::Real&);
    static mpfr::Real sqrt_up (const mpfr::Real&);

    static mpfr::Real exp_down (const mpfr::Real&);
    static mpfr::Real exp_up (const mpfr::Real&);

    static mpfr::Real log_down (const mpfr::Real&);
    static mpfr::Real log_up (const mpfr::Real&);

    static mpfr::Real cos_down (const mpfr::Real&);
    static mpfr::Real cos_up (const mpfr::Real&);

    static mpfr::Real tan_down (const mpfr::Real&);
    static mpfr::Real tan_up (const mpfr::Real&);

    static mpfr::Real asin_down (const mpfr::Real&);
    static mpfr::Real asin_up (const mpfr::Real&);

    static mpfr::Real acos_down (const mpfr::Real&);
    static mpfr::Real acos_up (const mpfr::Real&);

    static mpfr::Real atan_down (const mpfr::Real&);
    static mpfr::Real atan_up (const mpfr::Real&);

    static mpfr::Real sinh_down (const mpfr::Real&);
    static mpfr::Real sinh_up (const mpfr::Real&);

    static mpfr::Real cosh_down (const mpfr::Real&);
    static mpfr::Real cosh_up (const mpfr::Real&);

    static mpfr::Real tanh_down (const mpfr::Real&);
    static mpfr::Real tanh_up (const mpfr::Real&);

    static mpfr::Real asinh_down (const mpfr::Real&);
    static mpfr::Real asinh_up (const mpfr::Real&);

    static mpfr::Real acosh_down (const mpfr::Real&);
    static mpfr::Real acosh_up (const mpfr::Real&);

    static mpfr::Real atanh_down (const mpfr::Real&);
    static mpfr::Real atanh_up (const mpfr::Real&);

    static mpfr::Real median(const mpfr::Real&, const mpfr::Real&);

    static mpfr::Real int_down (const mpfr::Real&);
    static mpfr::Real int_up (const mpfr::Real&);

    template<typename T> static mpfr::Real conv_down (const T&);
    template<typename T> static mpfr::Real conv_up  (const T&);

  // unprotected rounding class
  typedef rounded_math<mpfr::Real> unprotected_rounding;
};

template<> class checking_base<mpfr::Real> {
public:
    static mpfr::Real pos_inf();
    static mpfr::Real neg_inf();

    static mpfr::Real nan();
    static bool is_nan(const mpfr::Real&);

    static mpfr::Real empty_lower();
    static mpfr::Real empty_upper();

    static bool is_empty(const mpfr::Real&, const mpfr::Real&);
};

namespace user {
    inline bool is_zero(const mpfr::Real&);
    inline bool is_neg (const mpfr::Real&);
    inline bool is_pos (const mpfr::Real&);
}

namespace constants {
    template<> inline mpfr::Real pi_half_lower<mpfr::Real>();
    template<> inline mpfr::Real pi_half_upper<mpfr::Real>();
    template<> inline mpfr::Real pi_lower<mpfr::Real>();
    template<> inline mpfr::Real pi_upper<mpfr::Real>();
    template<> inline mpfr::Real pi_twice_lower<mpfr::Real>();
    template<> inline mpfr::Real pi_twice_upper<mpfr::Real>();
}

} // namespace interval_lib
} // namespace numeric
} // namespace boost