2 #ifndef _COMPLEX_RATIONAL_NUMBER_H_ 3 #define _COMPLEX_RATIONAL_NUMBER_H_ 5 #include "BPASField.hpp" 103 return (a == 0 && b == 0);
122 return (a == 1 && b == 0);
141 return (a == -1 && b == 0);
168 if (a == c.a && b == c.b)
173 inline bool operator== (
const mpq_class& k)
const {
174 if (a == k && b == 0)
180 if (a == k && b == 0)
186 if (a == c.a && b == c.b)
191 inline bool operator!= (
const mpq_class& k)
const {
192 if (a == k && b == 0)
198 if (a == k && b == 0)
236 mpq_class t = a*c.a - b*c.b;
237 mpq_class e = a*c.b + c.a*b;
295 std::cerr <<
"ComplexRationalNumber::convertToExpressionTree NOT YET IMPLEMENTED" << std::endl;
307 std::cout <<
"BPAS: error, dividend is zero from ComplexRationalNumber."<< std::endl;
310 mpq_class r = c.a*c.a + c.b*c.b;
311 mpq_class t = (a*c.a+b*c.b)/r;
312 mpq_class e = (b*c.a-c.b*a)/r;
345 std::vector<ComplexRationalNumber> ret;
346 ret.push_back(*
this);
381 mpq_class e = a * a + b * b;
400 void print(std::ostream& out)
const;
A sparsely represented univariate polynomial over an arbitrary ring.
Definition: BigPrimeField.hpp:21
bool operator!=(const ComplexRationalNumber &c) const
Inequality test,.
Definition: ComplexRationalNumber.hpp:185
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:208
ComplexRationalNumber operator/(const ComplexRationalNumber &c) const
Exact division.
Definition: ComplexRationalNumber.hpp:300
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:225
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:322
ComplexRationalNumber & operator-=(const ComplexRationalNumber &c)
Subtraction assignment.
Definition: ComplexRationalNumber.hpp:219
void zero()
Assign to zero.
Definition: ComplexRationalNumber.hpp:111
bool operator==(const ComplexRationalNumber &c) const
Equality test,.
Definition: ComplexRationalNumber.hpp:167
ComplexRationalNumber operator+(const ComplexRationalNumber &c) const
Addition.
Definition: ComplexRationalNumber.hpp:203
A prime field whose prime is 32 bits or less.
Definition: SmallPrimeField.hpp:450
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:14
ComplexRationalNumber gcd(const ComplexRationalNumber &c) const
GCD(a, b)
Definition: ComplexRationalNumber.hpp:332
void negativeOne()
Assign to negative one.
Definition: ComplexRationalNumber.hpp:149
ComplexRationalNumber operator^(long long int e) const
Overload operator ^ replace xor operation by exponentiation.
Definition: ComplexRationalNumber.hpp:261
ComplexRationalNumber operator%(const ComplexRationalNumber &c) const
Get the remainder of *this and b;.
Definition: ComplexRationalNumber.hpp:318
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:16
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:305
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:294
int isConstant() const
Is a constant.
Definition: ComplexRationalNumber.hpp:159
ComplexRationalNumber inverse() const
Get the inverse of *this.
Definition: ComplexRationalNumber.hpp:379
ComplexRationalNumber remainder(const ComplexRationalNumber &b) const
Get the remainder of *this and b.
bool isOne() const
Is a 1.
Definition: ComplexRationalNumber.hpp:121
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
An abstract class defining the interface of a field.
Definition: BPASField.hpp:11
ComplexRationalNumber operator*(const ComplexRationalNumber &c) const
Multiplication.
Definition: ComplexRationalNumber.hpp:230
ComplexRationalNumber & operator*=(const ComplexRationalNumber &c)
Multiplication assignment.
Definition: ComplexRationalNumber.hpp:235
ComplexRationalNumber & operator^=(long long int e)
Exponentiation assignment.
Definition: ComplexRationalNumber.hpp:289
Factors< ComplexRationalNumber > squareFree() const
Compute squarefree factorization of *this.
Definition: ComplexRationalNumber.hpp:344
bool isZero() const
Is a zero.
Definition: ComplexRationalNumber.hpp:102
bool isNegativeOne() const
Is a -1.
Definition: ComplexRationalNumber.hpp:140
Integer euclideanSize() const
Get the euclidean size of *this.
Definition: ComplexRationalNumber.hpp:353
void one()
Assign to one.
Definition: ComplexRationalNumber.hpp:130