Cgl 0.60.2

- 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 public:
14 long getDenominator() { return denominator_; }
15 long getNumerator() { return numerator_; }
16
17 CoinRational()
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_;
35 long denominator_;
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
Definition: CoinRational.hpp:11
CoinRational::CoinRational
CoinRational()
Definition: CoinRational.hpp:17
CoinRational::nearestRational_
bool nearestRational_(double val, double maxdelta, long maxdnom)
CoinRational::getDenominator
long getDenominator()
Definition: CoinRational.hpp:14
CoinRational::getNumerator
long getNumerator()
Definition: CoinRational.hpp:15
CoinRational::numerator_
long numerator_
Definition: CoinRational.hpp:31
CoinRational::CoinRational
CoinRational(double val, double maxdelta, long maxdnom)
Definition: CoinRational.hpp:25
CoinRational::CoinRational
CoinRational(long n, long d)
Definition: CoinRational.hpp:21
CoinRational::denominator_
long denominator_
Definition: CoinRational.hpp:35