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

📄 tvmutil.h

📁 行人检测源程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// {{{ Copyright Notice// }}}// {{{ file documentation/** * @file  * @author Navneet Dalal * @brief Defines some useful utilities for TinyVector and TinyMatrix.  * * @warning Some functions may not be defined using blitz Expression Templates * and Meta Programming techniques. */// }}}#ifndef _LEAR_EXT_TVMUTILS_H_#define _LEAR_EXT_TVMUTILS_H_// {{{ headers#include <blitz/array.h>#include <blitz/tinyvec.h>#include <blitz/tinymat.h>// }}}BZ_NAMESPACE(blitz)//{{{ isInRange functionstemplate<class TypeA, class TypeB, class TypeC, int Rank>inline bool isInRange(        const TinyVector<TypeA, Rank>& p,         const TinyVector<TypeB, Rank>& cMin,         const TinyVector<TypeC, Rank>& cMax) {    for (int i= 0; i< Rank; ++i)         if (p[i] < cMin[i] || p[i] > cMax[i])            return false;    return true;}#define TMP_ISINRANGE(TYPE)                                                 \inline bool isInRange(const TYPE p, const TYPE cMin, const TYPE cMax){      \    if (p < cMin || p > cMax)                                               \            return false;                                                   \    return true;                                                            \} TMP_ISINRANGE(double)TMP_ISINRANGE(long double)TMP_ISINRANGE(float)TMP_ISINRANGE(int)TMP_ISINRANGE(unsigned int)TMP_ISINRANGE(short)TMP_ISINRANGE(unsigned short)TMP_ISINRANGE(long)TMP_ISINRANGE(unsigned long)TMP_ISINRANGE(char)TMP_ISINRANGE(unsigned char)#undef TMP_ISINRANGE//}}}// {{{ dot/*  * @def dot * @brief Enables dot to be called for blitz array. * * For e.g. if A , B and C are blitz arrays, and we want to call dot product for each element, * we can simply use this statment * A = dot(B,C); * instead of writing for loops. */// @{#define TMP_SUM(TYPE)           \inline double dot(const TYPE a, const TYPE b){  \    return a*b;                   \}TMP_SUM(double)TMP_SUM(long double)TMP_SUM(float)TMP_SUM(int)TMP_SUM(unsigned int)TMP_SUM(short)TMP_SUM(unsigned short)TMP_SUM(long)TMP_SUM(unsigned long)TMP_SUM(char)TMP_SUM(unsigned char)#undef TMP_SUMtemplate<class T>inline double dist(const T a) {    return dot(a,a);}BZ_DECLARE_FUNCTION2_RET(dot,double)BZ_DECLARE_FUNCTION_RET(dist,double)// }}}// template<class T, int N>// inline TinyVector<T,N> sqrt(const TinyVector<T,N>& a) {//     TinyVector<T,N> val;//     for (int i= 0; i<N ; ++i) //         val(i) = sqrt(a(i));//     return val;// }// BZ_DECLARE_FUNCTION_RET(dist,TinyVector<T,N>)// {{{ isEqual functions/**  * @defgroup isEqual_Functions Overloaded isEqual functions * @brief Defines isEqual function for int, double and TinyVector. * * isEqual compares element by element and returns true only if all elements are equal. * */// @{ #define TMP_ISEQUAL(TYPE)                                                  \inline bool isEqual(const TYPE a, const TYPE b) {                           \    return a == b;                                                          \}TMP_ISEQUAL(double)TMP_ISEQUAL(long double)TMP_ISEQUAL(float)TMP_ISEQUAL(int)TMP_ISEQUAL(unsigned int)TMP_ISEQUAL(short)TMP_ISEQUAL(unsigned short)TMP_ISEQUAL(long)TMP_ISEQUAL(unsigned long)TMP_ISEQUAL(char)TMP_ISEQUAL(unsigned char)#undef TMP_ISEQUALtemplate<class T1, class T2, int N>inline bool isEqual(const TinyVector<T1,N>&a, const TinyVector<T2,N>&b) {    for (int i= 0; i<N ; ++i)         if (a[i] != b[i])            return false;    return true;}BZ_DECLARE_FUNCTION2_RET(isEqual,bool)// @}// }}}// {{{ isNotEqual functions/**  * @defgroup isNotEqual Overloaded isNotEqual functions * @brief Defines isNotEqual function for int and TinyVector. * * isNotEqual compares element by element and returns true only if all elements are equal. * */// @{ #define TMP_ISNOTEQUAL(TYPE)                                                  \inline bool isNotEqual(const TYPE a, const TYPE b) {                           \    return a != b;                                                          \}TMP_ISNOTEQUAL(int)TMP_ISNOTEQUAL(unsigned int)TMP_ISNOTEQUAL(short)TMP_ISNOTEQUAL(unsigned short)TMP_ISNOTEQUAL(long)TMP_ISNOTEQUAL(unsigned long)TMP_ISNOTEQUAL(char)TMP_ISNOTEQUAL(unsigned char)#undef TMP_ISNOTEQUALtemplate<class T1, class T2, int N>inline bool isNotEqual(const TinyVector<T1,N>&a, const TinyVector<T2,N>&b) {    for (int i= 0; i<N ; ++i)         if (a[i] != b[i])            return true;    return false;}BZ_DECLARE_FUNCTION2_RET(isNotEqual,bool)// @}// }}}// {{{ isGreater functions/**  * @defgroup isGreater Overloaded isEqual functions * @brief Defines isGreater function for int, double and TinyVector. * * isGreater compares element by element and returns true only if all elements  * of a are are Greater than b. * */// @{ #define TMP_ISGREATER(TYPE)                                     \inline bool isGreater(const TYPE a, const TYPE b) {             \    return a > b;                                               \}TMP_ISGREATER(double)TMP_ISGREATER(long double)TMP_ISGREATER(float)TMP_ISGREATER(int)TMP_ISGREATER(unsigned int)TMP_ISGREATER(short)TMP_ISGREATER(unsigned short)TMP_ISGREATER(long)TMP_ISGREATER(unsigned long)TMP_ISGREATER(char)TMP_ISGREATER(unsigned char)#undef TMP_ISGREATERtemplate<class T1, class T2, int N>inline bool isGreater(const TinyVector<T1,N>&a, const TinyVector<T2,N>&b) {    for (int i= 0; i<N ; ++i)         if (a[i] <= b[i])            return false;    return true;}BZ_DECLARE_FUNCTION2_RET(isGreater,bool)// @}// }}}// {{{ isGreaterEqual functions/**  * @defgroup isGreaterEqual Overloaded isGreaterEqual functions * @brief Defines isGreaterEqual function for int, double and TinyVector. * * isGreaterEqual compares element by element and returns true only if all elements  * of a are GreaterEqual than b. * */// @{ #define TMP_ISGREATEREQUAL(TYPE)                                          \inline bool isGreaterEqual(const TYPE a, const TYPE b) {                  \    return a >= b;                                                         \}TMP_ISGREATEREQUAL(double)TMP_ISGREATEREQUAL(long double)TMP_ISGREATEREQUAL(float)TMP_ISGREATEREQUAL(int)TMP_ISGREATEREQUAL(unsigned int)TMP_ISGREATEREQUAL(short)TMP_ISGREATEREQUAL(unsigned short)TMP_ISGREATEREQUAL(long)TMP_ISGREATEREQUAL(unsigned long)TMP_ISGREATEREQUAL(char)TMP_ISGREATEREQUAL(unsigned char)#undef TMP_ISGREATEREQUAL template<class T1, class T2, int N>inline bool isGreaterEqual(const TinyVector<T1,N>&a, const TinyVector<T2,N>&b) {    for (int i= 0; i<N ; ++i)         if (a[i] < b[i])            return false;    return true;}BZ_DECLARE_FUNCTION2_RET(isGreaterEqual,bool)// @}// }}}// {{{ isLess functions/**  * @defgroup isLess Overloaded isLess functions * @brief Defines isLess function for int, double and TinyVector. * * isLess compares element by element and returns true only if all elements  * of a are are Greater than b. * */// @{ #define TMP_ISLESS(TYPE)                                     \inline bool isLess(const TYPE a, const TYPE b) {             \    return a < b;                                               \}TMP_ISLESS(double)TMP_ISLESS(long double)TMP_ISLESS(float)TMP_ISLESS(int)TMP_ISLESS(unsigned int)TMP_ISLESS(short)TMP_ISLESS(unsigned short)TMP_ISLESS(long)TMP_ISLESS(unsigned long)TMP_ISLESS(char)TMP_ISLESS(unsigned char)#undef TMP_ISGREATERtemplate<class T1, class T2, int N>inline bool isLess(const TinyVector<T1,N>&a, const TinyVector<T2,N>&b) {    for (int i= 0; i<N ; ++i)         if (a[i] >= b[i])            return false;    return true;}BZ_DECLARE_FUNCTION2_RET(isLess,bool)// @}// }}}// {{{ isLessEqual functions/**  * @defgroup isLessEqual Overloaded isLessEqual functions * @brief Defines isLessEqual function for int, double and TinyVector. * * isLessEqual compares element by element and returns true only if all elements  * of a are GreaterEqual than b. * */// @{ #define TMP_ISLESSEQUAL(TYPE)                                          \inline bool isLessEqual(const TYPE a, const TYPE b) {                  \    return a <= b;                                                         \}TMP_ISLESSEQUAL(double)TMP_ISLESSEQUAL(long double)TMP_ISLESSEQUAL(float)TMP_ISLESSEQUAL(int)TMP_ISLESSEQUAL(unsigned int)TMP_ISLESSEQUAL(short)TMP_ISLESSEQUAL(unsigned short)TMP_ISLESSEQUAL(long)TMP_ISLESSEQUAL(unsigned long)TMP_ISLESSEQUAL(char)

⌨️ 快捷键说明

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