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. More...
|
|
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. More...
|
|
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. More...
|
|
std::string | to_string () const |
| Convert the ratio to string representation.
|
|
| operator std::string () |
| Convert the ratio to string representation.
|
|
|
T1 | num |
| The numerator.
|
|
T2 | den |
| The denominator.
|
|
|
std::ostream & | operator<< (std::ostream &out, const ratio< T1, T2 > &obj) |
| Stream the ratio in string representation to an output stream (std::ostream)
|
|
template<typename T1, typename T2 = T1>
class theoretica::ratio< T1, T2 >
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.
◆ ratio()
template<typename T1 , typename T2 = T1>
Construct the object from two objects.
- Parameters
-
n | The numerator |
d | The denominator |
◆ eval_as()
template<typename T1 , typename T2 = T1>
template<typename T >
Evaluate the ratio as the division between numerator and denominator cast to the specified type.
This function is well-defined only if division between objects of type T is defined. A static cast is performed before division.
◆ operator T2()
template<typename T1 , typename T2 = T1>
Evaluate the ratio as the division between numerator and denominator cast to the type of the denominator.
- See also
- eval
The documentation for this class was generated from the following file: