Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
global.h
Go to the documentation of this file.
1
30#pragma once
31
34
35#pragma GCC visibility push(default)
36namespace abacus {
37
38
40
59public:
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
101
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
270 int &param,
271 const char *name,
272 int minVal,
273 int maxVal) const;
274
277 unsigned &param,
278 const char *name,
279 unsigned minVal,
280 unsigned maxVal) const;
281
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
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
330 int &param,
331 const char *name,
332 int minVal,
333 int maxVal,
334 int defVal) const;
335
338 unsigned &param,
339 const char *name,
340 unsigned minVal,
341 unsigned maxVal,
342 unsigned defVal) const;
343
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
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
407private:
408
409 double eps_;
410
412
417
418 double infinity_;
419
421
424};
425
426}
427#pragma GCC visibility pop
Hash tables.
Definition hash.h:125
Global data and functions.
Definition global.h:58
void eps(double e)
Sets the zero tolerance to e.
Definition global.h:134
friend std::ostream & operator<<(std::ostream &out, const AbacusGlobal &rhs)
The output operator writes some of the data members to an ouput stream out.
int findParameter(const char *name, const char *feasible) const
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for descri...
virtual ~AbacusGlobal()
The destructor.
Definition global.h:88
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
void assignParameter(string &param, const char *name, unsigned nFeasible, const char *feasible[], const char *defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void machineEps(double e)
Sets the machine dependent zero tolerance to e.
Definition global.h:151
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
void assignParameter(string &param, const char *name, unsigned nFeasible=0, const char *feasible[]=nullptr) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
int findParameter(const char *name, unsigned nFeasible, const int *feasible) const
Searches for parameter name in the parameter table.
void assignParameter(double &param, const char *name, double minVal, double maxVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void assignParameter(unsigned &param, const char *name, unsigned minVal, unsigned maxVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
double infinity_
An "infinite" big number.
Definition global.h:418
int getParameter(const char *name, int &param) const
Searches for parameter name in the parameter table and returns its value in param.
void assignParameter(char &param, const char *name, const char *feasible, char defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void assignParameter(double &param, const char *name, double minVal, double maxVal, double defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
int getParameter(const char *name, double &param) const
void readParameters(const string &fileName)
Opens the parameter file fileName, reads all parameters, and inserts them in the parameter table.
void assignParameter(bool &param, const char *name) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
int getParameter(const char *name, char &param) const
void assignParameter(unsigned &param, const char *name, unsigned minVal, unsigned maxVal, unsigned defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
AbacusGlobal(double eps=1.0e-4, double machineEps=1.0e-7, double infinity=1.0e32)
The constructor.
Definition global.h:76
double eps() const
Returns the zero tolerance.
Definition global.h:128
int getParameter(const char *name, unsigned int &param) const
double infinity() const
Provides a floating point value of "infinite" size.
Definition global.h:160
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
int findParameter(const char *name, unsigned nFeasible, const char *feasible[]) const
See AbacusGlobal::findParameter(const char *name, unsigned nFeasible, const int *feasible) for descri...
void assignParameter(char &param, const char *name, const char *feasible=nullptr) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
AbaHash< string, string > paramTable_
Definition global.h:420
void assignParameter(int &param, const char *name, int minVal, int maxVal, int defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
void assignParameter(int &param, const char *name, int minVal, int maxVal) const
Searches for parameter name in the parameter table and returns its value in param.
bool isMinusInfinity(double x) const
Returns true if x is regarded as infinite small, false otherwise.
Definition global.h:188
int getParameter(const char *name, string &param) const
double eps_
A zero tolerance.
Definition global.h:409
bool isInfinity(double x) const
Returns true if x is regarded as "infinite" large, false otherwise.
Definition global.h:180
int getParameter(const char *name, bool &param) const
void insertParameter(const char *name, const char *value)
Inserts parameter name with value value into the parameter table.
void infinity(double x)
Sets the "infinite value" to x.
Definition global.h:173
AbacusGlobal(const AbacusGlobal &rhs)
void assignParameter(bool &param, const char *name, bool defVal) const
See AbacusGlobal::assignParameter(int&,const char*,int,int) for a description.
bool isInteger(double x, double eps) const
Returns whether the value x differs at most by eps from an integer value.
double machineEps() const
Provides a machine dependent zero tolerance.
Definition global.h:145
const AbacusGlobal & operator=(const AbacusGlobal &rhs)
Base class of all other classes of ABACUS.
Definition abacusroot.h:69
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
hash table.