plll
1.0
|
Header for rational number arithmetic. More...
#include <plll/arithmetic.hpp>
#include "helper.hpp"
#include <sstream>
#include <cassert>
#include <cmath>
#include "rational-ops.hpp"
#include "rational-conv.hpp"
Go to the source code of this file.
Classes | |
class | plll::arithmetic::Rational |
Represents a rational number as a quotient of two arbitrary precision integers. More... | |
class | plll::arithmetic::RationalContext |
Represents an arithmetic context for rational numbers. More... | |
Namespaces | |
plll | |
Contains the plll library. | |
plll::arithmetic | |
Contains the arithmetic backend of plll . | |
Functions | |
Predicates. | |
bool | plll::arithmetic::isZero (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given rational number for being zero. More... | |
bool | plll::arithmetic::isOne (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given plll::arithmetic::Real object for being zero. More... | |
bool | plll::arithmetic::isPositive (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given rational number for being strictly positive. More... | |
bool | plll::arithmetic::isNonNegative (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given rational number for being positive or zero. More... | |
bool | plll::arithmetic::isNegative (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given rational number for being strictly negative. More... | |
bool | plll::arithmetic::isNonPositive (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Tests the given rational number for being negative or zero. More... | |
Functional versions of operators. | |
void | plll::arithmetic::add (Rational &r, const Rational &a, const Rational &b) |
Adds a and b and stores the result in r . More... | |
void | plll::arithmetic::sub (Rational &r, const Rational &a, const Rational &b) |
Subtracts b from a and stores the result in r . More... | |
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... | |
void | plll::arithmetic::mul (Rational &r, const Rational &a, const Rational &b) |
Multiplies a with b and stores the result in r . More... | |
void | plll::arithmetic::div (Rational &r, const Rational &a, const Rational &b) |
Divides a by b and stores the result in r . More... | |
void | plll::arithmetic::mod (Rational &r, const Rational &a, const Rational &b) |
Takes the remainder of the division of a by b and stores it in r . More... | |
void | plll::arithmetic::shl (Rational &r, const Rational &a, long b) |
Multiplies a by and stores the result in r . More... | |
void | plll::arithmetic::shr (Rational &r, const Rational &a, long b) |
Multiplies a by and stores the result in r . More... | |
void | plll::arithmetic::increment (Rational &r, const Rational &a) |
Increments a by one and stores the result in r . More... | |
void | plll::arithmetic::decrement (Rational &r, const Rational &a) |
Negates a and stores the result in r . More... | |
void | plll::arithmetic::neg (Rational &r, const Rational &a) |
Negates a and stores the result in r . More... | |
void | plll::arithmetic::abs (Rational &r, const Rational &a) |
Takes the absolute value of a and stores the result in r . More... | |
void | plll::arithmetic::square (Rational &r, const Rational &a) |
Computes the square of a and stores the result in r . More... | |
Sign querying/modification. | |
void | plll::arithmetic::makeAbs (Rational &a) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Makes the operand non-negative. More... | |
int | plll::arithmetic::sign (const Rational &r) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Returns the sign of the given rational number. More... | |
Stream input/output. | |
std::ostream & | plll::arithmetic::operator<< (std::ostream &s, const Rational &r) |
Outputs the rational number on the given output stream. | |
std::istream & | plll::arithmetic::operator>> (std::istream &s, Rational &r) |
Reads the rational number from the given input stream. | |
Setting to specific constants. | |
void | plll::arithmetic::setZero (Rational &r, bool sign=true) |
Sets the given rational number to . More... | |
void | plll::arithmetic::setOne (Rational &r) |
Sets the given rational number to one. More... | |
Comparisons. | |
int | plll::arithmetic::compare (const Rational &a, const Rational &b) |
Compares the two rational numbers. More... | |
int | plll::arithmetic::compareAbsValues (const Rational &a, const Rational &b) |
Compares the two rational numbers in absolute value. More... | |
Exponentiation. | |
void | plll::arithmetic::power (Rational &r, const Rational &a, signed long e) |
Raises a to the power e and stores the result in r . More... | |
void | plll::arithmetic::power (Rational &r, const Rational &a, unsigned long e) |
Raises a to the power e and stores the result in r . More... | |
void | plll::arithmetic::power (Rational &r, const Rational &a, const Integer &e) |
Raises a to the power e and stores the result in r . More... | |
Swap functions. | |
void | plll::arithmetic::swap (Rational &, Rational &) PLLL_INTERNAL_NOTHROW_POSTFIX_INLINE |
Swaps two plll::arithmetic::Rational objects. | |
Header for rational number arithmetic.
This header provides rational number arithmetic for plll
. It provides plll::arithmetic::RationalContext
, an arithmetic context as described in Arithmetic Contexts. Concrete rational numbers are represented by plll::arithmetic::Rational
objects, which essentially consist of two plll::arithmetic::Integer
objects, and expressions are represented by plll::arithmetic::expressions::expression<>
templates.
Definition in file rational.hpp.