Osi 0.107.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
14 public :
15 long getDenominator() { return denominator_; }
16 long getNumerator() { return numerator_; }
17
18 CoinRational():
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_;
39 long denominator_;
40
41 bool nearestRational_(double val, double maxdelta, long maxdnom);
42 };
43
44 #endif
CoinRational
Definition: CoinRational.hpp:11
CoinRational::CoinRational
CoinRational()
Definition: CoinRational.hpp:18
CoinRational::nearestRational_
bool nearestRational_(double val, double maxdelta, long maxdnom)
CoinRational::getDenominator
long getDenominator()
Definition: CoinRational.hpp:15
CoinRational::getNumerator
long getNumerator()
Definition: CoinRational.hpp:16
CoinRational::numerator_
long numerator_
Definition: CoinRational.hpp:34
CoinRational::CoinRational
CoinRational(double val, double maxdelta, long maxdnom)
Definition: CoinRational.hpp:28
CoinRational::CoinRational
CoinRational(long n, long d)
Definition: CoinRational.hpp:23
CoinRational::denominator_
long denominator_
Definition: CoinRational.hpp:39