⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcommon.hpp

📁 这是个人脸识别程序
💻 HPP
字号:
// $common\mcommon.hpp 1.5 milbo$ bits and pieces needed all over the place// Warning: this is raw research code -- expect it to be quite messy.// milbo dec05 durban#if !defined(mcommon_hpp)#define mcommon_hpp#include <float.h>#define SLEN    	256		// generic string length#define PLEN    	128		// a more reasonable string length, used for path lengths etc.#define FLEN		64		// short string len, used for file base name len (without path) etc.#define CONF_nMaxPrintfLen 10000	// big enough for big printfs#define PI       	3.141592653589793238462643#define SHAPE		Mat		// convention to indicate that this is a Nx2 matrix holding a shape#define ShapeVec	MatVec	// convention to indicate that this is a vector of Nx2 matrices holding shapes#define IntVec  cvec<int>	// we use a define not a typedef so don't have to include STL header files everywhere#define BoolVec cvec<bool>#define CharVec cvec<char>#define _float double		// define this to float or double for the base type of neural nets// DASSERT is only enabled if debugging, ASSERT is always enabled.// Use DASSERT when the release code must be fast.#if _DEBUG#define DASSERT(x) 	if (!(x)) SysErr("%s %d: FAIL %s", __FILE__, __LINE__, #x)#else#define DASSERT(x)#endif#define ASSERT(x) 	if (!(x)) SysErr("%s %d: FAIL %s", __FILE__, __LINE__, #x)#define IF_ELSEN(a,b)		((a)?(b):NULL)	// macro for conditional compilation of function parameters#define fSet(Bits, Mask)	(((Bits) & (Mask)) != 0)#define fClr(Bits, Mask)	(((Bits) & (Mask)) == 0)#define fOdd(ix)			(((ix)&1)==1)	// 1 if ix is odd, 0 if ix is even#define fEven(ix)			(((ix)&1)==0)#define Pow12(x) 			pow(1.2, (x))#define ABS(x)				(((x)<0)?-(x):(x))#define SQR(x) 				((x)*(x))#define EnterDebugger		*(int *)100 = 0				// abort() doesn't always work, hence this macro#define NBR_ELEMS(A)		(sizeof(A)/sizeof(A[0]))	// number of elements in an array#pragma warning(disable:4786)				// MSC specific: disable warnings about extremely long variable names in STLstatic const bool NO_EXIT_ON_ERR = false;	// values for fExitOnErrstatic const bool EXIT_ON_ERR	 = true;static const bool QUIET   = false;			// values for fVerbosestatic const bool VERBOSE = true;// inline routines have to be in the header file to be seen by microsoft linkerstatic inline double Degrees (double Radians) { return 360 * Radians / (2 * PI); }static inline double Radians (double Degrees) { return 2 * PI * Degrees / 360; }// true if x is positive or 0static inline bool fPos (double x) { return x >= 0; }// iRound() is "symmetrical" in that e.g. 1.5 becomes 1 and -1.5 becomes -1static inline int iRound (double x) { if (x < 0) return (int)(x - 0.5); else return (int)(x + 0.5); }// fEqual () returns true if x == y within reasonable tolerance// If one or both of the numbers are NANs then the test fails (even if they// are equal NANs).//// I'm just doing a straight comparism because gsl_fcmp() tests ratios and// is not useful for small numbers (because two small numbers can be close// in absolute value but far in ratio).//// But I added the _isnan tests because the microsoft v6 compiler says NANs// are equal to anything and also less than anything i.e NAN==x and NAN<x are true// for any double x.  This is a compiler bug I believe.static inline bool fEqual (double x, double y, double MaxDiff=1e-10) { return !_isnan(x) && !_isnan(y) && ABS(x-y) < MaxDiff; }static inline bool fGeq (double x, double y, double Range)  // x >= y{ if (_isnan(x) || _isnan(y)) return false; return x >= y - Range; }static inline bool fLeq (double x, double y, double Range)		// x <= y{ if (_isnan(x) || _isnan(y)) return false; return x - Range <= y; }#if 0	// routines for tracing fopen/fclosestatic FILE *fopenTrace (const char *sPath, const char *sMode){ FILE *pFile=fopen(sPath, sMode); if (pFile) printf("\n%x fopen %s %s\n", pFile, sPath, sMode); return pFile; }static int fcloseTrace (FILE *pFile){ printf("\n%x fclose\n", pFile); return fclose(pFile); }#define fopen(sPath, sMode)  fopenTrace(sPath, sMode);#define fclose(pFile) 		 fcloseTrace(pFile);#endifvoid __cdecl Warn(const char *pArgs, ...);		// args like printfvoid __cdecl SysErr(const char *pArgs, ...);void __cdecl Err(const char *pArgs, ...);void __cdecl lprintf(const char *pArgs, ...);#endif	// mcommon_hpp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -