gen_fun::Hadamard_product: don't assume equalities are independent
[barvinok.git] / barvinok / NTL_QQ.h
blobcb4be94611f38b12e0387d91564379b3b3afb293
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;
20 QQ& operator += (const QQ& a) {
21 ZZ g = GCD(d, a.d);
22 ZZ num = a.n * (d / g) + (a.d / g) * n;
23 ZZ den = a.d / g * d;
24 g = GCD(num, den);
25 n = num/g;
26 d = den/g;
27 return *this;
30 QQ& operator *= (const QQ& a) {
31 n *= a.n;
32 d *= a.d;
33 return *this;
37 NTL_vector_decl(QQ,vec_QQ);
39 std::ostream& operator<< (std::ostream& os, const QQ& q);
40 std::istream& operator>> (std::istream& os, QQ& q);
42 NTL_io_vector_decl(QQ,vec_QQ);
44 #endif