plll  1.0
rational-ops.hpp File Reference

Operator definitions for rational numbers. More...

Go to the source code of this file.

Namespaces

 plll
 Contains the plll library.
 
 plll::arithmetic
 Contains the arithmetic backend of plll.
 
 plll::arithmetic::expressions
 Expression templates.
 

Functions

Assignment-operation operators.
Rational & plll::arithmetic::operator-= (Rational &cur, const Rational &r)
 Subtracts the given rational number r from this rational number. More...
 
template<class D >
Rational & plll::arithmetic::operator-= (Rational &cur, const expressions::Expression< RationalContext, D, expressions::MulOp > &E)
 Subtracts the given multiplication expression from this rational number. More...
 
Rational & plll::arithmetic::operator+= (Rational &cur, const Rational &r)
 Adds the given rational number r to this rational number. More...
 
template<class D >
Rational & plll::arithmetic::operator+= (Rational &cur, const expressions::Expression< RationalContext, D, expressions::MulOp > &E)
 Adds the given multiplication expression to this rational number. More...
 
Rational & plll::arithmetic::operator*= (Rational &cur, const Rational &r)
 Multiplies the given rational number r with this rational number. More...
 
Rational & plll::arithmetic::operator/= (Rational &cur, const Rational &r)
 Divides this rational number by the given rational number r. More...
 
Rational & plll::arithmetic::operator%= (Rational &cur, const Rational &r)
 Divides this rational number by the given rational number r and stores the remainder in this rational number. More...
 
Rational & plll::arithmetic::operator<<= (Rational &cur, long r)
 Multiplies this rational number by 2 to the power of r. More...
 
Rational & plll::arithmetic::operator>>= (Rational &cur, long r)
 Divides this rational number by 2 to the power of r. More...
 
Operators.
Rational plll::arithmetic::operator++ (Rational &cur, int)
 Increments this rational number by one and returns the previous value. More...
 
Rational plll::arithmetic::operator-- (Rational &cur, int)
 Decrements this rational number by one and returns the previous value. More...
 
Rational & plll::arithmetic::operator++ (Rational &cur)
 Increments this rational number by one and returns the new value. More...
 
Rational & plll::arithmetic::operator-- (Rational &cur)
 Decrements this rational number by one and returns the new value. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::NegOp > 
plll::arithmetic::operator- (const Rational &a)
 Negates this rational number. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< RationalContext >
>, expressions::AddOp > 
plll::arithmetic::operator+ (const Rational &a, const Rational &b)
 Adds the argument to this rational number and returns the result. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< RationalContext >
>, expressions::SubOp > 
plll::arithmetic::operator- (const Rational &a, const Rational &b)
 Subtracts the argument from this rational number and returns the result. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< RationalContext >
>, expressions::MulOp > 
plll::arithmetic::operator* (const Rational &a, const Rational &b)
 Multiplies the argument with this rational number and returns the result. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< RationalContext >
>, expressions::DivOp > 
plll::arithmetic::operator/ (const Rational &a, const Rational &b)
 Divides this rational number by the argument and returns the result. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< RationalContext >
>, expressions::ModOp > 
plll::arithmetic::operator% (const Rational &a, const Rational &b)
 Returns the remainder of this rational number divided by the by the argument. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::ShiftCOp > 
plll::arithmetic::operator<< (const Rational &a, signed long b)
 Multiplies this rational number with 2 to the power of b and returns the result. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::ShiftCOp > 
plll::arithmetic::operator>> (const Rational &a, signed long b)
 Divides this rational number by 2 to the power of b and returns the result. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::AbsOp > 
plll::arithmetic::abs (const Rational &i)
 Returns the absolute value of the given rational number. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::SquareOp > 
plll::arithmetic::square (const Rational &i)
 Returns the square of the given rational number. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::AbsOp > 
plll::arithmetic::abs (const Rational &i, const RationalContext &rc)
 Returns the absolute value of the given rational number. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::SquareOp > 
plll::arithmetic::square (const Rational &i, const RationalContext &rc)
 Returns the square of the given rational number. More...
 
Comparisons.
bool plll::arithmetic::operator== (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b for equality. More...
 
bool plll::arithmetic::operator!= (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b for inequality. More...
 
bool plll::arithmetic::operator<= (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b. More...
 
bool plll::arithmetic::operator>= (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b. More...
 
bool plll::arithmetic::operator< (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b. More...
 
bool plll::arithmetic::operator> (const Rational &a, const Rational &b)
 Compares the two rational numbers a and b. More...
 
Exponentiation.
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::PowerCOp
< signed long >::impl > 
plll::arithmetic::power (const Rational &a, signed long b)
 Returns a raised to the power of b. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::PowerCOp
< unsigned long >::impl > 
plll::arithmetic::power (const Rational &a, unsigned long b)
 Returns a raised to the power of b. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< IntegerContext >
>, expressions::PowerOp > 
plll::arithmetic::power (const Rational &a, const Integer &b)
 Returns a raised to the power of b. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::PowerCOp
< signed long >::impl > 
plll::arithmetic::power (const Rational &a, signed long b, const RationalContext &rc)
 Returns a raised to the power of b. More...
 
expressions::Expression
< RationalContext,
expressions::Wrapper
< RationalContext >
, expressions::PowerCOp
< unsigned long >::impl > 
plll::arithmetic::power (const Rational &a, unsigned long b, const RationalContext &rc)
 Returns a raised to the power of b. More...
 
expressions::Expression
< RationalContext, std::pair
< expressions::Wrapper
< RationalContext >
, expressions::Wrapper
< IntegerContext >
>, expressions::PowerOp > 
plll::arithmetic::power (const Rational &a, const Integer &b, const RationalContext &rc)
 Returns a raised to the power of b. More...
 
Functional versions of operators.
void plll::arithmetic::addmul (Rational &r, const Rational &a, const Rational &b)
 Multiplies a and b and adds the result to r. More...
 
void plll::arithmetic::submul (Rational &r, const Rational &a, const Rational &b)
 Multiplies a and b and subtracts the result from r. More...
 

Detailed Description

Operator definitions for rational numbers.

This header contains templates and instantiations to implement all operations on rational numbers.

Definition in file rational-ops.hpp.