Rational Class Reference

#include <Rational.h>

List of all members.

Public Member Functions

 Rational ()
 Rational (double)
 Rational (int n)
 Rational (long n)
 Rational (int n, int d)
 Rational (long n, long d)
 Rational (long n, unsigned long d)
 Rational (unsigned long n, long d)
 Rational (unsigned long n, unsigned long d)
 Rational (const Integer &n)
 Rational (const Integer &n, const Integer &d)
 Rational (const Rational &)
 ~Rational ()
Rationaloperator= (const Rational &y)
int operator== (const Rational &x)
int operator!= (const Rational &x)
Rationaloperator+= (const Rational &y)
Rationaloperator-= (const Rational &y)
Rationaloperator *= (const Rational &y)
Rationaloperator/= (const Rational &y)
void negate ()
void invert ()
const Integernumerator () const
const Integerdenominator () const
 operator double () const
int fits_in_float () const
int fits_in_double () const
void error (const char *msg) const
int OK () const

Protected Member Functions

void normalize ()

Protected Attributes

Integer num
Integer den

Friends

int operator< (const Rational &x, const Rational &y)
int operator<= (const Rational &x, const Rational &y)
int operator> (const Rational &x, const Rational &y)
int operator>= (const Rational &x, const Rational &y)
Rational operator+ (const Rational &x, const Rational &y)
Rational operator- (const Rational &x, const Rational &y)
Rational operator * (const Rational &x, const Rational &y)
Rational operator/ (const Rational &x, const Rational &y)
Rational operator- (const Rational &x)
int sign (const Rational &x)
Rational abs (const Rational &x)
Rational sqr (const Rational &x)
Rational pow (const Rational &x, long y)
Rational pow (const Rational &x, const Integer &y)
Integer floor (const Rational &x)
Integer ceil (const Rational &x)
Integer trunc (const Rational &x)
Integer round (const Rational &x)
istream & operator>> (istream &s, Rational &y)
ostream & operator<< (ostream &s, const Rational &y)
int compare (const Rational &x, const Rational &y)
void add (const Rational &x, const Rational &y, Rational &dest)
void sub (const Rational &x, const Rational &y, Rational &dest)
void mul (const Rational &x, const Rational &y, Rational &dest)
void div (const Rational &x, const Rational &y, Rational &dest)


Detailed Description

Definition at line 8 of file Rational.h.


Constructor & Destructor Documentation

Rational::Rational  )  [inline]
 

Definition at line 99 of file Rational.h.

Rational::Rational double   ) 
 

Rational::Rational int  n  )  [inline]
 

Definition at line 113 of file Rational.h.

Rational::Rational long  n  )  [inline]
 

Definition at line 111 of file Rational.h.

Rational::Rational int  n,
int  d
[inline]
 

Definition at line 116 of file Rational.h.

References normalize().

Rational::Rational long  n,
long  d
[inline]
 

Definition at line 115 of file Rational.h.

References normalize().

Rational::Rational long  n,
unsigned long  d
[inline]
 

Definition at line 117 of file Rational.h.

References normalize().

Rational::Rational unsigned long  n,
long  d
[inline]
 

Definition at line 121 of file Rational.h.

References normalize().

Rational::Rational unsigned long  n,
unsigned long  d
[inline]
 

Definition at line 125 of file Rational.h.

References normalize().

Rational::Rational const Integer n  )  [inline]
 

Definition at line 104 of file Rational.h.

Rational::Rational const Integer n,
const Integer d
[inline]
 

Definition at line 106 of file Rational.h.

References normalize().

Rational::Rational const Rational  )  [inline]
 

Definition at line 102 of file Rational.h.

Rational::~Rational  )  [inline]
 

Definition at line 100 of file Rational.h.


Member Function Documentation

const Integer & Rational::denominator  )  const [inline]
 

Definition at line 193 of file Rational.h.

References den.

void Rational::error const char *  msg  )  const
 

int Rational::fits_in_double  )  const
 

int Rational::fits_in_float  )  const
 

