Add missing include of isl/aff.h
[barvinok.git] / barvinok / NTL_QQ.h
blob0619c82ef3b3078ec5f982b52571a91c92a1d039
1 #ifndef NTL_QQ_H
2 #define NTL_QQ_H
4 #include <barvinok/NTL.h>
6 #ifdef NTL_STD_CXX
7 using namespace NTL;
8 #endif
10 struct QQ {
11 ZZ n;
12 ZZ d;
13 /* This is not thread-safe, but neither is NTL */
14 static ZZ tmp;
16 QQ() {}
17 QQ(int n, int d) {
18 this->n = n;
19 this->d = d;
22 QQ& canonicalize() {
23 GCD(tmp, n, d);
24 n /= tmp;
25 d /= tmp;
26 return *this;
29 QQ& operator += (const QQ& a) {
30 n *= a.d;
31 mul(tmp, d, a.n);
32 n += tmp;
33 d *= a.d;
34 return canonicalize();
37 QQ& operator *= (const QQ& a) {
38 n *= a.n;
39 d *= a.d;
40 return canonicalize();
43 QQ& operator *= (const ZZ& a) {
44 n *= a;
45 return *this;
49 #ifdef NTL_vector_decl
50 NTL_vector_decl(QQ,vec_QQ);
51 #else
52 typedef Vec<QQ> vec_QQ;
53 #endif
55 vec_QQ& operator *= (vec_QQ& a, const ZZ& b);
56 vec_QQ& operator *= (vec_QQ& a, const QQ& b);
58 std::ostream& operator<< (std::ostream& os, const QQ& q);
59 std::istream& operator>> (std::istream& os, QQ& q);
61 #ifdef NTL_io_vector_decl
62 NTL_io_vector_decl(QQ,vec_QQ);
63 #endif
65 #endif