2 #ifndef _COMPLEX_RATIONAL_NUMBER_H_ 3 #define _COMPLEX_RATIONAL_NUMBER_H_ 5 #include "BPASField.hpp" 33 static RingProperties properties;
104 return (a == 0 && b == 0);
123 return (a == 1 && b == 0);
142 return (a == -1 && b == 0);
169 if (a == c.a && b == c.b)
174 inline bool operator== (
const mpq_class& k)
const {
175 if (a == k && b == 0)
181 if (a == k && b == 0)
187 if (a == c.a && b == c.b)
192 inline bool operator!= (
const mpq_class& k)
const {
193 if (a == k && b == 0)
199 if (a == k && b == 0)
237 mpq_class t = a*c.a - b*c.b;
238 mpq_class e = a*c.b + c.a*b;
296 std::cerr <<
"ComplexRationalNumber::convertToExpressionTree NOT YET IMPLEMENTED" << std::endl;
308 std::cout <<
"BPAS: error, dividend is zero from ComplexRationalNumber."<< std::endl;
311 mpq_class r = c.a*c.a + c.b*c.b;
312 mpq_class t = (a*c.a+b*c.b)/r;
313 mpq_class e = (b*c.a-c.b*a)/r;
346 std::vector<ComplexRationalNumber> ret;
347 ret.push_back(*
this);
356 std::cerr <<
"ComplexRationalNumber::euclideanSize NOT YET IMPLEMENTED" << std::endl;
385 mpq_class e = a * a + b * b;
404 void print(std::ostream& out)
const;
A univariate polynomial over an arbitrary BPASRing represented sparsely.
Definition: BigPrimeField.hpp:21
bool operator!=(const ComplexRationalNumber &c) const
Inequality test,.
Definition: ComplexRationalNumber.hpp:186
ComplexRationalNumber euclideanSize() const
Get the euclidean size of *this.
Definition: ComplexRationalNumber.hpp:354
An arbitrary-precision complex rational number.
Definition: ComplexRationalNumber.hpp:23
ComplexRationalNumber quotient(const ComplexRationalNumber &b) const
Get the quotient of *this and b.
ComplexRationalNumber & operator+=(const ComplexRationalNumber &c)
Addition assignment.
Definition: ComplexRationalNumber.hpp:209
ComplexRationalNumber operator/(const ComplexRationalNumber &c) const
Exact division.
Definition: ComplexRationalNumber.hpp:301
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
A finite field whose prime should be a generalized fermat number.
Definition: GeneralizedFermatPrimeField.hpp:36
ComplexRationalNumber operator-() const
Negation.
Definition: ComplexRationalNumber.hpp:226
ComplexRationalNumber & operator=(const ComplexRationalNumber &c)
Copy assignment.
ComplexRationalNumber & operator%=(const ComplexRationalNumber &c)
Assign *this to be the remainder of *this and b.
Definition: ComplexRationalNumber.hpp:323
ComplexRationalNumber & operator-=(const ComplexRationalNumber &c)
Subtraction assignment.
Definition: ComplexRationalNumber.hpp:220
void zero()
Assign to zero.
Definition: ComplexRationalNumber.hpp:112
bool operator==(const ComplexRationalNumber &c) const
Equality test,.
Definition: ComplexRationalNumber.hpp:168
ComplexRationalNumber operator+(const ComplexRationalNumber &c) const
Addition.
Definition: ComplexRationalNumber.hpp:204
A prime field whose prime is 32 bits or less.
Definition: SmallPrimeField.hpp:449
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:13
ComplexRationalNumber gcd(const ComplexRationalNumber &c) const
GCD(a, b)
Definition: ComplexRationalNumber.hpp:333
void negativeOne()
Assign to negative one.
Definition: ComplexRationalNumber.hpp:150
ComplexRationalNumber operator^(long long int e) const
Overload operator ^ replace xor operation by exponentiation.
Definition: ComplexRationalNumber.hpp:262
ComplexRationalNumber operator%(const ComplexRationalNumber &c) const
Get the remainder of *this and b;.
Definition: ComplexRationalNumber.hpp:319
ComplexRationalNumber extendedEuclidean(const ComplexRationalNumber &b, ComplexRationalNumber *s=NULL, ComplexRationalNumber *t=NULL) const
Perform the extended euclidean division on *this and b.
A univariate polynomial with RationalNumber coefficients represented densely.
Definition: urpolynomial.h:15
ComplexRationalNumber unitCanonical(ComplexRationalNumber *u=NULL, ComplexRationalNumber *v=NULL) const
Obtain the unit normal (a.k.a canonical associate) of an element.
A prime field whose prime can be arbitrarily large.
Definition: BigPrimeField.hpp:27
ComplexRationalNumber & operator/=(const ComplexRationalNumber &c)
Exact division assignment.
Definition: ComplexRationalNumber.hpp:306
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
void print(std::ostream &out) const
Print the Ring element.
ComplexRationalNumber euclideanDivision(const ComplexRationalNumber &b, ComplexRationalNumber *q=NULL) const
Perform the eucldiean division of *this and b.
An arbitrary-precision Integer.
Definition: Integer.hpp:22
ExpressionTree convertToExpressionTree() const
Convert this to an expression tree.
Definition: ComplexRationalNumber.hpp:295
int isConstant() const
Is a constant.
Definition: ComplexRationalNumber.hpp:160
ComplexRationalNumber inverse() const
Get the inverse of *this.
Definition: ComplexRationalNumber.hpp:383
ComplexRationalNumber remainder(const ComplexRationalNumber &b) const
Get the remainder of *this and b.
bool isOne() const
Is a 1.
Definition: ComplexRationalNumber.hpp:122
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
virtual mpz_class characteristic()
The characteristic of this ring class.
Definition: BPASRing.hpp:88
An abstract class defining the interface of a field.
Definition: BPASField.hpp:11
ComplexRationalNumber operator*(const ComplexRationalNumber &c) const
Multiplication.
Definition: ComplexRationalNumber.hpp:231
ComplexRationalNumber & operator*=(const ComplexRationalNumber &c)
Multiplication assignment.
Definition: ComplexRationalNumber.hpp:236
ComplexRationalNumber & operator^=(long long int e)
Exponentiation assignment.
Definition: ComplexRationalNumber.hpp:290
Factors< ComplexRationalNumber > squareFree() const
Compute squarefree factorization of *this.
Definition: ComplexRationalNumber.hpp:345
bool isZero() const
Is a zero.
Definition: ComplexRationalNumber.hpp:103
bool isNegativeOne() const
Is a -1.
Definition: ComplexRationalNumber.hpp:141
void one()
Assign to one.
Definition: ComplexRationalNumber.hpp:131