summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c
diff options
context:
space:
mode:
authorsimon2009-08-04 14:49:49 +0000
committersimon2009-08-04 14:49:49 +0000
commit3b470c8327bdafb133a11f5e7257ccb270f8c1c9 (patch)
tree41c9438f2a39f7915f75bf3da8b24f626a63d700 /src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c
parentbe8c66b26fa69a8078ee369f0af5fb9372f95293 (diff)
downloadscilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.tar.gz
scilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.tar.bz2
scilab2c-3b470c8327bdafb133a11f5e7257ccb270f8c1c9.zip
added stdevf functions , interfaces , header, tests , everything
Diffstat (limited to 'src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c')
-rw-r--r--src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c b/src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c
index 3d1e8ec9..7dadda70 100644
--- a/src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c
+++ b/src/c/statisticsFunctions/stdevf/zcolumnstdevfa.c
@@ -13,15 +13,14 @@
#include "stdevf.h"
#include "meanf.h"
-
-#include <stdio.h>
+#include "abs.h"
void zcolumnstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in2, doubleComplex* out){
int i = 0;
int j = 0;
doubleComplex temp = DoubleComplex(0.0,0.0);
doubleComplex accumulate = DoubleComplex(0.0,0.0);
- double accumulateFre = 0.0;
+ doubleComplex accumulateFre = DoubleComplex(0.0,0.0);
zcolumnmeanfa(in1, lines, columns, in2, out );
@@ -30,7 +29,7 @@ void zcolumnstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in
for (j = 0; j < lines; ++j)
{
accumulate = DoubleComplex(0.0,0.0);
- accumulateFre = 0.0;
+ accumulateFre = DoubleComplex(0.0,0.0);
temp = DoubleComplex(0.0,0.0);
for ( i = 0 ; i < columns; ++i )
@@ -40,7 +39,7 @@ void zcolumnstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in
temp = zmuls( in2[lines*i + j] , temp);
accumulate = zadds( temp , accumulate);
- accumulateFre += zreals(in2[lines*i + j]);
+ accumulateFre = zadds(in2[lines*i + j] ,accumulateFre );
}
@@ -50,7 +49,9 @@ void zcolumnstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in
}
else
{
- accumulate = DoubleComplex( zreals(accumulate ) / (accumulateFre - 1) , zimags(accumulate) / (accumulateFre - 1));
+ if( dabss (zreals(accumulate)) <= 3e-14 ) accumulate = DoubleComplex(dabss(zreals(accumulate)) ,zimags(accumulate));
+ if( dabss (zimags(accumulate)) <= 3e-14 ) accumulate = DoubleComplex(zreals(accumulate) ,dabss(zimags(accumulate)));
+ accumulate = zrdivs(accumulate, zdiffs(accumulateFre ,DoubleComplex(1.0,0.0)));
out[j] = zsqrts(accumulate);
}
}