void Rational::invert  ) 
 

void Rational::negate  )  [inline]
 

Definition at line 162 of file Rational.h.

References Integer::negate1(), and num.

void Rational::normalize  )  [protected]
 

Referenced by Rational().

const Integer & Rational::numerator  )  const [inline]
 

Definition at line 192 of file Rational.h.

References num.

int Rational::OK  )  const
 

Rational & Rational::operator *= const Rational y  )  [inline]
 

Definition at line 180 of file Rational.h.

References mul.

Rational::operator double  )  const [inline]
 

Definition at line 194 of file Rational.h.

References den, and num.

int Rational::operator!= const Rational x  )  [inline]
 

Definition at line 35 of file Rational.h.

References compare, den, and num.

Rational & Rational::operator+= const Rational y  )  [inline]
 

Definition at line 168 of file Rational.h.

References add.

Rational & Rational::operator-= const Rational y  )  [inline]
 

Definition at line 174 of file Rational.h.

References sub.

Rational & Rational::operator/= const Rational y  )  [inline]
 

Definition at line 186 of file Rational.h.

References div.

Rational & Rational::operator= const Rational y  )  [inline]
 

Definition at line 130 of file Rational.h.

References den, and num.

int Rational::operator== const Rational x  )  [inline]
 

Definition at line 34 of file Rational.h.

References compare, den, and num.


Friends And Related Function Documentation

Rational abs const Rational x  )  [friend]
 

void add const Rational x,
const Rational y,
Rational dest
[friend]
 

Referenced by operator+=().

Integer ceil const Rational x  )  [friend]
 

int compare const Rational x,
const Rational y
[friend]
 

Referenced by operator!=(), and operator==().

void div const Rational x,
const Rational y,
Rational dest
[friend]
 

Referenced by operator/=().

Integer floor const Rational x  )  [friend]
 

void mul const Rational x,
const Rational y,
Rational dest
[friend]
 

Referenced by operator *=().

Rational operator * const Rational x,
const Rational y
[friend]
 

Definition at line 206 of file Rational.h.

Rational operator+ const Rational x,
const Rational y
[friend]
 

Definition at line 196 of file Rational.h.

Rational operator- const Rational x  )  [friend]
 

Rational operator- const Rational x,
const Rational y
[friend]
 

Definition at line 201 of file Rational.h.

Rational operator/ const Rational x,
const Rational y
[friend]
 

Definition at line 211 of file Rational.h.

int operator< const Rational x,
const Rational y
[friend]
 

Definition at line 137 of file Rational.h.

ostream& operator<< ostream &  s,
const Rational y
[friend]
 

int operator<= const Rational x,
const Rational y
[friend]
 

Definition at line 142 of file Rational.h.

int operator> const Rational x,
const Rational y
[friend]
 

Definition at line 147 of file Rational.h.

int operator>= const Rational x,
const Rational y
[friend]
 

Definition at line 152 of file Rational.h.

istream& operator>> istream &  s,
Rational y
[friend]
 

Rational pow const Rational x,
const Integer y
[friend]
 

Rational pow const Rational x,
long  y
[friend]
 

Integer round const Rational x  )  [friend]
 

int sign const Rational x  )  [friend]
 

Definition at line 157 of file Rational.h.

Rational sqr const Rational x  )  [friend]
 

void sub const Rational x,
const Rational y,
Rational dest
[friend]
 

Referenced by operator-=().

Integer trunc const Rational x  )  [friend]
 


Member Data Documentation

Integer Rational::den [protected]
 

Definition at line 12 of file Rational.h.

Referenced by denominator(), operator double(), operator!=(), operator=(), and operator==().

Integer Rational::num [protected]
 

Definition at line 11 of file Rational.h.

Referenced by negate(), numerator(), operator double(), operator!=(), operator=(), operator==(), and sign().


The documentation for this class was generated from the following file:
Generated on Mon Feb 27 22:47:17 2006 for CRyptography And Groups (CRAG) by  doxygen 1.4.4