representing a ratio between two objects, like a fraction or a rational polynomial.
More...
|
| ratio () |
| Construct the object from the default constructors of the two types.
|
|
| ratio (const T1 &n, const T2 &d) |
| Construct the object from two objects.
|
|
ratio | operator* (const ratio &r) const |
| Multiply two ratios.
|
|
ratio | operator/ (const ratio &r) const |
| Divide two ratios (without explicitly using division)
|
|
ratio | operator+ (const ratio &r) const |
| Add two ratios.
|
|
ratio | operator- (const ratio &r) const |
| Subtract two ratios.
|
|
ratio | operator* (const T1 &a) const |
| Multiply the ratio by a factor.
|
|
ratio | operator/ (const T2 &b) const |
| Divide the ratio by a factor.
|
|
template<typename T > |
T | eval_as () |
| Evaluate the ratio as the division between numerator and denominator cast to the specified type.
|
|
T2 | eval () |
| Evaluate the ratio as the division between numerator and denominator cast to the type of the denominator.
|
|
| operator T2 () |
| Evaluate the ratio as the division between numerator and denominator cast to the type of the denominator.
|
|
std::string | to_string () const |
| Convert the ratio to string representation.
|
|
| operator std::string () |
| Convert the ratio to string representation.
|
|
representing a ratio between two objects, like a fraction or a rational polynomial.
- Note
- For the class to properly work, the template types need to have operator*, operator+ and operator- defined.