/**------------------------------------------------------------------------
 * @file
 *
 * Copyright 2001 by the University of Toronto (UT).
 *
 *                       All Rights Reserved
 * 
 * Permission to copy and modify this software and its documentation 
 * only for internal use in your organization is hereby granted, 
 * provided that this notice is retained thereon and on all copies.  
 * UT makes no representations as to the suitability and operability 
 * of this software for any purpose.  It is provided "as is" without 
 * express or implied warranty.
 *
 * UT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
 * SHALL UT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * No other rights, including for example, the right to redistribute 
 * this software and its documentation or the right to prepare 
 * derivative works, are granted unless specifically provided in a 
 * separate license agreement.
 *
 * Author: Diego Macrini based on Ali Shokoufandeh's original code
 * 
 * $Log: HelperFunctions.h,v $
 * Revision 1.4  2002/06/17 23:09:46  dmac
 * Class LogFile added.
 *
 * Revision 1.3  2002/06/10 18:39:46  dmac
 * PRINT functions added.
 *
 * Revision 1.2  2002/05/16 22:50:09  dmac
 * Several bugs fixed and a new DAG-derived class added
 *
 * Revision 1.1.1.1  2002/03/10 07:38:07  dmac
 * Imported sources
 *
 *
 *-----------------------------------------------------------------------*/

#ifndef __HELPER_FUNCTIONS_H__
#define __HELPER_FUNCTIONS_H__

#include "BasicUtils.h"

#include <fstream>

/*#ifdef WIN32
#define isnan  _isnan
#define finite _finite
#endif

#include <fstream>

// Infinity is a million. i.e. a rather big value easy to identify
#ifndef INFINITY
#define INFINITY	1000000
#endif

#define round(x) ( x < 0 ? -(int)(0.5-x) : (int)(x+0.5) )

#define MIN(X, Y) ( (X) <= (Y) ? (X):(Y) )
#define MAX(X, Y) ( (X) >= (Y) ? (X):(Y) )

#define NORM2(X, Y) std::sqrt ((X)*(X) + (Y)*(Y))

#define SIGN(X) ((X) == 0.0 ? 0:int((X) / fabs(X)))

#define PRINT(OS, EXP)	OS << #EXP << ": " << EXP << ", "
#define PRINTN(OS, EXP)	OS << #EXP << ": " << EXP << endl

#define PRINT_OPEN(OS, EXP)	OS << '[' << #EXP << ": " << EXP << ", "
#define PRINT_CLOSE(OS, EXP) OS << #EXP << ": " << EXP << ']' << endl

#define ShowError(M) cerr << "\n\nERROR: " << M << endl
#define ShowMsg(M) cout << endl << M << endl*/

double SIMILARITY(double x, double y, const double& minVal = .1);

class LogFile : public std::fstream
{

public:
	LogFile() {}
	LogFile(const char* szFileName);
	void Print(const char* szFormat, ...);
};

#endif //__HELPER_FUNCTIONS_H__
