|
|
Go to the documentation of this file. 1 #ifndef PhysicsTools_Utilities_Fraction_h
2 #define PhysicsTools_Utilities_Fraction_h
10 template <
int n,
int m>
12 static_assert(
m != 0);
15 operator double()
const {
return double(
n) / double(
m); }
17 double operator()(
double,
double)
const {
return double(
n) / double(
m); }
20 template <
int n,
int m,
unsigned gcd = std::gcd(
n,
m),
int num =
n / gcd,
int den =
m / gcd>
25 template <
int n,
int m,
unsigned gcd,
int num>
30 template <
int n,
int m,
bool pn = (n >= 0),
bool pm = (
m >= 0)>
35 template <
int n,
int m>
41 template <
int n,
int m>
47 template <
int n,
int m>
52 template <
int n,
int m>
57 template <
int n,
int m>
62 template <
int a,
int b,
int c>
68 template <
int a,
int b,
int c>
74 template <
int a,
int b,
int c>
80 template <
int a,
int b,
int c>
86 template <
int a,
int b,
int c>
92 template <
int a,
int b,
int c>
98 template <
int a,
int b,
int c>
104 template <
int a,
int b,
int c,
int d>
108 return fract<a * d + c * b, b * d>();
112 template <
int a,
int b,
int c,
int d>
120 template <
int a,
int b,
int c,
int d>
124 return fract<a * c, b * d>();
128 template <
int a,
int b,
int c,
int d>
132 return fract<a * d, b * c>();
static type combine(const FractionStruct< b, c > &, const Numerical< a > &)
Minus< typename PositiveFraction< n, -m >::type >::type type
FractionStruct< num, den > type
Fraction< a *d, b *c >::type type
static type combine(const Numerical< a > &, const FractionStruct< b, c > &)
double operator()() const
Fraction< b, a *c >::type type
static type combine(const FractionStruct< a, b > &, const FractionStruct< c, d > &)
static type combine(const FractionStruct< a, b > &, const FractionStruct< c, d > &)
Fraction< a *d+c *b, b *d >::type type
static const int numerator
static type combine(const Numerical< a > &, const FractionStruct< b, c > &)
static type combine(const FractionStruct< b, c > &, const Numerical< a > &)
Fraction< n, m >::type type
static type combine(const Numerical< a > &, const FractionStruct< b, c > &)
const Numerical< n > & num()
double operator()(double) const
static const int denominator
Fraction< a *c+b, b >::type type
Fraction< a *b, c >::type type
static type combine(const FractionStruct< a, b > &, const FractionStruct< c, d > &)
const Fraction< n, m >::type & fract()
Fraction< a *c, b *d >::type type
PositiveFraction< n, m >::type type
Fraction< a *d - c *b, b *d >::type type
static type combine(const Numerical< n > &, const Numerical< m > &)
Minus< typename PositiveFraction<-n, m >::type >::type type
Fraction< a *c+b, b >::type type
static type combine(const FractionStruct< a, b > &, const FractionStruct< c, d > &)
static type combine(const FractionStruct< b, c > &, const Numerical< a > &)
Fraction< a *b, c >::type type
Fraction< a *c - b, b >::type type
double operator()(double, double) const
static type combine(const Numerical< a > &, const FractionStruct< b, c > &)
Fraction< a *c, b >::type type
Minus< typename PositiveFraction<-n, -m >::type >::type type