[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| Functions for Rational |

#include <vigra/rational.hxx>
More...

## Functions

template<typename IntType >
Rational< IntType > | abs (const Rational< IntType > &r)
| absolute value
template<typename IntType >
Rational< IntType > | ceil (const Rational< IntType > &r)
| smallest integer not smaller than `r`
template<typename IntType >
Rational< IntType > | floor (const Rational< IntType > &r)
| largest integer not larger than `r`
template<typename IntType >
Rational< IntType > | norm (const Rational< IntType > &r)
| norm (same as `abs(r)`)
template<typename IntType1 , typename IntType2 >
bool | operator!= (Rational< IntType1 > const &l, Rational< IntType2 > const &r)
| inequality
template<typename IntType1 , typename IntType2 >
bool | operator!= (const Rational< IntType1 > &l, IntType2 const &i)
| inequality with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator!= (IntType1 const &l, Rational< IntType2 > const &r)
| inequality with left-hand `IntType1` argument
template<typename IntType >
Rational< IntType > | operator* (Rational< IntType > l, Rational< IntType > const &r)
| multiplication
template<typename IntType >
Rational< IntType > | operator* (Rational< IntType > l, typename Rational< IntType >::param_type r)
| multiplication with right-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator* (typename Rational< IntType >::param_type l, Rational< IntType > r)
| multiplication with left-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator+ (const Rational< IntType > &r)
| unary plus
template<typename IntType >
Rational< IntType > | operator+ (Rational< IntType > l, Rational< IntType > const &r)
| addition
template<typename IntType >
Rational< IntType > | operator+ (Rational< IntType > l, typename Rational< IntType >::param_type r)
| addition of right-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator+ (typename Rational< IntType >::param_type l, Rational< IntType > r)
| addition of left-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator- (const Rational< IntType > &r)
| unary minus (negation)
template<typename IntType >
Rational< IntType > | operator- (Rational< IntType > l, Rational< IntType > const &r)
| subtraction
template<typename IntType >
Rational< IntType > | operator- (Rational< IntType > l, typename Rational< IntType >::param_type r)
| subtraction of right-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator- (typename Rational< IntType >::param_type l, Rational< IntType > const &r)
| subtraction from left-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator/ (Rational< IntType > l, Rational< IntType > const &r)
| division
template<typename IntType >
Rational< IntType > | operator/ (Rational< IntType > l, typename Rational< IntType >::param_type r)
| division by right-hand `IntType` argument
template<typename IntType >
Rational< IntType > | operator/ (typename Rational< IntType >::param_type l, Rational< IntType > const &r)
| division of left-hand `IntType` argument
template<typename IntType1 , typename IntType2 >
bool | operator< (const Rational< IntType1 > &l, const Rational< IntType2 > &r)
| less-than
template<typename IntType1 , typename IntType2 >
bool | operator< (const Rational< IntType1 > &l, IntType2 const &i)
| less-than with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator< (IntType1 const &l, Rational< IntType2 > const &r)
| less-than with left-hand `IntType1` argument
template<typename IntType1 , typename IntType2 >
bool | operator<= (Rational< IntType1 > const &l, Rational< IntType2 > const &r)
| less-equal
template<typename IntType1 , typename IntType2 >
bool | operator<= (Rational< IntType1 > const &l, IntType2 const &r)
| less-equal with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator<= (IntType1 const &l, Rational< IntType2 > const &r)
| less-equal with left-hand `IntType1` argument
template<typename IntType1 , typename IntType2 >
bool | operator== (const Rational< IntType1 > &l, const Rational< IntType2 > &r)
| equality
template<typename IntType1 , typename IntType2 >
bool | operator== (const Rational< IntType1 > &l, IntType2 const &i)
| equality with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator== (IntType1 const &l, Rational< IntType2 > const &r)
| equality with left-hand `IntType1` argument
template<typename IntType1 , typename IntType2 >
bool | operator> (Rational< IntType1 > const &l, Rational< IntType2 > const &r)
| greater-than
template<typename IntType1 , typename IntType2 >
bool | operator> (const Rational< IntType1 > &l, IntType2 const &i)
| greater-than with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator> (IntType1 const &l, Rational< IntType2 > const &r)
| greater-than with left-hand `IntType1` argument
template<typename IntType1 , typename IntType2 >
bool | operator>= (Rational< IntType1 > const &l, Rational< IntType2 > const &r)
| greater-equal
template<typename IntType1 , typename IntType2 >
bool | operator>= (Rational< IntType1 > const &l, IntType2 const &r)
| greater-equal with right-hand `IntType2` argument
template<typename IntType1 , typename IntType2 >
bool | operator>= (IntType1 const &l, Rational< IntType2 > const &r)
| greater-equal with left-hand `IntType1` argument
template<typename IntType >
Rational< IntType > | pow (const Rational< IntType > &r, int n)
template<typename T , typename IntType >
T | rational_cast (const Rational< IntType > &src)
template<typename IntType >
NormTraits< Rational< IntType > >::SquaredNormType | squaredNorm (const Rational< IntType > &r)
| squared norm

## Detailed Description

#include <vigra/rational.hxx>

These functions fulfill the requirements of an AlgebraicField.

Namespace: vigra

## Function Documentation

Rational< IntType > pow | ( | const Rational< IntType > & | r,
|  | int | e
| ) |  |

integer powers

`throws bad_rational` if indeterminate expression.

T vigra::rational_cast | ( | const Rational< IntType > & | src | ) |

Type conversion

Executes `static_cast<T>(numerator()) / denominator()`.

Usage:

            Rational<int> r;
            int i;
            double d;
            i = rational_cast<int>(r);     // round r downwards
            d = rational_cast<double>(r);  // represent rational as a double
            r = rational_cast<Rational<int> >(r);   // no change

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.9.0 (Tue Nov 6 2012)