summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/stdevf/zrowstdevfa.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/zrowstdevfa.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/zrowstdevfa.c')
-rw-r--r--src/c/statisticsFunctions/stdevf/zrowstdevfa.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/c/statisticsFunctions/stdevf/zrowstdevfa.c b/src/c/statisticsFunctions/stdevf/zrowstdevfa.c
index 8a35d4de..bfa77aa5 100644
--- a/src/c/statisticsFunctions/stdevf/zrowstdevfa.c
+++ b/src/c/statisticsFunctions/stdevf/zrowstdevfa.c
@@ -12,8 +12,8 @@
#include "stdevf.h"
#include "meanf.h"
+#include "abs.h"
-#include <stdio.h>
void zrowstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in2, doubleComplex* out){
@@ -21,15 +21,16 @@ void zrowstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in2,
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);
zrowmeanfa(in1, lines, columns, in2, out );
/*we first multiply each zell of the input matrix by its coefficient*/
for (j = 0; j < columns; ++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 < lines; ++i )
@@ -39,7 +40,7 @@ void zrowstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in2,
temp = zmuls( in2[lines*j + i] , temp);
accumulate = zadds( temp , accumulate);
- accumulateFre += zreals(in2[lines*j + i]);
+ accumulateFre = zadds(in2[lines*j + i] ,accumulateFre );
}
@@ -49,8 +50,13 @@ void zrowstdevfa(doubleComplex *in1, int lines, int columns, doubleComplex*in2,
}
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);
+
}
}