7#ifndef gbLAB_Rational_h_
8#define gbLAB_Rational_h_
15 template<
typename IntScalarType>
38 Rational(
const IntScalarType& n_in,
const IntScalarType& d_in) :
48 return double(
n)/double(
d);
64 return n==0 && other==0;
71 return !(*
this==other);
130 template<
typename IntScalarType>
struct NumTraits<
gbLAB::Rational<IntScalarType>>
131 : NumTraits<IntScalarType>
141 RequireInitialization = 1,
142 ReadCost = int(NumTraits<IntScalarType>::ReadCost),
143 AddCost = int(NumTraits<IntScalarType>::AddCost),
144 MulCost = int(NumTraits<IntScalarType>::MulCost)
bool operator!=(const IntScalarType &other) const
Rational operator-(const Rational &r2) const
Rational operator-(const IntScalarType &i) const
Rational operator*(const IntScalarType &i) const
Rational operator*(const Rational &r2) const
Rational operator/(const Rational &r2) const
friend std::ostream & operator<<(std::ostream &os, const Rational &r)
bool operator==(const IntScalarType &other) const
Rational(const IntScalarType &n_in, const IntScalarType &d_in)
Rational operator+(const Rational &r2) const
Rational operator/(const IntScalarType &i) const
Rational operator+(const IntScalarType &i) const
Rational(const IntScalarType &n_in)