2
2
#define FIELD_RATIONALS_H_INCLUDED
5
#include <cstdio> /* Always include cstdio before gmp.h.*/
6
#include <gmp.h> //remove?
8
11
class FieldRationalsImplementation : public FieldImplementation
10
13
FieldElementImplementation *zHomomorphismImplementation(int n);/* Creates FieldElementImplementation object with refcount1 */
29
33
IntegerVector primitiveVector(vector<FieldElement> const &v);
34
IntegerVector toIntegerVector(vector<FieldElement> const &v);// MUST HAVE INTEGER ENTRIES
35
int toInteger(FieldElement const &a);// MUST BE INTEGER
36
mpq_t *fieldElementToGmp(FieldElement const &c);
37
double fieldElementToFloatingPoint(FieldElement const&c);
39
* Will create a new FieldElement containing the value of c. The gmp representation of c is copied,
40
* so c must be destructed by the caller.
42
FieldElement fieldElementFromGmp(mpq_t *c);
44
* Will create a new FieldElement containing the value of c. The gmp representation of c is copied,
45
* so c must be destructed by the caller.
47
FieldElement fieldElementFromGmpZ(const mpz_t *c);
48
FieldElement gcd(FieldElement const &a, FieldElement const &b, FieldElement &s, FieldElement &t);
50
* Assumes that a and b are integers in the field of rational numbers.
51
* Assumes that b is non-zero.
52
* The remainder (if pointer is non-zero) is set to the remainder
53
* of a divided by b in the interval [0,B[, where B=abs(b)=max(b,-b).
54
* The return value equals the integer (a-remainder)/b.
56
FieldElement integerDivision(FieldElement const &a, FieldElement const &b, FieldElement *remainder=0);