1#ifndef FREE_TENSOR_RATIONAL_H
2#define FREE_TENSOR_RATIONAL_H
29 T g = std::gcd(
lhs.q_,
rhs.q_);
36 T g = std::gcd(
lhs.q_,
rhs.q_);
55 os <<
"(" << r.
p_ <<
" / " << r.
q_ <<
")";
60 T g = std::gcd(
lhs.q_,
rhs.q_);
65 return *
this = *
this + other;
68 return *
this = *
this - other;
71 return *
this = *
this * other;
74 return *
this = *
this / other;
86 return x < 0 ? -x : x;
Definition: allocator.h:9
auto && lhs
Definition: const_fold.cc:70
auto auto && rhs
Definition: const_fold.cc:70
freetensor::Rational< T > abs(const freetensor::Rational< T > &x)
Definition: rational.h:85
friend Rational operator*(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:42
Rational(T p=0, T q=1)
Definition: rational.h:12
friend auto operator<=>(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:59
Rational & operator+=(const Rational< T > &other)
Definition: rational.h:64
friend Rational operator/(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:48
Rational & operator/=(const Rational< T > &other)
Definition: rational.h:73
friend Rational operator-(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:35
friend Rational operator+(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:28
Rational & operator*=(const Rational< T > &other)
Definition: rational.h:70
Rational & operator-=(const Rational< T > &other)
Definition: rational.h:67
friend bool operator==(const Rational< T > &lhs, const Rational< T > &rhs)
Definition: rational.h:24
friend std::ostream & operator<<(std::ostream &os, const Rational< T > &r)
Definition: rational.h:54
T p_
Definition: rational.h:10
Rational operator-() const
Definition: rational.h:77
T q_
Definition: rational.h:10