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

Go to the source code of this file.
Functions | |
| template<typename T > | |
| T | gcd (T a, T b) |
| Computes the greates common divisor. | |
| template<typename T > | |
| T | lcm (T a, T b) |
| Computes the least common multiple. | |
Euclidean algorithm to compute gcd() and lcm().
Definition in file euclid.hh.
| T gcd | ( | T | a, | |
| T | 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.
| a | the first number. | |
| b | the second number. |
Definition at line 41 of file euclid.hh.
Referenced by rational::cancel(), and lcm().
| T lcm | ( | T | a, | |
| T | 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.
| a | the first number. | |
| b | the second number. |
Definition at line 62 of file euclid.hh.
References gcd().
Referenced by mipgen::comdenom(), and rational::operator-().
1.6.0