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