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 {
13 
14 public :
15  long getDenominator() { return denominator_; }
16  long getNumerator() { return numerator_; }
17 
19  numerator_(0),
20  denominator_(1)
21  {};
22 
23  CoinRational(long n, long d):
24  numerator_(n),
25  denominator_(d)
26  {};
27 
28  CoinRational(double val, double maxdelta, long maxdnom)
29  {
30  if (!nearestRational_(val, maxdelta, maxdnom)){
31  numerator_ = 0;
32  denominator_ = 1;
33  }
34  };
35 
36 private :
37 
38  long numerator_;
40 
41  bool nearestRational_(double val, double maxdelta, long maxdnom);
42 };
43 
44 #endif
CoinRational(long n, long d)
CoinRational(double val, double maxdelta, long maxdnom)
bool nearestRational_(double val, double maxdelta, long maxdnom)
long getNumerator()
long getDenominator()