std.h File Reference
Detailed Description
My base file: contains a bunch of standard includes, macros, operators, etc. that are used by most other headers.
Definition in file std.h.
Go to the source code of this file.
Namespaces
Classes
Defines
-
#define DOX !\brief
-
#define MT_MSG(msg) { std::cerr <<__FILE__ <<':' <<__LINE__ <<": " <<msg <<std::endl; }
-
#define HALT(msg)
-
#define CHECK(cond, msg) if(!(cond)) HALT("CHECK failed: "<<msg);
-
#define MT_PI 3.14159265358979323846
-
#define MT_2PI (2.*3.14159265358979323846)
-
#define MT_LN2 0.69314718055994528622676398299518041312694549560546875
-
#define forall(i, a) for(a.First(i) ;a.CheckNext(i); a.Next(i))
-
#define forall_rev(i, a) for(a.Last(i) ;a.CheckPrev(i); a.Prev(i))
-
#define forall_save(i, j, a) for(a.First(i),j=i,a.Next(j);a.CheckNext(i);i=j,a.Next(j))
-
#define forall_rev_save(i, j, a) for(a.Last(i) ,j=i,a.Prev(j);a.CheckPrev(i);i=j,a.Prev(j))
-
#define stdInPipe(type) inline std::istream& operator>>(std::istream& is,type& x){ x.read(is);return is; }
-
#define stdOutPipe(type) inline std::ostream& operator<<(std::ostream& os,const type& x){ x.write(os); return os; }
-
#define stdPipes(type)
-
#define fwdStdPipes(type)
-
#define OUTHEX(y) "0x" <<std::hex <<*((unsigned long*)&y) <<std::dec
-
#define INHEX(y) std::hex >>*((unsigned long*)&y) >>std::dec
-
#define STRING(x) ((MT::String&)(MT::String().str()<<x)).ptr()
Typedefs
-
typedef unsigned char byte
- byte
-
typedef unsigned int uint
- unsigned integer
-
typedef void(* voidFct )()
- pointer to a void function
-
typedef std::iostream MT::IOStream
Functions
-
int MT::debugBreakpoint ()
-
char MT::skip (std::istream &is, char *skipchars)
- skips the chars (typically white characters) when parsing from the istream
-
std::istream & operator>> (std::istream &is, const char *str)
- a global operator to scan (parse) strings from a stream
-
std::istream & operator>> (std::istream &is, char *str)
- the same global operator for non-const string
-
std::ofstream & MT::log (const char *name="MT.log", bool _nolog=false)
- access to the log-file
-
void MT::open (std::ofstream &fs, const char *name, char *errmsg="")
- open an output-file with name '
name'
-
void MT::open (std::ifstream &fs, const char *name, char *errmsg="")
- open an input-file with name '
name'
-
template<class T> void MT::save (const T &x, const char *filename)
- a standard method to save an object into a file. The same as std::ofstream file; MT::open(file,filename); file <<x; file.close();
-
template<class T> void MT::load (T &x, const char *filename)
- a standard method to load object from a file. The same as std::ifstream file; MT::open(file,filename); file >>x; file.close();
-
bool MT::contains (const char *s, char c)
- returns true if the (0-terminated) string s contains c
-
void MT::skipLine (std::istream &is)
- skips a newline character (same as skip(is,"\n");)
-
byte MT::bit (byte *str, uint i)
- returns the i-th of str
-
void MT::flip (byte &b, uint i)
- flips the i-th bit of b
-
void MT::flip (int &b, uint i)
- filps the i-th bit of b
-
double MT::modMetric (double x, double y, double mod)
- the distance between x and y w.r.t. a circular topology (e.g. modMetric(1,8,10)=3)
-
double MT::sign (double x)
- the sign (+/-1) of x (+1 for zero)
-
double MT::linsig (double x)
- returns 0 for x<0, 1 for x>1, x for 0<x<1
-
float MT::phi (float dx, float dy)
- the angle of the vector (dx,dy) in [-pi,pi]
-
double MT::DIV (double x, double y, bool force=false)
- save division, checks for division by zero; force=true will return zero if y=0
-
double MT::sigmoid11 (double x)
-
template<class T> T MT::MIN (T a, T b)
-
template<class T> T MT::MAX (T a, T b)
-
double MT::approxExp (double x)
- approximate exp (sets up a static value table)
-
double MT::Log (double x)
- ordinary Log, but cutting off for small values
-
uint MT::Log2 (uint n)
- integer log2
-
double MT::sqr (double x)
- square of a double
-
double MT::realTime ()
- real time since start of the process in floating-point seconds (probably in micro second resolution) -- Windows checked!
-
double MT::cpuTime ()
- user CPU time of this process in floating-point seconds (pure processor time) -- Windows checked!
-
double MT::sysTime ()
- system CPU time of this process in floating-point seconds (the time spend for file input/output, x-server stuff, etc.) -- not implemented for Windows!
-
double MT::totalTime ()
- total CPU time of this process in floating-point seconds (same as cpuTime + sysTime) -- not implemented for Windows!
-
char * MT::date ()
- the absolute real time and date as string
-
void MT::wait (double sec)
- wait real time
-
void MT::wait ()
- wait for an ENTER at the console
-
long MT::mem ()
- the integral shared memory size -- not implemented for Windows!
-
void MT::resetTimer ()
- push reset on the stop watch (user CPU time)
-
double MT::getTimer (bool reset=true)
- read the stop watch (user CPU time)
-
void MT::init (int _argc, char *_argv[])
- memorize the command line arguments and open a log file
-
bool MT::checkOption (const char *tag)
- returns false if command-line option
-tag
was not found
-
bool MT::getOption (const char *tag, char *&option)
- returns false if command-line option
-tag
was not found
-
void MT::openConfigFile (char *name=0)
- Open a (possibly new) config file with name '
name'
.
If name
is not specified, it searches for a command line-option '-cfg' and, if not found, it assumes name=MT
.cfg.
-
void MT::initQt ()
- create a Qt application
Variables
[]