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 #pragma GCC visibility push(default)
36 namespace abacus {
37 
38 
40 
59 public:
60 
62 
77  double eps = 1.0e-4,
78  double machineEps = 1.0e-7,
79  double infinity = 1.0e32) :
80  eps_(eps),
81  machineEps_(machineEps),
82  infinity_(infinity),
83  paramTable_(100)
84  {
85  }
86 
88  virtual ~AbacusGlobal() {};
89 
91 
97  friend OGDF_EXPORT std::ostream &operator<<(std::ostream &out, const AbacusGlobal &rhs);
98 
99 #if 0
100 
109 #if 0
110  virtual AbaOStream& lout() const;
111 #endif
112 
114 
122 #if 0
123  virtual AbaOStream& fout() const;
124 #endif
125 #endif
126 
128  double eps() const { return eps_; }
129 
131 
134  void eps(double e) { eps_ = e; }
135 
137 
145  double machineEps() const { return machineEps_; }
146 
148 
151  void machineEps(double e) { machineEps_ = e; }
152 
154 
160  double infinity() const {
161  return infinity_;
162  }
163 
165 
173  void infinity(double x) { infinity_ = x; }
174 
175 
177 
180  bool isInfinity(double x) const {
181  return ( x >= infinity_ );
182  }
183 
185 
188  bool isMinusInfinity(double x) const {
189  return ( x <= -infinity_ );
190  }
191 
193 
197  bool equal(double x, double y) const {
198  return ( fabs(x-y) < machineEps_ );
199  }
200 
201 
203  bool isInteger(double x) const {
204  return isInteger(x, machineEps_);
205  }
206 
208  bool isInteger(double x, double eps) const;
209 
211 
216  void readParameters(const string &fileName);
217 
219 
225  void insertParameter(const char *name, const char *value);
226 
228 
239  int getParameter(const char *name, int &param) const;
240  int getParameter(const char *name, unsigned int &param) const;
241  int getParameter(const char *name, double &param) const;
242  int getParameter(const char *name, string &param) const;
243  int getParameter(const char *name, bool &param) const;
244  int getParameter(const char *name, char &param) const;
245 
247 
269  void assignParameter (
270  int &param,
271  const char *name,
272  int minVal,
273  int maxVal) const;
274 
276  void assignParameter (
277  unsigned &param,
278  const char *name,
279  unsigned minVal,
280  unsigned maxVal) const;
281 
283  void assignParameter (
284  double &param,
285  const char *name,
286  double minVal,
287  double maxVal) const;
288 
290  void assignParameter(bool &param, const char *name) const;
291 
293 
302  void assignParameter(
303  string &param,
304  const char *name,
305  unsigned nFeasible = 0,
306  const char *feasible[] = nullptr) const;
307 
309 
315  void assignParameter(char &param, const char *name,
316  const char *feasible=nullptr) const;
317 
319 
329  void assignParameter(
330  int &param,
331  const char *name,
332  int minVal,
333  int maxVal,
334  int defVal) const;
335 
337  void assignParameter(
338  unsigned &param,
339  const char *name,
340  unsigned minVal,
341  unsigned maxVal,
342  unsigned defVal) const;
343 
345  void assignParameter(
346  double &param,
347  const char *name,
348  double minVal,
349  double maxVal,
350  double defVal) const;
351 
353  void assignParameter(bool &param, const char *name, bool defVal) const;
354 
356 
366  void assignParameter(
367  string &param,
368  const char *name,
369  unsigned nFeasible,
370  const char *feasible[],
371  const char *defVal) const;
372 
374 
380  void assignParameter(char &param, const char *name,
381  const char *feasible, char defVal) const;
382 
384 
398  int findParameter(const char *name, unsigned nFeasible, const int *feasible) const;
399 
401  int findParameter(const char *name,
402  unsigned nFeasible, const char *feasible[]) const;
403 
405  int findParameter(const char *name,const char *feasible) const;
406 
407 private:
408 
409  double eps_;
410 
412 
416  double machineEps_;
417 
418  double infinity_;
419 
421 
422  AbacusGlobal(const AbacusGlobal &rhs);
423  const AbacusGlobal &operator=(const AbacusGlobal &rhs);
424 };
425 
426 }
427 #pragma GCC visibility pop
abacus::AbacusGlobal::machineEps
double machineEps() const
Provides a machine dependent zero tolerance.
Definition: global.h:145
abacus::AbacusGlobal::eps
double eps() const
Returns the zero tolerance.
Definition: global.h:128
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:203
abacusroot.h
abacus::AbacusGlobal::machineEps
void machineEps(double e)
Sets the machine dependent zero tolerance to e.
Definition: global.h:151
abacus
Definition: ILPClusterPlanarity.h:50
abacus::AbacusGlobal::eps
void eps(double e)
Sets the zero tolerance to e.
Definition: global.h:134
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:416
abacus::AbacusGlobal::~AbacusGlobal
virtual ~AbacusGlobal()
The destructor.
Definition: global.h:88
abacus::AbacusRoot
Base class of all other classes of ABACUS.
Definition: abacusroot.h:69
abacus::AbacusGlobal::infinity_
double infinity_
An "infinite" big number.
Definition: global.h:418
abacus::AbaHash< string, string >
abacus::AbacusGlobal::paramTable_
AbaHash< string, string > paramTable_
Definition: global.h:420
abacus::AbacusGlobal::AbacusGlobal
AbacusGlobal(double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e32)
The constructor.
Definition: global.h:76
abacus::AbacusGlobal::isInfinity
bool isInfinity(double x) const
Returns true if x is regarded as "infinite" large, false otherwise.
Definition: global.h:180
abacus::AbacusGlobal::infinity
void infinity(double x)
Sets the "infinite value" to x.
Definition: global.h:173
abacus::AbacusGlobal::infinity
double infinity() const
Provides a floating point value of "infinite" size.
Definition: global.h:160
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition: config.h:117
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:197
abacus::AbacusGlobal::eps_
double eps_
A zero tolerance.
Definition: global.h:409
abacus::AbacusGlobal
Global data and functions.
Definition: global.h:58
abacus::AbacusGlobal::isMinusInfinity
bool isMinusInfinity(double x) const
Returns true if x is regarded as infinite small, false otherwise.
Definition: global.h:188