#ifndef HGL_Primary_Mathematics_INCLUDE #define HGL_Primary_Mathematics_INCLUDE #include namespace hgl { /** * 求一批数的合 */ template const T sum(const T *data,const int count) { T result=0; for(int i=0;i const R sum(const T *data,const int count) { R result=0; for(int i=0;i inline constexpr T Clamp(const T &value,const T2 &min_value,const T2 &max_value) { if(valuemax_value)return max_value; return value; } template inline constexpr T Clamp(const T &value) { return Clamp(value,0,1); } inline constexpr uint8 ClampU8(const int &value) { if(value<0)return 0; if(value>0xFF)return 0xFF; return value; } inline constexpr uint16 ClampU16(const int value) { if(value<0)return 0; if(value>0xFFFF)return 0xFFFF; return value; } }//namespace hgl #endif//HGL_Primary_Mathematics_INCLUDE