Cgl  0.60.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
11 class CoinRational {
12 
13 public:
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 
33 private:
34  long numerator_;
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 */
bool nearestRational_(double val, double maxdelta, long maxdnom)
long getDenominator()
long getNumerator()
CoinRational(double val, double maxdelta, long maxdnom)
CoinRational(long n, long d)