euclid.hh File Reference

Euclidean algorithm to compute gcd() and lcm(). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
gcd (T a, T b)
 Computes the greates common divisor.
template<typename T >
lcm (T a, T b)
 Computes the least common multiple.

Detailed Description

Euclidean algorithm to compute gcd() and lcm().

Definition in file euclid.hh.


Function Documentation

template<typename T >
T gcd ( a,
b 
) [inline]

Computes the greates common divisor.

The implementation can handle negative numbers and an arbitrary order of arguments. The implementation as a template allows its use for different types.

Parameters:
a the first number.
b the second number.
Returns:
the greatest common divisor of a and b.

Definition at line 41 of file euclid.hh.

Referenced by rational::cancel(), and lcm().

template<typename T >
T lcm ( a,
b 
) [inline]

Computes the least common multiple.

The implementation can handle negative numbers and an arbitrary order of arguments. The implementation as a template allows its use for different types.

Parameters:
a the first number.
b the second number.
Returns:
the least common multiple of a and b.

Definition at line 62 of file euclid.hh.

References gcd().

Referenced by mipgen::comdenom(), and rational::operator-().


Generated on Fri Aug 21 08:15:07 2009 for mqn2mps by  doxygen 1.6.0