CMCore/inc/hgl/math/PrimaryMathematics.h

40 lines
710 B
C
Raw Normal View History

2022-05-31 17:21:17 +08:00
#ifndef HGL_Primary_Mathematics_INCLUDE
2021-09-14 09:55:36 +08:00
#define HGL_Primary_Mathematics_INCLUDE
namespace hgl
{
/**
2022-05-31 17:21:17 +08:00
*
2021-09-14 09:55:36 +08:00
*/
template<typename T>
const T sum(const T *data,const int count)
{
T result=0;
for(int i=0;i<count;i++)
{
result+=*data;
++data;
}
return result;
}
/**
2022-05-31 17:21:17 +08:00
*
2021-09-14 09:55:36 +08:00
*/
template<typename R,typename T>
const R sum(const T *data,const int count)
{
R result=0;
for(int i=0;i<count;i++)
{
result+=*data;
++data;
}
return result;
}
}//namespace hgl
#endif//HGL_Primary_Mathematics_INCLUDE