SourceForge.net Logo
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

EkRational Class Template Reference

The EkRational class provides a templated implementation of the rational number. More...

#include <EkRational.h>

Inheritance diagram for EkRational:

[legend]
Collaboration diagram for EkRational:
[legend]
List of all members.

Public Methods

 EkRational (void)
 Default constructor. More...

 EkRational (const Type &numer, const Type &denom)
 constructor. More...

 EkRational (const EkRational< Type > &theSrc)
 constructor. More...

 ~EkRational (void)
 This is the destructor. More...

EkRational< Type > & operator= (const EkRational< Type > &rhs)
 This is an operator equals. More...

EkRational< Type > & operator+= (const EkRational< Type > &rhs)
 This is an operator+=. More...

EkRational< Type > & operator-= (const EkRational< Type > &rhs)
 This is an operator-=. More...

EkRational< Type > & operator *= (const EkRational< Type > &rhs)
 This is an operator *=. More...

EkRational< Type > & operator/= (const EkRational< Type > &rhs)
 This is an operator/=. More...

bool operator== (const EkRational< Type > &rhs) const
 This is an operator==. More...

bool operator!= (const EkRational< Type > &rhs) const
 This is an operator!=. More...

bool operator< (const EkRational< Type > &rhs) const
 This is an operator<. More...

bool operator<= (const EkRational< Type > &rhs) const
 This is an operator<=. More...

bool operator> (const EkRational< Type > &rhs) const
 This is an operator>. More...

bool operator>= (const EkRational< Type > &rhs) const
 This is an operator>=. More...

double asDouble (void) const
 This converts the rational to a double. More...

ostream & print (ostream &os) const
 This prints to the stream. More...

istream & read (istream &is)
 This reads from the stream. More...

double rationalize (const double &mFpVal, const double error=1.0e-10)
 Convert a floating point number into a rational. More...

const Type & numerator (void) const
 Access the numerator of the rational. More...

const Type & denominator (void) const
 Access the denominator of the rational. More...

void numerator (const Type &numer)
 This method sets the numerator. More...

void denominator (const Type &denom)
 This mehtod sets the denominator. More...


Detailed Description

template<class Type>
class EkRational< Type >

The EkRational class provides a templated implementation of the rational number.

A rational number is a fraction, p/q, where p and q are integers, with p being the Numerator and q the Denominator. This class can be constructed in several ways. First, using the constructor that takes two intergers the numerator and denominator. Second, using the default constructor and later supplying the numerator and denominator through class methods. Lastly, using the default constructor and supplying a floating point number to the rationalize() method that inturn calculates the integer numerator and denominator to the given precision (default is 1E-10). Smart pointers to the long and unsigned long versions of the EkRational class are pre-defined in the header file.


Constructor & Destructor Documentation

template<class Type>
EkRational< Type >::EkRational void    [inline]
 

Default constructor.

template<class Type>
EkRational< Type >::EkRational const Type &    numer,
const Type &    denom
[inline]
 

constructor.

template<class Type>
EkRational< Type >::EkRational const EkRational< Type > &    theSrc [inline]
 

constructor.

template<class Type>
EkRational< Type >::~EkRational void    [inline]
 

This is the destructor.


Member Function Documentation

template<class Type>
double EkRational< Type >::asDouble void    const [inline]
 

This converts the rational to a double.

template<class Type>
void EkRational< Type >::denominator const Type &    denom [inline]
 

This mehtod sets the denominator.

template<class Type>
const Type& EkRational< Type >::denominator void    const [inline]
 

Access the denominator of the rational.

template<class Type>
void EkRational< Type >::numerator const Type &    numer [inline]
 

This method sets the numerator.

template<class Type>
const Type& EkRational< Type >::numerator void    const [inline]
 

Access the numerator of the rational.

template<class Type>
EkRational< Type > & EkRational< Type >::operator *= const EkRational< Type > &    rhs [inline]
 

This is an operator *=.

template<class Type>
bool EkRational< Type >::operator!= const EkRational< Type > &    rhs const [inline]
 

This is an operator!=.

template<class Type>
EkRational< Type > & EkRational< Type >::operator+= const EkRational< Type > &    rhs [inline]
 

This is an operator+=.

template<class Type>
EkRational< Type > & EkRational< Type >::operator-= const EkRational< Type > &    rhs [inline]
 

This is an operator-=.

template<class Type>
EkRational< Type > & EkRational< Type >::operator/= const EkRational< Type > &    rhs [inline]
 

This is an operator/=.

template<class Type>
bool EkRational< Type >::operator< const EkRational< Type > &    rhs const [inline]
 

This is an operator<.

template<class Type>
bool EkRational< Type >::operator<= const EkRational< Type > &    rhs const [inline]
 

This is an operator<=.

template<class Type>
EkRational< Type > & EkRational< Type >::operator= const EkRational< Type > &    rhs [inline]
 

This is an operator equals.

template<class Type>
bool EkRational< Type >::operator== const EkRational< Type > &    rhs const [inline]
 

This is an operator==.

template<class Type>
bool EkRational< Type >::operator> const EkRational< Type > &    rhs const [inline]
 

This is an operator>.

template<class Type>
bool EkRational< Type >::operator>= const EkRational< Type > &    rhs const [inline]
 

This is an operator>=.

template<class Type>
ostream & EkRational< Type >::print ostream &    os const [inline]
 

This prints to the stream.

template<class Type>
double EkRational< Type >::rationalize const double &    mFpVal,
const double    error = 1.0e-10
 

Convert a floating point number into a rational.

template<class Type>
istream & EkRational< Type >::read istream &    is [inline]
 

This reads from the stream.


The documentation for this class was generated from the following file:
Last Updated: March 12, 2003 (rlr)
Copyright © 2003 Eastman Kodak Company All Rights Reserved.