Machine Learning Library
Macros | Functions
Macros.h File Reference
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <CObject.h>

Go to the source code of this file.

Macros

#define INFINITY   HUGE_VAL
 
#define MSG(x)   {cout << x << endl;}
 
#define ABS(x)   ( ((x) < 0) ? -(x) : (x))
 
#define SIGN(x)   ( ((x) < 0) ? -1 : +1)
 
#define MAX(x, y)   ( ((x) > (y)) ? (x) : (y))
 
#define MIN(x, y)   ( ((x) < (y)) ? (x) : (y))
 
#define IRAND(x, y)   ((x) + (int)(((float) (y - x)) * rand()/(RAND_MAX+1.0)))
 
#define ML_NAN_CHK(var)   if(!isnan(var)) {cerr << "ML_NAN_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "!= NAN" << endl; abort();}
 
#define ML_NOT_NAN_CHK(var)   if(isnan(var)) {cerr << "ML_NOT_NAN_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "== NAN" << endl; abort();}
 
#define ML_NULL_CHK(var)   if((var) != NULL) {cerr << "ML_NULL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "!= NULL" << endl; abort();}
 
#define ML_NOT_NULL_CHK(var)   if((var) == NULL) {cerr << "ML_NOT_NULL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "== NULL" << endl; abort();}
 
#define ML_BOOL_CHK(var)   if(!(var)) {cerr << "ML_BOOL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << endl; abort();}
 
#define ML_LS_CHK(var, val)   if((var) >= (val)) {cerr << "ML_LS_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " >= " << val << endl; abort();}
 
#define ML_LEQ_CHK(var, val)   if((var) > (val)) {cerr << "ML_LEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " > " << val << endl; abort();}
 
#define ML_GR_CHK(var, val)   if((var) <= (val)) {cerr << "ML_GR_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " <= " << val << endl; abort();}
 
#define ML_GEQ_CHK(var, val)   if((var) < (val)) {cerr << "ML_GEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " < " << val << endl; abort();}
 
#define ML_EQ_CHK(var, val)   if((var) != (val)) {cerr << "ML_EQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " != " << val << endl; abort();}
 
#define ML_NEQ_CHK(var, val)   if((var) == (val)) {cerr << "ML_NEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " == " << val << endl; abort();}
 
#define ML_RANGE_CHK(var, lower, upper)   if((var)<(lower) && (var)>(upper)) {cerr << "ML_RANGE_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " out of range ["<<lower <<","<<upper<<"]" << endl; abort();}
 
#define ML_WARNING_MSG(x)   {cerr << "ML_WARNING_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; cerr << endl;}
 
#define ML_CRITICAL_MSG(x)   {cerr << "ML_CRITICAL_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; abort();}
 
#define ML_MSG(x)   {cerr << "ML_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; cerr << endl;}
 

Functions

template<class Type >
void readValueOfType (Type &rtValue, fstream &stream, DATATYPE tType)
 
template<class Type >
Type getRank (int iRank, int iDim, Type *pfVector)
 
template<class Type >
void nDimFor (const vector< Type > &rvtStart, const vector< Type > &rvtEnd, vector< Type > &rvtIndices, bool bInit)
 
template<class Type >
void nDimForReverse (const vector< Type > &rvtStart, const vector< Type > &rvtEnd, vector< Type > &rvtIndices, bool bInit)
 
double gammln (double xx)
 
double factrl (int n)
 
double factln (int n)
 
double bico (int n, int k)
 
float gauss_rnd (void)
 
void init_rnd_seed ()
 

Macro Definition Documentation

