dpoly: add some documentation
[barvinok.git] / barvinok / NTL_QQ.h
blob6c75bc384ef0311ddcea056145157af99e4b581e
1 #ifndef NTL_QQ_H
2 #define NTL_QQ_H
4 #include <NTL/ZZ.h>
5 #include <NTL/vector.h>
7 #ifdef NTL_STD_CXX
8 using namespace NTL;
9 #endif
11 struct QQ {
12 ZZ n;
13 ZZ d;
15 QQ() {}
16 QQ(int n, int d) {
17 this->n = n;
18 this->d = d;
21 QQ& operator += (const QQ& a) {
22 ZZ g = GCD(d, a.d);
23 ZZ num = a.n * (d / g) + (a.d / g) * n;
24 ZZ den = a.d / g * d;
25 g = GCD(num, den);
26 n = num/g;
27 d = den/g;
28 return *this;
31 QQ& operator *= (const QQ& a) {
32 n *= a.n;
33 d *= a.d;
34 return *this;
37 QQ& operator *= (const ZZ& a) {
38 n *= a;
39 return *this;
43 NTL_vector_decl(QQ,vec_QQ);
45 vec_QQ& operator *= (vec_QQ& a, const ZZ& b);
47 std::ostream& operator<< (std::ostream& os, const QQ& q);
48 std::istream& operator>> (std::istream& os, QQ& q);
50 NTL_io_vector_decl(QQ,vec_QQ);
52 #endif