diff options
author | simon | 2009-07-27 13:53:19 +0000 |
---|---|---|
committer | simon | 2009-07-27 13:53:19 +0000 |
commit | cfc1f74342cfbdac402d3232106d96cba36d51b5 (patch) | |
tree | 8c095e5fdd1b992ac423f7dc8b7d444adffee07f /src/c/statisticsFunctions/variancef/cvariancefa.c | |
parent | 7d72ad32fa35a85fc62fa65a8bbbbd5a352653b4 (diff) | |
download | scilab2c-cfc1f74342cfbdac402d3232106d96cba36d51b5.tar.gz scilab2c-cfc1f74342cfbdac402d3232106d96cba36d51b5.tar.bz2 scilab2c-cfc1f74342cfbdac402d3232106d96cba36d51b5.zip |
added variancef functions but *(row|column)variance* don't work are waiting some clarity about how they works in scilab
added the corresponding interface and unitary test
Diffstat (limited to 'src/c/statisticsFunctions/variancef/cvariancefa.c')
-rw-r--r-- | src/c/statisticsFunctions/variancef/cvariancefa.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/variancef/cvariancefa.c b/src/c/statisticsFunctions/variancef/cvariancefa.c new file mode 100644 index 00000000..71f29be8 --- /dev/null +++ b/src/c/statisticsFunctions/variancef/cvariancefa.c @@ -0,0 +1,36 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "variancef.h" +#include "division.h" + +floatComplex cvariancefa(floatComplex *in1, int size, floatComplex *in2) + +{ + int i = 0 ; + floatComplex temp = FloatComplex (0.0f, 0.0f ); + floatComplex accumulate =FloatComplex (0.0f, 0.0f ); + float accumulateFre = 0.0f; + + floatComplex meanf = cmeanfa (in1 , size , in2); + //printf("\n\tComplex meanf result : %lf \t+ %lf i " ,creals( meanf) ,cimags( meanf)) ; + for(i = 0 ; i < size ; ++i) + { + temp = cpows ( cdiffs (in1[i] , meanf ) ,FloatComplex (2.0f, 0.0f ) ); + temp = cmuls( in2[i] , temp); + //printf("\n\tComplex accumulate : %lf \t+ %lf i " ,creals(temp) ,cimags(temp)) ; + accumulate = cadds( temp , accumulate); + accumulateFre += creals(in2[i]); + } +//printf("\n\tComplex division result : %lf \t+ %lf i / %lf " ,creals(accumulate) ,cimags(accumulate),accumulateFre) ; + return FloatComplex( creals(accumulate) /(accumulateFre -1), cimags(accumulate) /(accumulateFre -1)); +} |