#define ABS (   x)    ( ((x) < 0) ? -(x) : (x))
#define INFINITY   HUGE_VAL
#define IRAND (   x,
 
)    ((x) + (int)(((float) (y - x)) * rand()/(RAND_MAX+1.0)))
#define MAX (   x,
 
)    ( ((x) > (y)) ? (x) : (y))
#define MIN (   x,
 
)    ( ((x) < (y)) ? (x) : (y))
#define ML_BOOL_CHK (   var)    if(!(var)) {cerr << "ML_BOOL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << endl; abort();}
#define ML_CRITICAL_MSG (   x)    {cerr << "ML_CRITICAL_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; abort();}
#define ML_EQ_CHK (   var,
  val 
)    if((var) != (val)) {cerr << "ML_EQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " != " << val << endl; abort();}
#define ML_GEQ_CHK (   var,
  val 
)    if((var) < (val)) {cerr << "ML_GEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " < " << val << endl; abort();}
#define ML_GR_CHK (   var,
  val 
)    if((var) <= (val)) {cerr << "ML_GR_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " <= " << val << endl; abort();}
#define ML_LEQ_CHK (   var,
  val 
)    if((var) > (val)) {cerr << "ML_LEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " > " << val << endl; abort();}
#define ML_LS_CHK (   var,
  val 
)    if((var) >= (val)) {cerr << "ML_LS_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " >= " << val << endl; abort();}
#define ML_MSG (   x)    {cerr << "ML_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; cerr << endl;}
#define ML_NAN_CHK (   var)    if(!isnan(var)) {cerr << "ML_NAN_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "!= NAN" << endl; abort();}

Macros for error handling

#define ML_NEQ_CHK (   var,
  val 
)    if((var) == (val)) {cerr << "ML_NEQ_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " == " << val << endl; abort();}
#define ML_NOT_NAN_CHK (   var)    if(isnan(var)) {cerr << "ML_NOT_NAN_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "== NAN" << endl; abort();}
#define ML_NOT_NULL_CHK (   var)    if((var) == NULL) {cerr << "ML_NOT_NULL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "== NULL" << endl; abort();}
#define ML_NULL_CHK (   var)    if((var) != NULL) {cerr << "ML_NULL_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "!= NULL" << endl; abort();}
#define ML_RANGE_CHK (   var,
  lower,
  upper 
)    if((var)<(lower) && (var)>(upper)) {cerr << "ML_RANGE_CHK failed in File: " << __FILE__ << " Line: " << __LINE__ << ". " << #var << "=" << var << " out of range ["<<lower <<","<<upper<<"]" << endl; abort();}
#define ML_WARNING_MSG (   x)    {cerr << "ML_WARNING_MSG in File: " << __FILE__ << " Line: " << __LINE__ << endl << x << endl << endl; cerr << endl;}
#define MSG (   x)    {cout << x << endl;}
#define SIGN (   x)    ( ((x) < 0) ? -1 : +1)

Function Documentation

double bico ( int  n,
int  k 
)
double factln ( int  n)
double factrl ( int  n)
double gammln ( double  xx)

Math functions

float gauss_rnd ( void  )
template<class Type >
Type getRank ( int  iRank,
int  iDim,
Type *  pfVector 
)

returns value of element with rank iRank in the given array. NOTE: The sorting of the array values will be changed!

void init_rnd_seed ( )
template<class Type >
void nDimFor ( const vector< Type > &  rvtStart,
const vector< Type > &  rvtEnd,
vector< Type > &  rvtIndices,
bool  bInit 
)

Simulates nested for-loops. After a call with bInit=True, each function call increments rvtIndices according to an iteration of nested loops with a range from rvtStart to rtvEnd (including). The incrementation begins with rvtIndices[0].

Parameters
rvtStartstart values for all loops.
rvtEndend values for all loops.
rvtIndicesvalues for the actual iteration.
bInitinitializes the loop
template<class Type >
void nDimForReverse ( const vector< Type > &  rvtStart,
const vector< Type > &  rvtEnd,
vector< Type > &  rvtIndices,
bool  bInit 
)
template<class Type >
void readValueOfType ( Type &  rtValue,
fstream &  stream,
DATATYPE  tType 
)

References DOUBLE, FLOAT, and INT.