Updated the indentation and added the optimized var function

pull/39/head
Silfurion 4 years ago
parent c6b18e9e92
commit 433ecc8b22

@ -49,6 +49,7 @@ void arm_var_f64(
uint32_t blockSize, uint32_t blockSize,
float64_t * pResult) float64_t * pResult)
{ {
uint32_t blkCnt; /* Loop counter */ uint32_t blkCnt; /* Loop counter */
float64_t sum = 0.; /* Temporary result storage */ float64_t sum = 0.; /* Temporary result storage */
float64_t fSum = 0.; float64_t fSum = 0.;
@ -60,28 +61,29 @@ void arm_var_f64(
*pResult = 0; *pResult = 0;
return; return;
} }
arm_mean_f64(pInput, blockSize, &fMean);
/* Initialize blkCnt with number of samples */ #if defined(ARM_MATH_NEON)
blkCnt = blockSize; float64x2_t fValueV ,fsumV , pInputV , fMeanV;
fsumV = vdupq_n_f64(0.0f);
fMeanV = vdupq_n_f64(fMean);
blkCnt = blockSize >> 1U;
while(blkCnt > 0U) while(blkCnt > 0U)
{ {
/* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ pInputV = vld1q_f64(pInput);
fValueV = vsubq_f64(pInputV, fMeanV);
sum += *pInput++; fsumV = vmlaq_f64(fsumV, fValueV, fValueV);
pInput += 2 ;
/* Decrement loop counter */
blkCnt--; blkCnt--;
} }
fSum = vaddvq_f64(fsumV);
/* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) / blockSize */ blkCnt = blockSize & 1 ;
fMean = sum / (float64_t) blockSize;
pInput = pSrc;
#else
/* Initialize blkCnt with number of samples */ /* Initialize blkCnt with number of samples */
blkCnt = blockSize; blkCnt = blockSize;
#endif
while (blkCnt > 0U) while (blkCnt > 0U)
{ {
fValue = *pInput++ - fMean; fValue = *pInput++ - fMean;

Loading…
Cancel
Save