X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Freal.h;h=8dea9533c1a2dccf43b8e46913f9a431898070af;hp=ab90384c69d118c21b56c247a9f4394ddd227b2f;hb=c64ec8fda6d6ad1bb5bdc5f2edd7d1d47c2d2680;hpb=33356addacfe4296ecb613c6c4696f082e351159 diff --git a/src/real.h b/src/real.h index ab90384..8dea953 100644 --- a/src/real.h +++ b/src/real.h @@ -9,6 +9,7 @@ #define REAL_LONG_DOUBLE 2 #define REAL_SINGLE_FAST2SUM 3 //TODO: Remove, is FITH #define REAL_RATIONAL 4 +#define REAL_RATIONAL_ARBINT 5 #ifndef REAL #error "REAL was not defined!" @@ -22,6 +23,11 @@ #include "rational.h" #endif //REAL +#if REAL == REAL_RATIONAL_ARBINT + #include "rational.h" + #include "arbint.h" +#endif //REAL + namespace IPDF { extern const char * g_real_name[]; @@ -37,10 +43,20 @@ namespace IPDF inline float Float(const Real & r) {return r.m_value;} inline double Double(const Real & r) {return r.m_value;} #elif REAL == REAL_RATIONAL - + typedef Rational Real; inline float Float(const Real & r) {return (float)r.ToDouble();} inline double Double(const Real & r) {return r.ToDouble();} +#elif REAL == REAL_RATIONAL_ARBINT + typedef Rational Real; + inline float Float(const Real & r) {return (float)r.ToDouble();} + inline double Double(const Real & r) {return r.ToDouble();} + inline Rational pow(const Rational & a, const Rational & b) + { + Arbint P(std::pow(static_cast(a.P), b.ToDouble())); + Arbint Q(std::pow(static_cast(a.Q), b.ToDouble())); + return Rational(P,Q); + } #else #error "Type of Real unspecified." #endif //REAL