diff options
author | simon | 2009-08-04 14:49:49 +0000 |
---|---|---|
committer | simon | 2009-08-04 14:49:49 +0000 |
commit | 3b470c8327bdafb133a11f5e7257ccb270f8c1c9 (patch) | |
tree | 41c9438f2a39f7915f75bf3da8b24f626a63d700 /src/c/statisticsFunctions/stdevf/cstdevfa.c | |
parent | be8c66b26fa69a8078ee369f0af5fb9372f95293 (diff) | |
download | scilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.tar.gz scilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.tar.bz2 scilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.zip |
added stdevf functions , interfaces , header, tests , everything
Diffstat (limited to 'src/c/statisticsFunctions/stdevf/cstdevfa.c')
-rw-r--r-- | src/c/statisticsFunctions/stdevf/cstdevfa.c | 16 |
1 files changed, 9 insertions, 7 deletions
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); } } |