Go to the documentation of this file. 1 #if !defined(__VectorFloat_hdr__)
2 #define __VectorFloat_hdr__
20 static void setZero (T *pfSrcDest,
int iLength)
22 assert (iLength >= 0);
26 memset (pfSrcDest, 0,
sizeof(T)*iLength);
37 assert (iLength >= 0);
40 for (
int i = 0; i < iLength; i++)
41 if (pfSrcDest[i] < Thresh)
51 static void copy(T *pDest,
const T *pSource,
int iLength)
59 memcpy(pDest, pSource,
sizeof(T)*iLength);
68 static void flip_I(T *pfSrcDest,
int iLength)
76 int iLoopLength = iLength / 2;
77 for (
int i = 0; i < iLoopLength; i++)
80 pfSrcDest[i] = pfSrcDest[iLength - 1 - i];
81 pfSrcDest[iLength - 1 - i] = Tmp;
93 static void moveInMem (T *pfSrcDest,
int iDestIdx,
int iSrcIdx,
int iLength)
95 assert (iLength >= 0);
99 memmove (&pfSrcDest[iDestIdx], &pfSrcDest[iSrcIdx],
sizeof(T)*iLength);
114 static inline void setZero (
float *pfSrcDest,
int iLength)
136 static inline void copy(
float *pfDest,
const float *pfSource,
int iLength)
146 static inline void flip_I(
float *pfSrcDest,
int iLength)
158 static inline void moveInMem (
float *pfSrcDest,
int iDestIdx,
int iSrcIdx,
int iLength)
169 static inline void setValue (
float *pfDest,
float fValue,
int iLength)
171 assert (iLength >= 0);
174 for (
int i = 0; i < iLength; i++)
184 static inline void mulC_I (
float *pfSrcDest,
float fScale,
int iLength)
186 assert (iLength >= 0);
189 for (
int i = 0; i < iLength; i++)
190 pfSrcDest[i] *= fScale;
199 static inline void mul_I (
float *pfSrcDest,
const float *pfSrc,
int iLength)
201 assert (iLength >= 0);
205 for (
int i = 0; i < iLength; i++)
206 pfSrcDest[i] *= pfSrc[i];
215 static inline float mulScalar (
const float *pfSrc1,
const float *pfSrc2,
int iLength)
217 assert (iLength >= 0);
222 for (
int i = 0; i < iLength; i++)
223 fResult += pfSrc1[i] * pfSrc2[i];
234 static inline void div_I (
float *pfSrcDest,
const float *pfSrc,
int iLength)
236 assert (iLength >= 0);
240 for (
int i = 0; i < iLength; i++)
242 assert(pfSrc[i] != 0);
243 pfSrcDest[i] /= pfSrc[i];
253 static inline void add_I (
float *pfSrcDest,
const float *pfSrc,
int iLength)
255 assert (iLength >= 0);
259 for (
int i = 0; i < iLength; i++)
260 pfSrcDest[i] += pfSrc[i];
269 static inline void addC_I (
float *pfSrcDest,
float fScale,
int iLength)
271 assert (iLength >= 0);
274 for (
int i = 0; i < iLength; i++)
275 pfSrcDest[i] += fScale;
284 static inline void sub_I (
float *pfSrcDest,
const float *pfSrc,
int iLength)
286 assert (iLength >= 0);
290 for (
int i = 0; i < iLength; i++)
291 pfSrcDest[i] -= pfSrc[i];
300 static inline float sum (
const float *pfSrc,
int iLength,
bool bAbs =
false)
302 assert (iLength >= 0);
308 for (
int i = 0; i < iLength; i++)
309 fResult += std::abs(pfSrc[i]);
313 for (
int i = 0; i < iLength; i++)
325 static inline bool isEqual (
const float *pfSrc1,
const float *pfSrc2,
int iLength)
327 assert (iLength >= 0);
331 return (memcmp (pfSrc1, pfSrc2, iLength *
sizeof(
float)) == 0);
339 static inline float getMean (
const float *pfSrc,
long long int iLength)
341 assert (iLength >= 0);
345 for (
int i=0; i < iLength; i++)
364 static inline float getStd (
const float *pfSrc,
long long int iLength,
float fMean = std::numeric_limits<float>::max())
366 assert (iLength >= 0);
370 if (fMean == std::numeric_limits<float>::max())
372 fMean =
getMean(pfSrc, iLength);
375 for (
int i=0; i < iLength; i++)
377 fStd += (pfSrc[i] - fMean) * (pfSrc[i] - fMean);
386 return std::sqrt(fStd);
394 static inline float getRms (
const float *pfSrc,
long long int iLength)
396 assert (iLength >= 0);
401 for (
int i=0; i < iLength; i++)
403 fRms += pfSrc[i] * pfSrc[i];
411 return std::sqrt(fRms);
420 static inline float getMax (
const float *pfSrc,
long long int iLength,
bool bAbs =
false)
425 findMax(pfSrc, fMax, iMax, iLength, bAbs);
436 static inline float getMin (
const float *pfSrc,
long long int iLength,
bool bAbs =
false)
441 findMin(pfSrc, fMin, iMin, iLength, bAbs);
454 static inline void findMax (
const float *pfSrc,
float &fMax,
long long &iMax,
long long int iLength,
bool bAbs =
false)
456 assert (iLength >= 0);
459 fMax = -std::numeric_limits<float>::max();
462 for (
int i = 0; i < iLength; i++)
464 float fCurr = (bAbs)? std::abs(pfSrc[i]) : pfSrc[i];
482 static inline void findMin (
const float *pfSrc,
float &fMin,
long long &iMin,
long long int iLength,
bool bAbs =
false)
484 assert (iLength >= 0);
487 fMin = std::numeric_limits<float>::max();
490 for (
int i = 0; i < iLength; i++)
492 float fCurr = (bAbs)? std::abs(pfSrc[i]) : pfSrc[i];
502 #endif // __VectorFloat_hdr__
static void div_I(float *pfSrcDest, const float *pfSrc, int iLength)
Definition: Vector.h:234
static void add_I(float *pfSrcDest, const float *pfSrc, int iLength)
Definition: Vector.h:253
static void setValue(float *pfDest, float fValue, int iLength)
Definition: Vector.h:169
static float getRms(const float *pfSrc, long long int iLength)
Definition: Vector.h:394
static void setZero(T *pfSrcDest, int iLength)
Definition: Vector.h:20
static void mulC_I(float *pfSrcDest, float fScale, int iLength)
Definition: Vector.h:184
static void moveInMem(float *pfSrcDest, int iDestIdx, int iSrcIdx, int iLength)
Definition: Vector.h:158
static float getMax(const float *pfSrc, long long int iLength, bool bAbs=false)
Definition: Vector.h:420
static void setZeroBelowThresh(float *pfSrcDest, int iLength, float fThresh)
Definition: Vector.h:125
static void setZero(float *pfSrcDest, int iLength)
Definition: Vector.h:114
static float getStd(const float *pfSrc, long long int iLength, float fMean=std::numeric_limits< float >::max())
Definition: Vector.h:364
static void sub_I(float *pfSrcDest, const float *pfSrc, int iLength)
Definition: Vector.h:284
static bool isEqual(const float *pfSrc1, const float *pfSrc2, int iLength)
Definition: Vector.h:325
static void moveInMem(T *pfSrcDest, int iDestIdx, int iSrcIdx, int iLength)
Definition: Vector.h:93
static void copy(float *pfDest, const float *pfSource, int iLength)
Definition: Vector.h:136
static void flip_I(T *pfSrcDest, int iLength)
Definition: Vector.h:68
static float getMean(const float *pfSrc, long long int iLength)
Definition: Vector.h:339
static void setZeroBelowThresh(T *pfSrcDest, int iLength, T Thresh)
Definition: Vector.h:35
class with static functions for buffer operations with type T
Definition: Vector.h:12
static void copy(T *pDest, const T *pSource, int iLength)
Definition: Vector.h:51
static void findMin(const float *pfSrc, float &fMin, long long &iMin, long long int iLength, bool bAbs=false)
Definition: Vector.h:482
static void flip_I(float *pfSrcDest, int iLength)
Definition: Vector.h:146
static float getMin(const float *pfSrc, long long int iLength, bool bAbs=false)
Definition: Vector.h:436
static void findMax(const float *pfSrc, float &fMax, long long &iMax, long long int iLength, bool bAbs=false)
Definition: Vector.h:454
static float sum(const float *pfSrc, int iLength, bool bAbs=false)
Definition: Vector.h:300
static float mulScalar(const float *pfSrc1, const float *pfSrc2, int iLength)
Definition: Vector.h:215
static void mul_I(float *pfSrcDest, const float *pfSrc, int iLength)
Definition: Vector.h:199
class with static functions for buffer operations with type float
Definition: Vector.h:106
static void addC_I(float *pfSrcDest, float fScale, int iLength)
Definition: Vector.h:269