Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

global.h
Go to the documentation of this file.
1 
30 #pragma once
31 
33 #include <ogdf/lib/abacus/hash.h>
34 
35 namespace abacus {
36 
37 
39 
58 public:
59 
61 
76  double eps = 1.0e-4,
77  double machineEps = 1.0e-7,
78  double infinity = 1.0e32) :
79  eps_(eps),
80  machineEps_(machineEps),
81  infinity_(infinity),
82  paramTable_(100)
83  {
84  }
85 
87  virtual ~AbacusGlobal() {};
88 
90 
96  friend OGDF_EXPORT std::ostream &operator<<(std::ostream &out, const AbacusGlobal &rhs);
97 
98 #if 0
99 
108 #if 0
109  virtual AbaOStream& lout() const;
110 #endif
111 
113 
121 #if 0
122  virtual AbaOStream& fout() const;
123 #endif
124 #endif
125 
127  double eps() const { return eps_; }
128 
130 
133  void eps(double e) { eps_ = e; }
134 
136 
144  double machineEps() const { return machineEps_; }
145 
147 
150  void machineEps(double e) { machineEps_ = e; }
151 
153 
159  double infinity() const {
160  return infinity_;
161  }
162 
164 
172  void infinity(double x) { infinity_ = x; }
173 
174 
176 
179  bool isInfinity(double x) const {
180  return ( x >= infinity_ );
181  }
182 
184 
187  bool isMinusInfinity(double x) const {
188  return ( x <= -infinity_ );
189  }
190 
192 
196  bool equal(double x, double y) const {
197  return ( fabs(x-y) < machineEps_ );
198  }
199 
200 
202  bool isInteger(double x) const {
203  return isInteger(x, machineEps_);
204  }
205 
207  bool isInteger(double x, double eps) const;
208 
210 
215  void readParameters(const string &fileName);
216 
218 
224  void insertParameter(const char *name, const char *value);
225 
227 
238  int getParameter(const char *name, int &param) const;
239  int getParameter(const char *name, unsigned int &param) const;
240  int getParameter(const char *name, double &param) const;
241  int getParameter(const char *name, string &param) const;
242  int getParameter(const char *name, bool &param) const;
243  int getParameter(const char *name, char &param) const;
244 
246 
268  void assignParameter (
269  int &param,
270  const char *name,
271  int minVal,
272  int maxVal) const;
273 
275  void assignParameter (
276  unsigned &param,
277  const char *name,
278  unsigned minVal,
279  unsigned maxVal) const;
280 
282  void assignParameter (
283  double &param,
284  const char *name,
285  double minVal,
286  double maxVal) const;
287 
289  void assignParameter(bool &param, const char *name) const;
290 
292 
301  void assignParameter(
302  string &param,
303  const char *name,
304  unsigned nFeasible = 0,
305  const char *feasible[] = nullptr) const;
306 
308 
314  void assignParameter(char &param, const char *name,
315  const char *feasible=nullptr) const;
316 
318 
328  void assignParameter(
329  int &param,
330  const char *name,
331  int minVal,
332  int maxVal,
333  int defVal) const;
334 
336  void assignParameter(
337  unsigned &param,
338  const char *name,
339  unsigned minVal,
340  unsigned maxVal,
341  unsigned defVal) const;
342 
344  void assignParameter(
345  double &param,
346  const char *name,
347  double minVal,
348  double maxVal,
349  double defVal) const;
350 
352  void assignParameter(bool &param, const char *name, bool defVal) const;
353 
355 
365  void assignParameter(
366  string &param,
367  const char *name,
368  unsigned nFeasible,
369  const char *feasible[],
370  const char *defVal) const;
371 
373 
379  void assignParameter(char &param, const char *name,
380  const char *feasible, char defVal) const;
381 
383 
397  int findParameter(const char *name, unsigned nFeasible, const int *feasible) const;
398 
400  int findParameter(const char *name,
401  unsigned nFeasible, const char *feasible[]) const;
402 
404  int findParameter(const char *name,const char *feasible) const;
405 
406 private:
407 
408  double eps_;
409 
411 
415  double machineEps_;
416 
417  double infinity_;
418 
420 
421  AbacusGlobal(const AbacusGlobal &rhs);
422  const AbacusGlobal &operator=(const AbacusGlobal &rhs);
423 };
424 
425 }
abacus::AbacusGlobal::machineEps
double machineEps() const
Provides a machine dependent zero tolerance.
Definition: global.h:144
abacus::AbacusGlobal::eps
double eps() const
Returns the zero tolerance.
Definition: global.h:127
ogdf::matching_blossom::infinity
TWeight infinity()
Helper function to get the maximum value for a given weight type.
Definition: utils.h:46
abacus::operator<<
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)
abacus::AbacusGlobal::isInteger
bool isInteger(double x) const
Returns whether the value x differs at most by the machine dependent zero tolerance from an integer v...
Definition: global.h:202
abacusroot.h
abacus::AbacusGlobal::machineEps
void machineEps(double e)
Sets the machine dependent zero tolerance to e.
Definition: global.h:150
abacus
Definition: ILPClusterPlanarity.h:50
abacus::AbacusGlobal::eps
void eps(double e)
Sets the zero tolerance to e.
Definition: global.h:133
abacus::AbacusGlobal::machineEps_
double machineEps_
The machine dependent zero tolerance, which is used to , e.g., to test if a floating point value is 0...
Definition: global.h:415
abacus::AbacusGlobal::~AbacusGlobal
virtual ~AbacusGlobal()
The destructor.
Definition: global.h:87
abacus::AbacusRoot
Base class of all other classes of ABACUS.
Definition: abacusroot.h:68
abacus::AbacusGlobal::infinity_
double infinity_
An "infinite" big number.
Definition: global.h:417
abacus::AbaHash< string, string >
abacus::AbacusGlobal::paramTable_
AbaHash< string, string > paramTable_
Definition: global.h:419
abacus::AbacusGlobal::AbacusGlobal
AbacusGlobal(double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e32)
The constructor.
Definition: global.h:75
abacus::AbacusGlobal::isInfinity
bool isInfinity(double x) const
Returns true if x is regarded as "infinite" large, false otherwise.
Definition: global.h:179
abacus::AbacusGlobal::infinity
void infinity(double x)
Sets the "infinite value" to x.
Definition: global.h:172
abacus::AbacusGlobal::infinity
double infinity() const
Provides a floating point value of "infinite" size.
Definition: global.h:159
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
hash.h
hash table.
abacus::AbacusGlobal::equal
bool equal(double x, double y) const
Returns whether the absolute difference between x and y is less than the machine dependent zero toler...
Definition: global.h:196
abacus::AbacusGlobal::eps_
double eps_
A zero tolerance.
Definition: global.h:408
abacus::AbacusGlobal
Global data and functions.
Definition: global.h:57
abacus::AbacusGlobal::isMinusInfinity
bool isMinusInfinity(double x) const
Returns true if x is regarded as infinite small, false otherwise.
Definition: global.h:187