From 3b470c8327bdafb133a11f5e7257ccb270f8c1c9 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 4 Aug 2009 14:49:49 +0000 Subject: added stdevf functions , interfaces , header, tests , everything --- src/c/statisticsFunctions/stdevf/cstdevfa.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/c/statisticsFunctions/stdevf/cstdevfa.c') diff --git a/src/c/statisticsFunctions/stdevf/cstdevfa.c b/src/c/statisticsFunctions/stdevf/cstdevfa.c index 63ce3948..5b1631f1 100644 --- a/src/c/statisticsFunctions/stdevf/cstdevfa.c +++ b/src/c/statisticsFunctions/stdevf/cstdevfa.c @@ -15,9 +15,10 @@ floatComplex cstdevfa(floatComplex *in1, int lines, int columns, floatComplex* in2) { int i = 0 ; + floatComplex temp = FloatComplex(0.0f,0.0f); floatComplex accumulate = FloatComplex(0.0f,0.0f); - float accumulateFre = 0.0f ; + floatComplex accumulateFre = FloatComplex(0.0f,0.0f); floatComplex meanf = cmeanfa (in1 , lines*columns , in2); /*equivalent to (in1 - meanf(x , in2 )).^2 .*in2 */ for(i = 0 ; i < lines*columns ; ++i) @@ -26,16 +27,17 @@ floatComplex cstdevfa(floatComplex *in1, int lines, int columns, floatComplex* i temp = cmuls( in2[i] , temp); accumulate = cadds( temp , accumulate); - accumulateFre += creals(in2[i]); - } + accumulateFre = cadds (in2[i] ,accumulateFre ); + + } - if (lines <= 1) + if (lines <= 1) { - return cmuls (FloatComplex(0.0f,0.0f) , accumulate ) ; + return cmuls (FloatComplex(0.0f,0.0f) , accumulate ) ; } - else + else { - accumulate = FloatComplex( creals(accumulate ) / (accumulateFre - 1) , cimags(accumulate) / (accumulateFre - 1)); + accumulate = crdivs (accumulate , cdiffs (accumulateFre ,FloatComplex(1.0f,0.0f)) ); return csqrts(accumulate); } } -- cgit