summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorsimon2009-08-04 11:52:49 +0000
committersimon2009-08-04 11:52:49 +0000
commitbe8c66b26fa69a8078ee369f0af5fb9372f95293 (patch)
treed3574f2f85042a199d5455221f58b23f05d5e394 /src/c
parentac2f79dabb674e9cf79e611c19b3acd2d98a9831 (diff)
downloadscilab2c-be8c66b26fa69a8078ee369f0af5fb9372f95293.tar.gz
scilab2c-be8c66b26fa69a8078ee369f0af5fb9372f95293.tar.bz2
scilab2c-be8c66b26fa69a8078ee369f0af5fb9372f95293.zip
added case where second input of meanf is complex
updated the header and interface added functiosn for the new cases update INIT_FillSCI2LibCDirs changing the unit test in order to test the new cases
Diffstat (limited to 'src/c')
-rw-r--r--src/c/statisticsFunctions/includes/meanf.h7
-rw-r--r--src/c/statisticsFunctions/interfaces/int_meanf.h149
-rw-r--r--src/c/statisticsFunctions/meanf/cmeanfa.c18
-rw-r--r--src/c/statisticsFunctions/meanf/cmeanfcs.c (renamed from src/c/statisticsFunctions/meanf/cmeanfv.c)2
-rw-r--r--src/c/statisticsFunctions/meanf/cmeanfsc.c25
-rw-r--r--src/c/statisticsFunctions/meanf/drowmeanfa.c4
-rw-r--r--src/c/statisticsFunctions/meanf/testDoubleMeanf.c81
-rw-r--r--src/c/statisticsFunctions/meanf/zcolumnmeanfa.c3
-rw-r--r--src/c/statisticsFunctions/meanf/zmeanfa.c7
-rw-r--r--src/c/statisticsFunctions/meanf/zmeanfdz.c25
-rw-r--r--src/c/statisticsFunctions/meanf/zmeanfzd.c (renamed from src/c/statisticsFunctions/meanf/zmeanfv.c)2
-rw-r--r--src/c/statisticsFunctions/meanf/zrowmeanfa.c2
12 files changed, 269 insertions, 56 deletions
diff --git a/src/c/statisticsFunctions/includes/meanf.h b/src/c/statisticsFunctions/includes/meanf.h
index f3a56bd0..c0d687c6 100644
--- a/src/c/statisticsFunctions/includes/meanf.h
+++ b/src/c/statisticsFunctions/includes/meanf.h
@@ -93,8 +93,11 @@ EXTERN_STATFUNC void zrowmeanfa(doubleComplex *in1, int lines, int columns, dou
EXTERN_STATFUNC void zcolumnmeanfa(doubleComplex *in1, int lines, int columns, doubleComplex *in2, doubleComplex* out);
/* for convenience with interface */
-doubleComplex zmeanfv (doubleComplex* in1 ,int lines , int columns , double* in2);
-floatComplex cmeanfv (floatComplex* in1 ,int lines , int columns , float* in2);
+doubleComplex zmeanfzd (doubleComplex* in1 ,int lines , int columns , double* in2);
+doubleComplex zmeanfdz (double* in1 ,int lines , int columns , doubleComplex* in2);
+
+floatComplex cmeanfcs (floatComplex* in1 ,int lines , int columns , float* in2);
+floatComplex cmeanfsc (float* in1 ,int lines , int columns , floatComplex* in2);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/src/c/statisticsFunctions/interfaces/int_meanf.h b/src/c/statisticsFunctions/interfaces/int_meanf.h
index c9abc495..c7fb4da9 100644
--- a/src/c/statisticsFunctions/interfaces/int_meanf.h
+++ b/src/c/statisticsFunctions/interfaces/int_meanf.h
@@ -1,6 +1,6 @@
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
+ * 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
@@ -19,17 +19,17 @@
#define d0d0meanfd0(in1,in2) dmeanfs(in1,in2)
-#define c0s0meanfc0(in1,in2) cmeanfs(in1,in2)
+#define c0s0meanfc0(in1,in2) cmeanfs(in1,FloatComplex(in2 , 0.0f))
-#define z0d0meanfz0(in1,in2) zmeanfs(in1,in2)
+#define z0d0meanfz0(in1,in2) zmeanfs(in1,DoubleComplex(in2, 0.0))
#define s2s2meanfs0(in1, size1, in2, size2) smeanfa(in1, size1[0]*size1[1], in2)
#define d2d2meanfd0(in1, size1, in2, size2) dmeanfa(in1, size1[0]*size1[1], in2)
-#define c2s2meanfc0(in1, size1, in2, size2) cmeanfv(in1, size1[0], size1[1], in2)
+#define c2s2meanfc0(in1, size1, in2, size2) cmeanfcs(in1, size1[0], size1[1], in2)
-#define z2d2meanfz0(in1, size1, in2, size2) zmeanfv(in1, size1[0], size1[1], in2)
+#define z2d2meanfz0(in1, size1, in2, size2) zmeanfzd(in1, size1[0], size1[1], in2)
/*by rows or columns */
@@ -38,21 +38,146 @@
#define d0d0d0meanfd0(in1,in2,in3) (in3==1) ? drowmeanfs(in1,in2) : dcolumnmeanfs(in1,in2)
-#define c0s0s0meanfc0(in1,in2,in3) (in3==1) ? crowmeanfs(in1,in2) : ccolumnmeanfs(in1,in2)
+#define c0s0s0meanfc0(in1,in2,in3) (in3==1) ? crowmeanfs(in1,FloatComplex(in2 , 0.0f)) : ccolumnmeanfs(in1,FloatComplex(in2 , 0.0f))
-#define z0d0d0meanfz0(in1,in2,in3) (in3==1) ? zrowmeanfs(in1,in2) : zcolumnmeanfs(in1,in2)
+#define z0d0d0meanfz0(in1,in2,in3) (in3==1) ? zrowmeanfs(in1,DoubleComplex(in2, 0.0)) : zcolumnmeanfs(in1,DoubleComplex(in2, 0.0))
+
#define s2s2s0meanfs2(in1, size1, in2, size2,in3,out) (in3==1) ? srowmeanfa(in1,size1[0],size1[1],in2,out) : scolumnmeanfa(in1,size1[0],size1[1],in2,out)
#define d2d2d0meanfd2(in1, size1, in2, size2,in3,out) (in3==1) ? drowmeanfa(in1,size1[0],size1[1],in2,out) : dcolumnmeanfa(in1,size1[0],size1[1],in2,out)
-#define c2s2s0meanfc2(in1, size1, in2, size2,in3,out) (in3==1) ? crowmeanfa(in1,size1[0],size1[1],in2,out) : ccolumnmeanfa(in1,size1[0],size1[1],in2,out)
-#define z2d2d0meanfz2(in1, size1, in2, size2,in3,out) (in3==1) ? zrowmeanfa(in1,size1[0],size1[1],in2,out) : zcolumnmeanfa(in1,size1[0],size1[1],in2,out)
+
+
+
+#define c2s2s0meanfc2(in1, size1, in2, size2,in3,out) if (in3==1) {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ crowmeanfa(in1,size1[0],size1[1],FloatComplexMatrix(in2,temp,size1[0]*size1[1]),out);\
+ free(temp);\
+ }\
+ else\
+ {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ ccolumnmeanfa(in1,size1[0],size1[1],FloatComplexMatrix(in2,temp,size1[0]*size1[1]),out);\
+ free(temp);\
+ }
+
+#define z2d2d0meanfz2(in1, size1, in2, size2,in3,out) if (in3==1) {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zrowmeanfa(in1,size1[0],size1[1],DoubleComplexMatrix(in2,temp,size1[0]*size1[1]),out);\
+ free(temp);\
+ }\
+ else\
+ {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zcolumnmeanfa(in1,size1[0],size1[1],DoubleComplexMatrix(in2,temp,size1[0]*size1[1]),out);\
+ free(temp);\
+ }
+
-/*
-#define d2d2d0meanfd2(in1,size1,in2,size2 ,in3 ,out) (in3==1) ? drowmeanfa(in1,size1[0],size1[1],in2 ,out) : dcolumnmeanfa(in1,size1[0],size1[1], in2,out)
-*/
+/**/
+
+
+#define s0c0meanfs0(in1,in2) creals (cmeanfs(FloatComplex(in1 , 0.0f),in2))
+#define s0c0meanfc0(in1,in2) cmeanfs(FloatComplex(in1 , 0.0f),in2)
+
+#define d0z0meanfd0(in1,in2) zreals(zmeanfs(DoubleComplex(in1, 0.0 ),in2))
+#define d0z0meanfz0(in1,in2) zmeanfs(DoubleComplex(in1, 0.0 ),in2)
+
+#define c0c0meanfc0(in1,in2) cmeanfs(in1,in2)
+
+#define z0z0meanfz0(in1,in2) zmeanfs(in1,in2)
+
+
+#define s2c2meanfs0(in1, size1, in2, size2) creals (cmeanfsc(in1, size1[0],size1[1], in2))
+#define s2c2meanfc0(in1, size1, in2, size2) cmeanfsc(in1, size1[0],size1[1], in2)
+
+#define d2z2meanfd0(in1, size1, in2, size2) zreals(zmeanfdz(in1, size1[0],size1[1], in2))
+#define d2z2meanfz0(in1, size1, in2, size2) zmeanfdz(in1, size1[0],size1[1], in2)
+
+#define c2c2meanfc0(in1, size1, in2, size2) cmeanfa(in1, size1[0]* size1[1], in2)
+
+#define z2z2meanfz0(in1, size1, in2, size2) zmeanfa(in1, size1[0]* size1[1], in2)
+
+
+/*by rows or columns */
+
+#define s0c0s0meanfs0(in1,in2,in3) (in3==1) ? crowmeanfs(FloatComplex(in1, 0.0f),in2) : ccolumnmeanfs(FloatComplex(in1, 0.0f),in2)
+
+#define d0z0d0meanfd0(in1,in2,in3) (in3==1) ? zrowmeanfs(DoubleComplex(in1, 0.0),in2) : zcolumnmeanfs(DoubleComplex(in1, 0.0),in2)
+
+#define c0c0s0meanfc0(in1,in2,in3) (in3==1) ? crowmeanfs(in1,in2) : ccolumnmeanfs(in1,in2)
+
+#define z0z0d0meanfz0(in1,in2,in3) (in3==1) ? zrowmeanfs(in1,in2) : zcolumnmeanfs(in1,in2)
+
+
+#define s2c2s0meanfs2(in1, size1, in2, size2,in3,out) if (in3==1) {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ crowmeanfa(FloatComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }\
+ else\
+ {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ ccolumnmeanfa(FloatComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }
+
+#define d2z2d0meanfd2(in1, size1, in2, size2,in3,out) if (in3==1) {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zrowmeanfa(DoubleComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }\
+ else\
+ {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zcolumnmeanfa(DoubleComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }
+
+/*complex output*/
+#define s2c2s0meanfc2(in1, size1, in2, size2,in3,out) if (in3==1) {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ crowmeanfa(FloatComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }\
+ else\
+ {float* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(float));\
+ sfilla(temp,size1[0],size1[1],0);\
+ ccolumnmeanfa(FloatComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }
+
+#define d2z2d0meanfz2(in1, size1, in2, size2,in3,out) if (in3==1) {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zrowmeanfa(DoubleComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }\
+ else\
+ {double* temp;\
+ temp=malloc((uint)(size1[0]*size1[1])*sizeof(double));\
+ dfilla(temp,size1[0],size1[1],0);\
+ zcolumnmeanfa(DoubleComplexMatrix(in1,temp,size1[0]*size1[1]),size1[0],size1[1],in2,out);\
+ free(temp);\
+ }
+
+
+
+#define c2c2s0meanfc2(in1, size1, in2, size2,in3,out) (in3==1) ? crowmeanfa(in1,size1[0],size1[1],in2,out) : ccolumnmeanfa(in1,size1[0],size1[1],in2,out)
+
+#define z2z2d0meanfz2(in1, size1, in2, size2,in3,out) (in3==1) ? zrowmeanfa(in1,size1[0],size1[1],in2,out) : zcolumnmeanfa(in1,size1[0],size1[1],in2,out)
#endif /* !__INT_MEANF_H__ */
diff --git a/src/c/statisticsFunctions/meanf/cmeanfa.c b/src/c/statisticsFunctions/meanf/cmeanfa.c
index fceaff7d..1aeef53d 100644
--- a/src/c/statisticsFunctions/meanf/cmeanfa.c
+++ b/src/c/statisticsFunctions/meanf/cmeanfa.c
@@ -12,29 +12,19 @@
#include "meanf.h"
#include "multiplication.h"
-
+#include "division.h"
floatComplex cmeanfa(floatComplex *in1, int size, floatComplex *in2 ) {
floatComplex accumulate = FloatComplex(0.0f, 0.0f);
- float freAccumulate = 0.0f;
+ floatComplex freAccumulate = FloatComplex(0.0f, 0.0f);
int i = 0;
for (i = 0; i < size; ++i)
{
accumulate = cadds(accumulate, cmuls (in1[i] , in2[i]));
- freAccumulate += creals(in2[i]);
+ freAccumulate = cadds(in2[i],freAccumulate);
}
- return FloatComplex(creals(accumulate) /freAccumulate, cimags(accumulate) /freAccumulate);
+ return crdivs(accumulate ,freAccumulate) ;
}
-/*
- for (i = 0; i < size; ++i)
- {
- accumulate += (in1[i] * in2[i]) ;
- freAccumulate += in2[i] ;
- }
- return accumulate / freAccumulate;
-
-
-*/
diff --git a/src/c/statisticsFunctions/meanf/cmeanfv.c b/src/c/statisticsFunctions/meanf/cmeanfcs.c
index 5a045dd4..d7d1a76d 100644
--- a/src/c/statisticsFunctions/meanf/cmeanfv.c
+++ b/src/c/statisticsFunctions/meanf/cmeanfcs.c
@@ -15,7 +15,7 @@
#include "zeros.h"
#include <malloc.h>
-floatComplex cmeanfv (floatComplex* in1 ,int lines , int columns , float* in2)
+floatComplex cmeanfcs (floatComplex* in1 ,int lines , int columns , float* in2)
{
float* ZEROS;
ZEROS=malloc((unsigned int)(lines*columns*sizeof(float)));
diff --git a/src/c/statisticsFunctions/meanf/cmeanfsc.c b/src/c/statisticsFunctions/meanf/cmeanfsc.c
new file mode 100644
index 00000000..7e28a0e1
--- /dev/null
+++ b/src/c/statisticsFunctions/meanf/cmeanfsc.c
@@ -0,0 +1,25 @@
+/*
+ * 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 "meanf.h"
+#include "zeros.h"
+#include <malloc.h>
+
+floatComplex cmeanfsc (float* in1 ,int lines , int columns , floatComplex* in2)
+ {
+ float* ZEROS;
+ ZEROS=malloc((unsigned int)(lines*columns*sizeof(float)));
+ szerosa(ZEROS,lines,columns);
+
+ return cmeanfa(FloatComplexMatrix(in1,ZEROS,lines*columns), lines*columns , in2);
+ }
diff --git a/src/c/statisticsFunctions/meanf/drowmeanfa.c b/src/c/statisticsFunctions/meanf/drowmeanfa.c
index 88baea8a..ce3523cb 100644
--- a/src/c/statisticsFunctions/meanf/drowmeanfa.c
+++ b/src/c/statisticsFunctions/meanf/drowmeanfa.c
@@ -10,7 +10,7 @@
*
*/
-#include "mean.h"
+#include "meanf.h"
#include "sum.h"
void drowmeanfa(double *in1, int lines, int columns, double *in2, double *out) {
@@ -26,7 +26,7 @@ void drowmeanfa(double *in1, int lines, int columns, double *in2, double *out) {
for ( i = 0 ; i < lines; ++i )
{
- tempMul = in1[lines*j + i] * in2[lines*j + i]; // we times by the coefficient
+ tempMul = in1[lines*j + i] * in2[lines*j + i]; /* we times by the coefficient*/
tempCoefSum +=in2[lines*j + i];
out[j] +=tempMul ;
}
diff --git a/src/c/statisticsFunctions/meanf/testDoubleMeanf.c b/src/c/statisticsFunctions/meanf/testDoubleMeanf.c
index 818e3082..f528f1df 100644
--- a/src/c/statisticsFunctions/meanf/testDoubleMeanf.c
+++ b/src/c/statisticsFunctions/meanf/testDoubleMeanf.c
@@ -25,6 +25,9 @@ static int dmeanfsTest(void) {
double coef1 = 56 ;
double coef2 = 2 ;
+ coef1 = 56 ;
+ coef2 = 2 ;
+
printf("\n>>>> Meanf Double Scalar Test\n");
assert( ( fabs(dmeanfs(value1,coef1) ) - ( 3.0 ) ) / fabs ( dmeanfs(value1,coef1) ) < 3e-16 );
assert( ( fabs(dmeanfs(value2,coef2) ) - ( 1.123456789 ) ) / fabs ( dmeanfs(value2,coef2) ) < 3e-16 );
@@ -143,7 +146,7 @@ static int drowmeanfaTest(void) {
double rowMeanmedTable1_1_9[9] = {0};
double rowMeanmedTable1_9_1[1] = {0};
double rowMeanmedTable2_2_5[5] = {0};
- double rowMeanmedTable2_5_2[2] = {0};
+
printf("\n>>>> Row Mean Double Array Test\n");
/*
@@ -206,6 +209,9 @@ static int zmeanfsTest(void) {
doubleComplex value2 = DoubleComplex(1.123456789, 1.123456789);
doubleComplex coef2 = DoubleComplex(9.0, 0.0);
+ coef1 = DoubleComplex(3.0, 0.0);
+ coef2 = DoubleComplex(9.0, 0.0);
+
printf("\n>>>> Mean Double Complex Scalar Test\n");
assert( ( fabs(zreals(zmeanfs(value1,coef1)) ) - ( 3.0 ) ) / fabs ( zreals(zmeanfs(value1,coef1)) ) < 3e-16 );
assert( ( fabs(zimags(zmeanfs(value1,coef1)) ) - ( 3.0 ) ) / fabs ( zimags(zmeanfs(value1,coef1)) ) < 3e-16 );
@@ -244,23 +250,35 @@ static int zrowmeanfaTest(void) {
double tableI1[9] = {1.0, 2.0, 3.0, 4.0 , 5.0, 6.0, 7.0, 8.0, 9.0};
double coefR1[9] = {10.0, 1.0, 5.0,11.0 , 2.0, 6.0,12.0, 3.0, 7.0};
double coefI1[9] = { 0.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 0.0, 0.0};
-/*
+
double tableR2[10] = {1.0, 4.0, 7.0, 2.0 , 5.0, 8.0, 3.0, 6.0, 9.0, 10.0};
- double tableI2[10] = {1.0, 2.0, 3.0, 4.0 , 5.0, 6.0, 7.0, 8.0, 9.0, 15.0};
- double coefR2[10] = {10.0, 1.0, 5.0,11.0 , 2.0, 6.0,12.0, 3.0, 7.0, 19.0};
- double coefI2[10] = { 0.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
-*/
+ double tableI2[10] = { 0.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 0.0, 0.0 , 0.0};
+ double coefR2[10] = { 0.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 0.0, 0.0 , 0.0};
+ double coefI2[10] ={10.0, 1.0, 5.0,11.0 , 2.0, 6.0,12.0, 3.0, 7.0, 19.0};
+
doubleComplex* table1 = DoubleComplexMatrix (tableR1, tableI1, 9);
doubleComplex* coef1 = DoubleComplexMatrix (coefR1, coefI1, 9);
-/*
- doubleComplex* table2 = DoubleComplexMatrix (tableR2, tableI2, 9);
- doubleComplex* coef2 = DoubleComplexMatrix (coefR2, coefI2, 9);
-*/
- doubleComplex rowMeanmedTable1_3_3[3] = {DoubleComplex(0.0, 0.0)};
+
+ doubleComplex* table2 = DoubleComplexMatrix (tableR2, tableI2, 10);
+ doubleComplex* coef2 = DoubleComplexMatrix (coefR2, coefI2, 10);
+
+ doubleComplex rowMeanmedTable1_3_3[3];
+ doubleComplex rowMeanmedTable2_2_5[5];
+
+ rowMeanmedTable1_3_3[0] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable1_3_3[1] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable1_3_3[2] = DoubleComplex(0.0, 0.0);
+
+ rowMeanmedTable2_2_5[0] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable2_2_5[1] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable2_2_5[2] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable2_2_5[3] = DoubleComplex(0.0, 0.0);
+ rowMeanmedTable2_2_5[4] = DoubleComplex(0.0, 0.0);
+
/*
doubleComplex rowMeanmedTable1_1_9[9] = {DoubleComplex(0.0, 0.0)};
doubleComplex rowMeanmedTable1_9_1[1] = {DoubleComplex(0.0, 0.0)};
- doubleComplex rowMeanmedTable2_2_5[5] = {DoubleComplex(0.0, 0.0)};
+
doubleComplex rowMeanmedTable2_5_2[2] = {DoubleComplex(0.0, 0.0)};
*/
@@ -275,16 +293,37 @@ static int zrowmeanfaTest(void) {
printf("rowMeanmedTable_3_3[%d] = %e + %ei\n", i, zreals(rowMeanmedTable1_3_3[i]), zimags(rowMeanmedTable1_3_3[i]));
}
- assert( ( fabs(zimags(rowMeanmedTable1_3_3[0]) ) - ( 27.0 / 16.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[0]) ) < 3e-16 );
- assert( ( fabs(zreals(rowMeanmedTable1_3_3[0]) ) - ( 49.0 / 16.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[0]) ) < 3e-16 );
+ assert( fabs(zimags(rowMeanmedTable1_3_3[0]) - ( 27.0 / 16.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[0]) ) < 3e-16 );
+ assert( fabs(zreals(rowMeanmedTable1_3_3[0]) - ( 49.0 / 16.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[0]) ) < 3e-16 );
- assert( ( fabs(zimags(rowMeanmedTable1_3_3[1]) ) - ( 90.0 / 19.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[1]) ) < 3e-16 );
- assert( ( fabs(zreals(rowMeanmedTable1_3_3[1]) ) - ( 80.0 / 19.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[1]) ) < 3e-16 );
+ assert( fabs(zimags(rowMeanmedTable1_3_3[1]) - ( 90.0 / 19.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[1]) ) < 3e-16 );
+ assert( fabs(zreals(rowMeanmedTable1_3_3[1]) - ( 80.0 / 19.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[1]) ) < 3e-16 );
- assert( ( fabs(zimags(rowMeanmedTable1_3_3[2]) ) - (171.0 / 22.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[2]) ) < 3e-16 );
- assert( ( fabs(zreals(rowMeanmedTable1_3_3[2]) ) - (117.0 / 22.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[2]) ) < 3e-16 );
+ assert( fabs(zimags(rowMeanmedTable1_3_3[2]) - (171.0 / 22.0 ) ) / fabs ( zimags(rowMeanmedTable1_3_3[2]) ) < 3e-16 );
+ assert( fabs(zreals(rowMeanmedTable1_3_3[2]) - (117.0 / 22.0 ) ) / fabs ( zreals(rowMeanmedTable1_3_3[2]) ) < 3e-16 );
+/**/
+ printf("\n\n");
+ zrowmeanfa(table2 , 2 , 5 , coef2 , rowMeanmedTable2_2_5);
+ for (i = 0 ; i < 5 ; ++i )
+ {
+ printf("rowMeanmedTable_2_5[%d] = %e + %ei\n", i, zreals(rowMeanmedTable2_2_5[i]), zimags(rowMeanmedTable2_2_5[i]));
+ }
+ assert( fabs(zreals(rowMeanmedTable2_2_5[0]) - 1.2727273 ) / fabs ( zreals(rowMeanmedTable2_2_5[0]) ) < 1e-6 );
+ assert( zimags(rowMeanmedTable2_2_5[0]) == 0);
+
+ assert( fabs(zreals(rowMeanmedTable2_2_5[1]) - 3.5625000 ) / fabs ( zreals(rowMeanmedTable2_2_5[1]) ) < 1e-6 );
+ assert( zimags(rowMeanmedTable2_2_5[1]) == 0);
+
+ assert( fabs(zreals(rowMeanmedTable2_2_5[2]) - 7.2500000 ) / fabs ( zreals(rowMeanmedTable2_2_5[2]) ) < 1e-6 );
+ assert( zimags(rowMeanmedTable2_2_5[2]) == 0);
+
+ assert( fabs(zreals(rowMeanmedTable2_2_5[3]) - 3.6000000 ) / fabs ( zreals(rowMeanmedTable2_2_5[3]) ) < 1e-6 );
+ assert( zimags(rowMeanmedTable2_2_5[3]) == 0);
+
+ assert( fabs(zreals(rowMeanmedTable2_2_5[4]) - 9.7307692 ) / fabs ( zreals(rowMeanmedTable2_2_5[4]) ) < 1e-6 );
+ assert( zimags(rowMeanmedTable2_2_5[4]) == 0);
return 0;
@@ -311,7 +350,7 @@ static int zcolumnmeanfaTest(void) {
doubleComplex* table2 = DoubleComplexMatrix (tableR2, tableI2, 9);
doubleComplex* coef2 = DoubleComplexMatrix (coefR2, coefI2, 9);
*/
- doubleComplex columnMeanmedTable1_3_3[3] = {DoubleComplex(0.0, 0.0)};
+ doubleComplex columnMeanmedTable1_3_3[3] ;
/*
doubleComplex rowMeanmedTable1_1_9[9] = {DoubleComplex(0.0, 0.0)};
doubleComplex rowMeanmedTable1_9_1[1] = {DoubleComplex(0.0, 0.0)};
@@ -319,6 +358,10 @@ static int zcolumnmeanfaTest(void) {
doubleComplex rowMeanmedTable2_5_2[2] = {DoubleComplex(0.0, 0.0)};
*/
+ columnMeanmedTable1_3_3[0] = DoubleComplex(0.0, 0.0);
+ columnMeanmedTable1_3_3[1] = DoubleComplex(0.0, 0.0);
+ columnMeanmedTable1_3_3[2] = DoubleComplex(0.0, 0.0);
+
printf("\n>>>> Column Meanf Double Complex Array Test\n");
/**/
diff --git a/src/c/statisticsFunctions/meanf/zcolumnmeanfa.c b/src/c/statisticsFunctions/meanf/zcolumnmeanfa.c
index 87f97b59..efbfa89a 100644
--- a/src/c/statisticsFunctions/meanf/zcolumnmeanfa.c
+++ b/src/c/statisticsFunctions/meanf/zcolumnmeanfa.c
@@ -13,6 +13,7 @@
#include "meanf.h"
#include "sum.h"
#include "multiplication.h"
+
void zcolumnmeanfa(doubleComplex *in1, int lines, int columns, doubleComplex *in2, doubleComplex *out) {
int i = 0;
int j = 0;
@@ -26,7 +27,7 @@ void zcolumnmeanfa(doubleComplex *in1, int lines, int columns, doubleComplex *in
for ( i = 0 ; i < columns; ++i )
{
- tempMul = zmuls ( in1[lines*i + j] , in2[lines*i + j]); // we times by the coefficient
+ tempMul = zmuls ( in1[lines*i + j] , in2[lines*i + j]); /* we times by the coefficient*/
tempCoefSum = zadds ( in2[lines*i + j] ,tempCoefSum ) ;
out[j] = zadds (tempMul, out[j]) ;
}
diff --git a/src/c/statisticsFunctions/meanf/zmeanfa.c b/src/c/statisticsFunctions/meanf/zmeanfa.c
index 592111d5..f6691d91 100644
--- a/src/c/statisticsFunctions/meanf/zmeanfa.c
+++ b/src/c/statisticsFunctions/meanf/zmeanfa.c
@@ -12,17 +12,18 @@
#include "meanf.h"
#include "multiplication.h"
+#include "division.h"
doubleComplex zmeanfa(doubleComplex *in1, int size, doubleComplex *in2 ) {
doubleComplex accumulate = DoubleComplex(0.0, 0.0);
- double freAccumulate = 0.0;
+ doubleComplex freAccumulate = DoubleComplex(0.0, 0.0);
int i = 0;
for (i = 0; i < size; ++i)
{
accumulate = zadds(accumulate , zmuls( in1[i] ,in2[i]));
- freAccumulate += zreals(in2[i]);
+ freAccumulate = zadds(in2[i],freAccumulate);
}
- return DoubleComplex(zreals(accumulate) / freAccumulate, zimags(accumulate) /freAccumulate);
+ return zrdivs(accumulate ,freAccumulate);
}
diff --git a/src/c/statisticsFunctions/meanf/zmeanfdz.c b/src/c/statisticsFunctions/meanf/zmeanfdz.c
new file mode 100644
index 00000000..8cbabe16
--- /dev/null
+++ b/src/c/statisticsFunctions/meanf/zmeanfdz.c
@@ -0,0 +1,25 @@
+/*
+ * 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 "meanf.h"
+#include "zeros.h"
+#include <malloc.h>
+
+doubleComplex zmeanfdz (double* in1 ,int lines , int columns , doubleComplex* in2)
+ {
+ double* ZEROS;
+ ZEROS=malloc((unsigned int)(lines*columns*sizeof(double)));
+ dzerosa(ZEROS,lines,columns);
+
+ return zmeanfa(DoubleComplexMatrix(in1,ZEROS,lines*columns), lines*columns , in2);
+ }
diff --git a/src/c/statisticsFunctions/meanf/zmeanfv.c b/src/c/statisticsFunctions/meanf/zmeanfzd.c
index 3e63495f..41c9cdcc 100644
--- a/src/c/statisticsFunctions/meanf/zmeanfv.c
+++ b/src/c/statisticsFunctions/meanf/zmeanfzd.c
@@ -15,7 +15,7 @@
#include "zeros.h"
#include <malloc.h>
-doubleComplex zmeanfv (doubleComplex* in1 ,int lines , int columns , double* in2)
+doubleComplex zmeanfzd (doubleComplex* in1 ,int lines , int columns , double* in2)
{
double* ZEROS;
ZEROS=malloc((unsigned int)(lines*columns*sizeof(double)));
diff --git a/src/c/statisticsFunctions/meanf/zrowmeanfa.c b/src/c/statisticsFunctions/meanf/zrowmeanfa.c
index 1be43c99..79114137 100644
--- a/src/c/statisticsFunctions/meanf/zrowmeanfa.c
+++ b/src/c/statisticsFunctions/meanf/zrowmeanfa.c
@@ -26,7 +26,7 @@ void zrowmeanfa(doubleComplex *in1, int lines, int columns, doubleComplex *in2,
for ( i = 0 ; i < lines; ++i )
{
- tempMul = zmuls ( in1[lines*j + i] , in2[lines*j + i]); // we times by the coefficient
+ tempMul = zmuls ( in1[lines*j + i] , in2[lines*j + i]); /* we times by the coefficient*/
tempCoefSum = zadds ( in2[lines*j + i] ,tempCoefSum ) ;
out[j] = zadds (tempMul, out[j]) ;
}