virtual ~Gmpint() {} //TODO: Do we need to delete m_op somehow?
- operator int64_t() {return mpz_get_si(m_op);}
- operator uint64_t() {return mpz_get_ui(m_op);}
- operator double() {return mpz_get_d(m_op);}
+ operator int64_t() const {return mpz_get_si(m_op);}
+ operator uint64_t() const {return mpz_get_ui(m_op);}
+ operator double() const {return mpz_get_d(m_op);}
std::string Str(int base = 10) const
{
//TODO: Make less hacky, if we care.
Gmpint operator-(const Gmpint & sub) const {Gmpint a(*this); a -= sub; return a;}
Gmpint operator*(const Gmpint & mul) const {Gmpint a(*this); a *= mul; return a;}
Gmpint operator/(const Gmpint & div) const {Gmpint a(*this); a /= div; return a;}
- Gmpint operator%(const Gmpint & div) const
- {Gmpint a(*this); mpz_mod(a.m_op, a.m_op, div.m_op); return a;}
+ Gmpint operator%(const Gmpint & div) const {Gmpint a(*this); mpz_mod(a.m_op, a.m_op, div.m_op); return a;}
Gmpint operator-() const {return (Gmpint(0L)-*this);}
//doc.Add(BEZIER, Rect(0.2+x-4.0, 0.2+y-4.0, 0.6,0.6), (x^y)%3);
}
}
- doc.Add(CIRCLE_FILLED, Rect(0.1,0.1,0.8,0.8), 0);
+ doc.Add(BEZIER, Rect(0.1,0.1,0.8,0.8), 0);
}
Debug("Start!");
Rect bounds(b[0],b[1],b[2],b[3]);
#include <cmath>
#include <cassert>
#include "arbint.h"
+#include "gmpint.h"
namespace IPDF
{
return abs(a);
}
template <> Arbint Tabs(const Arbint & a);
-
+template <> Gmpint Tabs(const Gmpint & a);
/* Recursive version of GCD
template <class T>
"Rational<int64_t>",
"Rational<Arbint>"
};
+
+ template <> Gmpint Tabs(const Gmpint & a)
+ {
+ return a.Abs();
+ }
}
#if REAL == REAL_RATIONAL_ARBINT
#include "rational.h"
#include "arbint.h"
+ #include "gmpint.h"
#endif //REAL
namespace IPDF
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<Arbint> Real;
+ #define ARBINT Gmpint // Set to Gmpint or Arbint here
+
+ typedef Rational<ARBINT> Real;
inline float Float(const Real & r) {return (float)r.ToDouble();}
inline double Double(const Real & r) {return r.ToDouble();}
- inline Rational<Arbint> pow(const Rational<Arbint> & a, const Rational<Arbint> & b)
+ inline Rational<ARBINT> pow(const Rational<ARBINT> & a, const Rational<ARBINT> & b)
{
- Arbint P(std::pow(static_cast<double>(a.P), b.ToDouble()));
- Arbint Q(std::pow(static_cast<double>(a.Q), b.ToDouble()));
- return Rational<Arbint>(P,Q);
+ ARBINT P(std::pow(static_cast<double>(a.P), b.ToDouble()));
+ ARBINT Q(std::pow(static_cast<double>(a.Q), b.ToDouble()));
+ return Rational<ARBINT>(P,Q);
}
#else
#error "Type of Real unspecified."
{
arb_a *= b;
gmp_a *= b;
-
- Debug("Arbint - %s", arb_a.Str().c_str());
- Debug("Gmpint - %s", gmp_a.Str().c_str());
+ }
+
+ for (unsigned j = 0; j < 5; ++j)
+ {
+ arb_a /= b;
+ gmp_a /= b;
}