CoinUtils 2.11.10
Loading...
Searching...
No Matches
CoinRational.hpp
Go to the documentation of this file.
1// Authors: Matthew Saltzman and Ted Ralphs
2// Copyright 2015, Matthew Saltzman and Ted Ralphs
3// Licensed under the Eclipse Public License 1.0
4
5#ifndef CoinRational_H
6#define CoinRational_H
7
8#include <cmath>
9
10//Small class for rational numbers
12
13public:
14 long getDenominator() { return denominator_; }
15 long getNumerator() { return numerator_; }
16
18 : numerator_(0)
19 , denominator_(1) {};
20
21 CoinRational(long n, long d)
22 : numerator_(n)
23 , denominator_(d) {};
24
25 CoinRational(double val, double maxdelta, long maxdnom)
26 {
27 if (!nearestRational_(val, maxdelta, maxdnom)) {
28 numerator_ = 0;
29 denominator_ = 1;
30 }
31 };
32
33private:
36
37 bool nearestRational_(double val, double maxdelta, long maxdnom);
38};
39
40#endif
41
42/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
43*/
CoinRational(double val, double maxdelta, long maxdnom)
long getDenominator()
long getNumerator()
CoinRational(long n, long d)
bool nearestRational_(double val, double maxdelta, long maxdnom)