#include <py2cpp/fractions.hpp>
template<typename Z>
Fraction struct
Template parameters | |
---|---|
Z |
Public functions
- auto Fraction(Z num, Z den) -> CONSTEXPR14
- Construct a new Fraction object.
- auto normalize() -> Z -> CONSTEXPR14 auto
- normalize to a canonical form
- auto normalize1() -> CONSTEXPR14 void
- normalize to a canonical form
- auto normalize2() -> Z -> CONSTEXPR14 auto
- normalize to a canonical form
- auto Fraction(Z&& num) -> CONSTEXPR14 explicit
- Construct a new Fraction object.
- auto Fraction(const Z& num) -> CONSTEXPR14 explicit
- Construct a new Fraction object.
- auto Fraction() -> CONSTEXPR14
- Construct a new Fraction object.
- auto num() const noexcept -> const Z & -> CONSTEXPR14 auto
- auto den() const noexcept -> const Z & -> CONSTEXPR14 auto
- auto cross(const Fraction& rhs) const -> Z -> CONSTEXPR14 auto
- cross product
- auto reciprocal() -> CONSTEXPR14 void
- reciprocal
- auto operator*=(Fraction rhs) -> Fraction & -> CONSTEXPR14 auto
- multiply and assign
- auto operator*=(Z rhs) -> Fraction & -> CONSTEXPR14 auto
- multiply and assign
- auto operator/=(Fraction rhs) -> Fraction & -> CONSTEXPR14 auto
- divide and assign
- auto operator/=(Z rhs) -> Fraction & -> CONSTEXPR14 auto
- divide and assign
- auto operator-() const -> Fraction -> CONSTEXPR14 auto
- Negate.
- auto operator+(const Fraction& rhs) const -> Fraction -> CONSTEXPR14 auto
- Add.
- auto operator-(const Fraction& frac) const -> Fraction -> CONSTEXPR14 auto
- Subtract.
- auto operator-(const Z& i) const -> Fraction -> CONSTEXPR14 auto
- auto operator+=(const Fraction& rhs) -> Fraction & -> CONSTEXPR14 auto
- auto operator-=(const Fraction& rhs) -> Fraction & -> CONSTEXPR14 auto
- auto operator+=(const Z& i) -> Fraction & -> CONSTEXPR14 auto
- auto operator-=(const Z& rhs) -> Fraction & -> CONSTEXPR14 auto
Public variables
Comparison operators
==, !=, <, >, <=, >= etc.
- auto operator!=(const Fraction& rhs) const -> bool -> CONSTEXPR14 auto
- auto operator>(const Fraction& rhs) const -> bool -> CONSTEXPR14 auto
- Greater than.
- auto operator>=(const Fraction& rhs) const -> bool -> CONSTEXPR14 auto
- Greater than or euqal to.
- auto operator<=(const Fraction& rhs) const -> bool -> CONSTEXPR14 auto
- Less than or equal to.
- auto operator>(const Z& rhs) const -> bool -> CONSTEXPR14 auto
- Greater than.
- auto operator<=(const Z& rhs) const -> bool -> CONSTEXPR14 auto
- Less than or equal to.
- auto operator>=(const Z& rhs) const -> bool -> CONSTEXPR14 auto
- Greater than or equal to.
- auto operator==(const Fraction& lhs, const Z& rhs) -> bool -> CONSTEXPR14 auto
- Equal to.
- auto operator<(const Fraction& lhs, const Z& rhs) -> bool -> CONSTEXPR14 auto
- Less than.
- auto operator<(const Z& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Less than.
- auto operator==(const Z& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Equal to.
- auto operator==(const Fraction& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Equal to.
- auto operator<(const Fraction& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Less than.
- auto operator>(const Z& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Greater than.
- auto operator<=(const Z& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Less than or equal to.
- auto operator>=(const Z& lhs, const Fraction& rhs) -> bool -> CONSTEXPR14 auto
- Greater than or euqal to.
Friends
- auto operator*(Fraction lhs, const Fraction& rhs) -> Fraction -> CONSTEXPR14 auto
- multiply
- auto operator*(Fraction lhs, const Z& rhs) -> Fraction -> CONSTEXPR14 auto
- multiply
- auto operator*(const Z& lhs, Fraction rhs) -> Fraction -> CONSTEXPR14 auto
- multiply
- auto operator/(Fraction lhs, const Fraction& rhs) -> Fraction -> CONSTEXPR14 auto
- divide
- auto operator/(Fraction lhs, const Z& rhs) -> Fraction -> CONSTEXPR14 auto
- divide
- auto operator/(const Z& lhs, Fraction rhs) -> Fraction -> CONSTEXPR14 auto
- divide
- auto operator+(Fraction frac, const Z& i) -> Fraction -> CONSTEXPR14 auto
- Add.
- auto operator+(const Z& i, Fraction frac) -> Fraction -> CONSTEXPR14 auto
- Add.
- auto operator-(const Z& c, const Fraction& frac) -> Fraction -> CONSTEXPR14 auto
- auto operator+(int&& c, const Fraction& frac) -> Fraction -> CONSTEXPR14 auto
- auto operator-(int&& c, const Fraction& frac) -> Fraction -> CONSTEXPR14 auto
- auto operator*(int&& c, const Fraction& frac) -> Fraction -> CONSTEXPR14 auto
-
template<typename _Stream>auto operator<<(_Stream& os, const Fraction& frac) -> _Stream & -> auto
Function documentation
template<typename Z>
CONSTEXPR14 fun:: Fraction<Z>:: Fraction(Z num,
Z den)
Construct a new Fraction object.
Parameters | |
---|---|
num in | |
den in |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: normalize() -> Z
normalize to a canonical form
denominator is always non-negative and co-prime with numerator
template<typename Z>
CONSTEXPR14 void fun:: Fraction<Z>:: normalize1()
normalize to a canonical form
denominator is always non-negative
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: normalize2() -> Z
normalize to a canonical form
denominator is always co-prime with numerator
template<typename Z>
CONSTEXPR14 fun:: Fraction<Z>:: Fraction(Z&& num) explicit
Construct a new Fraction object.
Parameters | |
---|---|
num in |
template<typename Z>
CONSTEXPR14 fun:: Fraction<Z>:: Fraction(const Z& num) explicit
Construct a new Fraction object.
Parameters | |
---|---|
num in |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: num() const noexcept -> const Z &
Returns | const Z& |
---|
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: den() const noexcept -> const Z &
Returns | const Z& |
---|
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: cross(const Fraction& rhs) const -> Z
cross product
Parameters | |
---|---|
rhs in | |
Returns | Z |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator*=(Fraction rhs) -> Fraction &
multiply and assign
Parameters | |
---|---|
rhs in | |
Returns | Fraction& |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator*=(Z rhs) -> Fraction &
multiply and assign
Parameters | |
---|---|
rhs in | |
Returns | Fraction& |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator/=(Fraction rhs) -> Fraction &
divide and assign
Parameters | |
---|---|
rhs in | |
Returns | Fraction& |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator/=(Z rhs) -> Fraction &
divide and assign
Parameters | |
---|---|
rhs in | |
Returns | Fraction& |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator-() const -> Fraction
Negate.
Returns | Fraction |
---|
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator+(const Fraction& rhs) const -> Fraction
Add.
Parameters | |
---|---|
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator-(const Fraction& frac) const -> Fraction
Subtract.
Parameters | |
---|---|
frac in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator-(const Z& i) const -> Fraction
Parameters | |
---|---|
i in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator+=(const Fraction& rhs) -> Fraction &
Parameters | |
---|---|
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator-=(const Fraction& rhs) -> Fraction &
Parameters | |
---|---|
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator+=(const Z& i) -> Fraction &
Parameters | |
---|---|
i in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator-=(const Z& rhs) -> Fraction &
Parameters | |
---|---|
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator!=(const Fraction& rhs) const -> bool
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>(const Fraction& rhs) const -> bool
Greater than.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>=(const Fraction& rhs) const -> bool
Greater than or euqal to.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<=(const Fraction& rhs) const -> bool
Less than or equal to.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>(const Z& rhs) const -> bool
Greater than.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<=(const Z& rhs) const -> bool
Less than or equal to.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>=(const Z& rhs) const -> bool
Greater than or equal to.
Parameters | |
---|---|
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator==(const Fraction& lhs,
const Z& rhs) -> bool
Equal to.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<(const Fraction& lhs,
const Z& rhs) -> bool
Less than.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<(const Z& lhs,
const Fraction& rhs) -> bool
Less than.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator==(const Z& lhs,
const Fraction& rhs) -> bool
Equal to.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator==(const Fraction& lhs,
const Fraction& rhs) -> bool
Equal to.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
Equal to
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<(const Fraction& lhs,
const Fraction& rhs) -> bool
Less than.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>(const Z& lhs,
const Fraction& rhs) -> bool
Greater than.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator<=(const Z& lhs,
const Fraction& rhs) -> bool
Less than or equal to.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto fun:: Fraction<Z>:: operator>=(const Z& lhs,
const Fraction& rhs) -> bool
Greater than or euqal to.
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | true |
template<typename Z>
CONSTEXPR14 auto operator*(Fraction lhs,
const Fraction& rhs) -> Fraction
multiply
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator*(Fraction lhs,
const Z& rhs) -> Fraction
multiply
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator*(const Z& lhs,
Fraction rhs) -> Fraction
multiply
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator/(Fraction lhs,
const Fraction& rhs) -> Fraction
divide
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator/(Fraction lhs,
const Z& rhs) -> Fraction
divide
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator/(const Z& lhs,
Fraction rhs) -> Fraction
divide
Parameters | |
---|---|
lhs in | |
rhs in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator+(Fraction frac,
const Z& i) -> Fraction
Add.
Parameters | |
---|---|
frac in | |
i in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator+(const Z& i,
Fraction frac) -> Fraction
Add.
Parameters | |
---|---|
i in | |
frac in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator-(const Z& c,
const Fraction& frac) -> Fraction
Parameters | |
---|---|
c in | |
frac in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator+(int&& c,
const Fraction& frac) -> Fraction
Parameters | |
---|---|
c in | |
frac in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator-(int&& c,
const Fraction& frac) -> Fraction
Parameters | |
---|---|
c in | |
frac in | |
Returns | Fraction |
template<typename Z>
CONSTEXPR14 auto operator*(int&& c,
const Fraction& frac) -> Fraction
Parameters | |
---|---|
c in | |
frac in | |
Returns | Fraction<Z> |
template<typename Z>
template<typename _Stream>
auto operator<<(_Stream& os,
const Fraction& frac) -> _Stream &
Template parameters | |
---|---|
_Stream | |
Parameters | |
os in | |
frac in | |
Returns | _Stream& |