diff options
39 files changed, 1578 insertions, 0 deletions
diff --git a/2.3-1/demos/Brijesh_Demos/test_center.sci b/2.3-1/demos/Brijesh_Demos/test_center.sci new file mode 100644 index 00000000..92815800 --- /dev/null +++ b/2.3-1/demos/Brijesh_Demos/test_center.sci @@ -0,0 +1,14 @@ +function test_center + disp('Datatype: Double'); + i1 = [1 2 3; 4 5 6]; + o1 = center(i1); + disp(o1); + disp('Datatype: float'); + i2 = float([1 2 3; 4 5 6]); + o2 = center(i2); + disp(o2); + disp('Datatype: Double Complex'); + i3 = [0 %i 3+%i; 4 5*%i 0]; + o3 = center(i3); + disp(o3); +endfunction diff --git a/2.3-1/demos/Brijesh_Demos/test_correl.sci b/2.3-1/demos/Brijesh_Demos/test_correl.sci new file mode 100644 index 00000000..80a09a0e --- /dev/null +++ b/2.3-1/demos/Brijesh_Demos/test_correl.sci @@ -0,0 +1,32 @@ +function test_correl + disp('Datatype: Double'); + i1 = [1 2 3 4 5 6]; + i2 = [1 2 3 3 5 6]; + o1 = correl(i1,i2); + disp(o1); + i3 = [1 2 3 4 5 6]; + i4 = [1 2]; + fre = [1 2 ;3 4; 5 6; 7 8; 9 1; 2 3]; + o2 = correl(i3,i4,fre); + disp(o2); + disp('Datatype: float'); + i5 = float([1 2 3 4 5 6]); + i6 = float([1 2 3 3 5 6]); + o3 = correl(i5,i6); + disp(o3); + i7 = float([1 2 3 4 5 6]); + i8 = float([1 2]); + ffre = float([1 2 ;3 4; 5 6; 7 8; 9 1; 2 3]); + o4 = correl(i7,i8,ffre); + disp(o4); + disp('Datatype: DoubleComplex'); + i9 = [1 2 %i 4 6+6*%i 5]; + i10 = [0 %i 1 4 8*%i 2]; + o5 = correl(i9,i10); + disp(o5); + i11 = [1 2 %i 4 6+6*%i 5]; + i12 = [1 %i]; + zfre = [1 %i ;3 0; 5 6*%i; 7 8; 9 1; 2 3]; + o6 = correl(i11,i12,zfre); + disp(o6); +endfunction diff --git a/2.3-1/demos/Brijesh_Demos/test_wcenter.sci b/2.3-1/demos/Brijesh_Demos/test_wcenter.sci new file mode 100644 index 00000000..921e9ee5 --- /dev/null +++ b/2.3-1/demos/Brijesh_Demos/test_wcenter.sci @@ -0,0 +1,14 @@ +function test_wcenter + disp('Datatype: Double'); + i1 = [1 2 3; 4 5 6]; + o1 = wcenter(i1,2); + disp(o1); + disp('Datatype: float'); + i2 = float([1 2 3; 4 5 6]); + o2 = wcenter(i2,2); + disp(o2); + disp('Datatype: Double Complex'); + i3 = [0 %i 3+%i; 4 5*%i 0]; + o3 = wcenter(i3,2); + disp(o3); +endfunction diff --git a/2.3-1/includes/sci2clib.h b/2.3-1/includes/sci2clib.h index 4a986c66..d7964b5d 100644 --- a/2.3-1/includes/sci2clib.h +++ b/2.3-1/includes/sci2clib.h @@ -668,6 +668,16 @@ extern "C" { /* interfacing variance */ #include "variance.h" #include "int_variance.h" +/* interfacing wcenter */ +#include "wcenter.h" +#include "int_wcenter.h" +/* interfacing center */ +#include "center.h" +#include "int_center.h" +/* interfacing correl */ +#include "correl.h" +#include "int_correl.h" + /* TYPE */ /* interfacing real */ diff --git a/2.3-1/jar/scilab_en_US_help.jar b/2.3-1/jar/scilab_en_US_help.jar Binary files differindex c78f0c25..aeb5ddf2 100644 --- a/2.3-1/jar/scilab_en_US_help.jar +++ b/2.3-1/jar/scilab_en_US_help.jar diff --git a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci index 4e7dd67f..ff5afb5e 100644 --- a/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci +++ b/2.3-1/macros/ToolInitialization/INIT_FillSCI2LibCDirs.sci @@ -1053,6 +1053,134 @@ INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,Ex +// -------------------
+// --- Class WCENTER. ---
+// -------------------
+ClassName = 'wcenter';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+PrintStringInfo('NIN= 1',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= IN(1).SZ(1)',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= IN(1).SZ(2)',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 2',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= IN(1).SZ(1)',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= IN(1).SZ(2)',ClassFileName,'file','y');
+
+
+//---Function list class. ----
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('d2g2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('d2d0'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2g2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2d0'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('z2'+ArgSeparator+'z2',ClassFileName,'file','y');
+PrintStringInfo('z2g2'+ArgSeparator+'z2',ClassFileName,'file','y');
+PrintStringInfo('z2d0'+ArgSeparator+'z2',ClassFileName,'file','y');
+
+
+
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'wcenter';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
+
+
+// -------------------
+// --- Class CENTER. ---
+// -------------------
+ClassName = 'center';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+PrintStringInfo('NIN= 1',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= IN(1).SZ(1)',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= IN(1).SZ(2)',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 2',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= IN(1).SZ(1)',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= IN(1).SZ(2)',ClassFileName,'file','y');
+
+
+//---Function list class. ----
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('d2g2'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('d2d0'+ArgSeparator+'d2',ClassFileName,'file','y');
+PrintStringInfo('s2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2g2'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('s2d0'+ArgSeparator+'s2',ClassFileName,'file','y');
+PrintStringInfo('z2'+ArgSeparator+'z2',ClassFileName,'file','y');
+PrintStringInfo('z2g2'+ArgSeparator+'z2',ClassFileName,'file','y');
+PrintStringInfo('z2d0'+ArgSeparator+'z2',ClassFileName,'file','y');
+
+
+
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'center';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
+
+
+// -------------------
+// --- Class CORREL. ---
+// -------------------
+ClassName = 'correl';
+
+// --- Class Annotation. ---
+PrintStringInfo(' Adding Class: '+ClassName+'.',GeneralReport,'file','y');
+ClassFileName = fullfile(SCI2CLibCAnnClsDir,ClassName+ExtensionCAnnCls);
+PrintStringInfo('NIN= 2',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= ''1''',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= ''1''',ClassFileName,'file','y');
+
+PrintStringInfo('NIN= 3',ClassFileName,'file','y');
+PrintStringInfo('NOUT= 1',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).TP= IN(1).TP',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(1)= ''1''',ClassFileName,'file','y');
+PrintStringInfo('OUT(1).SZ(2)= ''1''',ClassFileName,'file','y');
+
+
+
+//---Function list class. ----
+ClassFileName = fullfile(SCI2CLibCFLClsDir,ClassName+ExtensionCFuncListCls);
+PrintStringInfo('d2d2'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('d2d2d2'+ArgSeparator+'d0',ClassFileName,'file','y');
+PrintStringInfo('s2s2'+ArgSeparator+'s0',ClassFileName,'file','y');
+PrintStringInfo('s2s2s2'+ArgSeparator+'s0',ClassFileName,'file','y');
+PrintStringInfo('z2z2'+ArgSeparator+'z0',ClassFileName,'file','y');
+PrintStringInfo('z2z2z2'+ArgSeparator+'z0',ClassFileName,'file','y');
+
+
+
+// --- Annotation Function And Function List Function. ---
+FunctionName = 'correl';
+PrintStringInfo(' Adding Function: '+FunctionName+'.',GeneralReport,'file','y');
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCAnnFunDir,ClassName,GeneralReport,ExtensionCAnnFun);
+INIT_GenAnnFLFunctions(FunctionName,SCI2CLibCFLFunDir,ClassName,GeneralReport,ExtensionCFuncListFun);
+
+
// -------------------
// --- Class Nanmin. ---
diff --git a/2.3-1/macros/findDeps/getAllHeaders.sci b/2.3-1/macros/findDeps/getAllHeaders.sci index c3376e32..6f417eca 100644 --- a/2.3-1/macros/findDeps/getAllHeaders.sci +++ b/2.3-1/macros/findDeps/getAllHeaders.sci @@ -161,6 +161,9 @@ function allHeaders = getAllHeaders(SharedInfo) "src/c/statisticsFunctions/includes/statMax.h" "src/c/statisticsFunctions/includes/statMin.h" "src/c/statisticsFunctions/includes/moment.h" + "src/c/statisticsFunctions/includes/wcenter.h" + "src/c/statisticsFunctions/includes/center.h" + "src/c/statisticsFunctions/includes/correl.h" "src/c/operations/includes/subtraction.h" "src/c/operations/includes/addition.h" "src/c/operations/includes/dynlib_operations.h" diff --git a/2.3-1/macros/findDeps/getAllInterfaces.sci b/2.3-1/macros/findDeps/getAllInterfaces.sci index d16aadbf..9d44df90 100644 --- a/2.3-1/macros/findDeps/getAllInterfaces.sci +++ b/2.3-1/macros/findDeps/getAllInterfaces.sci @@ -149,6 +149,9 @@ function allInterfaces = getAllInterfaces(SharedInfo) "src/c/statisticsFunctions/interfaces/int_variance.h" "src/c/statisticsFunctions/interfaces/int_sum.h" "src/c/statisticsFunctions/interfaces/int_moment.h" + "src/c/statisticsFunctions/interfaces/int_wcenter.h" + "src/c/statisticsFunctions/interfaces/int_center.h" + "src/c/statisticsFunctions/interfaces/int_correl.h" "src/c/operations/interfaces/int_OpEqual.h" "src/c/operations/interfaces/int_OpLogNot.h" "src/c/operations/interfaces/int_OpLogEq.h" diff --git a/2.3-1/macros/findDeps/getAllSources.sci b/2.3-1/macros/findDeps/getAllSources.sci index dc27e0a9..c3fd3a5f 100644 --- a/2.3-1/macros/findDeps/getAllSources.sci +++ b/2.3-1/macros/findDeps/getAllSources.sci @@ -1076,6 +1076,30 @@ function allSources = getAllSources(SharedInfo,BuildTool) "src/c/statisticsFunctions/moment/zmoments.c" "src/c/statisticsFunctions/moment/zmomentrowa.c" "src/c/statisticsFunctions/moment/zmomentcola.c" + "src/c/statisticsFunctions/wcenter/dwcentera.c" + "src/c/statisticsFunctions/wcenter/dwcenterrowa.c" + "src/c/statisticsFunctions/wcenter/dwcentercola.c" + "src/c/statisticsFunctions/wcenter/swcentera.c" + "src/c/statisticsFunctions/wcenter/swcenterrowa.c" + "src/c/statisticsFunctions/wcenter/swcentercola.c" + "src/c/statisticsFunctions/wcenter/zwcentera.c" + "src/c/statisticsFunctions/wcenter/zwcenterrowa.c" + "src/c/statisticsFunctions/wcenter/zwcentercola.c" + "src/c/statisticsFunctions/center/dcentera.c" + "src/c/statisticsFunctions/center/dcenterrowa.c" + "src/c/statisticsFunctions/center/dcentercola.c" + "src/c/statisticsFunctions/center/scentera.c" + "src/c/statisticsFunctions/center/scenterrowa.c" + "src/c/statisticsFunctions/center/scentercola.c" + "src/c/statisticsFunctions/center/zcentera.c" + "src/c/statisticsFunctions/center/zcenterrowa.c" + "src/c/statisticsFunctions/center/zcentercola.c" + "src/c/statisticsFunctions/correl/dcorrels.c" + "src/c/statisticsFunctions/correl/dcorrelfres.c" + "src/c/statisticsFunctions/correl/scorrels.c" + "src/c/statisticsFunctions/correl/scorrelfres.c" + "src/c/statisticsFunctions/correl/zcorrels.c" + "src/c/statisticsFunctions/correl/zcorrelfres.c" "src/c/operations/multiplication/cmula.c" "src/c/operations/multiplication/cmuls.c" "src/c/operations/multiplication/cmulv.c" diff --git a/2.3-1/src/c/statisticsFunctions/center/dcentera.c b/2.3-1/src/c/statisticsFunctions/center/dcentera.c new file mode 100644 index 00000000..87480386 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcentera.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "center.h" + +void dcentera (double* inp, int row, int col, double* out) +{ + double sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum += inp[i]; + xbar = sum/(row*col); + + double one[row*col]; // Creating a matrix of ones + donesa(one,row,col); + + double prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = one[i]*xbar; + + for(int i = 0; i < row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/dcentercola.c b/2.3-1/src/c/statisticsFunctions/center/dcentercola.c new file mode 100644 index 00000000..e92a1d29 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcentercola.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void dcentercola (double* inp, int row, int col, double* out) +{ + + double sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + double one[col]; // Creating a matrix of ones + donesa(one,1,col); + + + double prod[row*col]; + dmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c new file mode 100644 index 00000000..e6f7e3cd --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void dcenterrowa (double* inp, int row, int col, double* out) +{ + + double sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = 0; + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += inp[j + i*row]; + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = sum[i]/row; + + double one[row]; // Creating a matrix of ones + donesa(one,row,1); + + double prod[row*col]; + dmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/scentera.c b/2.3-1/src/c/statisticsFunctions/center/scentera.c new file mode 100644 index 00000000..2b165be1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/scentera.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "center.h" + +void scentera (float* inp, int row, int col, float* out) +{ + float sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum += inp[i]; + xbar = sum/(row*col); + + float one[row*col]; // Creating a matrix of ones + sonesa(one,row,col); + + float prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = one[i]*xbar; + + for(int i = 0; i < row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/scentercola.c b/2.3-1/src/c/statisticsFunctions/center/scentercola.c new file mode 100644 index 00000000..d5ef5eeb --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/scentercola.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void scentercola (float* inp, int row, int col, float* out) +{ + + float sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + float one[col]; // Creating a matrix of ones + sonesa(one,1,col); + + + float prod[row*col]; + smulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c new file mode 100644 index 00000000..b5910cd9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void scenterrowa (float* inp, int row, int col, float* out) +{ + + float sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = 0; + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += inp[j + i*row]; + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = sum[i]/row; + + float one[row]; // Creating a matrix of ones + sonesa(one,row,1); + + float prod[row*col]; + smulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcentera.c b/2.3-1/src/c/statisticsFunctions/center/zcentera.c new file mode 100644 index 00000000..22ce70d7 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/zcentera.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "center.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zcentera (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + doubleComplex sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum = zadds(sum,inp[i]); + xbar = zrdivs(sum,(row*col)); + + doubleComplex one[row*col]; // Creating a matrix of ones + zonesa(one,row,col); + + doubleComplex prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = zmuls(one[i],xbar); + + for(int i = 0; i < row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcentercola.c b/2.3-1/src/c/statisticsFunctions/center/zcentercola.c new file mode 100644 index 00000000..8a838bc5 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/zcentercola.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "center.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zcentercola (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], inp[i + j*row]); + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = zrdivs(sum[i], col); + + doubleComplex one[col]; // Creating a matrix of ones + zonesa(one,1,col); + + + doubleComplex prod[row*col]; + zmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c new file mode 100644 index 00000000..cddd3403 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "center.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], inp[j + i*row]); + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = zrdivs(sum[i], row); + + doubleComplex one[row]; // Creating a matrix of ones + zonesa(one,row,1); + + doubleComplex prod[row*col]; + zmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c new file mode 100644 index 00000000..7d4c718a --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +double dcorrelfres (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* inp3, int sr3, int sc3) +{ + double p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + double fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 += inp3[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = inp3[i]/s3; + + + + dcolumnsuma(fr, sr3, sc3, p1); + drowsuma(fr, sr3, sc3, p2); + + + + m1 = dmulv(inp1, p1, sr3); + m2 = dmulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = dsqrts(dmulv(diff1, p1, sr3)); + s2 = dsqrts(dmulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = inp1[i] - m1; + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = inp2[i] - m2; + + dmulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return dmulv(diff1, prod, sr3)/(s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c b/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c new file mode 100644 index 00000000..eda07fc1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +double dcorrels (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2) +{ + double m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = dmeana(inp1, sr1*sc1); + m2 = dmeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = dsqrts(dsuma(diff1, sr1*sc1)); + s2 = dsqrts(dsuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum += (inp1[i] - m1) * (inp2[i] - m2); + + return sum / (s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c new file mode 100644 index 00000000..2d056a5b --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +float scorrelfres (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* inp3, int sr3, int sc3) +{ + float p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + float fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 += inp3[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = inp3[i]/s3; + + + + scolumnsuma(fr, sr3, sc3, p1); + srowsuma(fr, sr3, sc3, p2); + + + + m1 = smulv(inp1, p1, sr3); + m2 = smulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = ssqrts(smulv(diff1, p1, sr3)); + s2 = ssqrts(smulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = inp1[i] - m1; + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = inp2[i] - m2; + + smulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return smulv(diff1, prod, sr3)/(s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/scorrels.c b/2.3-1/src/c/statisticsFunctions/correl/scorrels.c new file mode 100644 index 00000000..892d8762 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/scorrels.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +float scorrels (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2) +{ + float m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = smeana(inp1, sr1*sc1); + m2 = smeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = ssqrts(ssuma(diff1, sr1*sc1)); + s2 = ssqrts(ssuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum += (inp1[i] - m1) * (inp2[i] - m2); + + return sum / (s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c new file mode 100644 index 00000000..b026c58a --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c @@ -0,0 +1,58 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "pow.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" +#include "doubleComplex.h" + +doubleComplex zcorrelfres (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* inp3, int sr3, int sc3) +{ + doubleComplex p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + doubleComplex fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 = zadds(s3, inp3[i]); + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = zrdivs(inp3[i],s3); + + + + zcolumnsuma(fr, sr3, sc3, p1); + zrowsuma(fr, sr3, sc3, p2); + + + + m1 = zmulv(inp1, p1, sr3); + m2 = zmulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zpows(zdiffs(inp1[i], m1), DoubleComplex(2,0)); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zpows(zdiffs(inp2[i], m2), DoubleComplex(2,0)); + + + s1 = zsqrts(zmulv(diff1, p1, sr3)); + s2 = zsqrts(zmulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zdiffs(inp1[i], m1); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zdiffs(inp2[i], m2); + + zmulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return zrdivs(zmulv(diff1, prod, sr3), zmuls(s1, s2)); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c b/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c new file mode 100644 index 00000000..818a6800 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "pow.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" +#include "doubleComplex.h" + +doubleComplex zcorrels (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2) +{ + doubleComplex m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = zmeana(inp1, sr1*sc1); + m2 = zmeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zpows(zdiffs(inp1[i], m1), DoubleComplex(2,0)); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zpows(zdiffs(inp2[i], m2), DoubleComplex(2,0)); + + + s1 = zsqrts(zsuma(diff1, sr1*sc1)); + s2 = zsqrts(zsuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum = zadds(sum, zmuls(zdiffs(inp1[i], m1), zdiffs(inp2[i], m2))); + + return zrdivs(sum, zmuls(s1,s2)); +} diff --git a/2.3-1/src/c/statisticsFunctions/includes/center.h b/2.3-1/src/c/statisticsFunctions/includes/center.h new file mode 100644 index 00000000..57a109b3 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/center.h @@ -0,0 +1,47 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __CENTER_H__ +#define __CENTER_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dcentera (double* inp, int row, int col, double* out); +void dcentercola (double* inp, int row, int col, double* out); +void dcenterrowa (double* inp, int row, int col, double* out); + +void scentera (float* inp, int row, int col, float* out); +void scentercola (float* inp, int row, int col, float* out); +void scenterrowa (float* inp, int row, int col, float* out); + +void zcentera (doubleComplex* inp, int row, int col, doubleComplex* out); +void zcentercola (doubleComplex* inp, int row, int col, doubleComplex* out); +void zcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/includes/correl.h b/2.3-1/src/c/statisticsFunctions/includes/correl.h new file mode 100644 index 00000000..8a9c0365 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/correl.h @@ -0,0 +1,48 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __CORREL_H__ +#define __CORREL_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double dcorrels (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2); +double dcorrelfres (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* inp3, int sr3, int sc3); + +float scorrels (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2); +float scorrelfres (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* inp3, int sr3, int sc3); + +doubleComplex zcorrels (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2); +doubleComplex zcorrelfres (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* inp3, int sr3, int sc3); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CORREL_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/includes/wcenter.h b/2.3-1/src/c/statisticsFunctions/includes/wcenter.h new file mode 100644 index 00000000..3919fd37 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/wcenter.h @@ -0,0 +1,47 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __WCENTER_H__ +#define __WCENTER_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "sqrt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dwcentera (double* inp, int row, int col, double* out); +void dwcentercola (double* inp, int row, int col, double* out); +void dwcenterrowa (double* inp, int row, int col, double* out); + +void swcentera (float* inp, int row, int col, float* out); +void swcentercola (float* inp, int row, int col, float* out); +void swcenterrowa (float* inp, int row, int col, float* out); + +void zwcentera (doubleComplex* inp, int row, int col, doubleComplex* out); +void zwcentercola (doubleComplex* inp, int row, int col, doubleComplex* out); +void zwcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__WCENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h new file mode 100644 index 00000000..041937e0 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h @@ -0,0 +1,36 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_CENTER_H__ +#define __INT_CENTER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2centerd2(in1,size, out) dcentera(in1,size[0],size[1],out) +#define d2g2centerd2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? dcenterrowa(in1, size[0], size[1], out) : dcentercola(in1, size[0], size[1], out) +#define d2d0centerd2(in1, size, in2 ,out) (in2 == 1) ? dcenterrowa(in1, size[0], size[1], out) : dcentercola(in1, size[0], size[1], out) + +#define s2centers2(in1,size, out) scentera(in1,size[0],size[1],out) +#define s2g2centers2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? scenterrowa(in1, size[0], size[1], out) : scentercola(in1, size[0], size[1], out) +#define s2d0centers2(in1, size, in2 ,out) (in2 == 1) ? scenterrowa(in1, size[0], size[1], out) : scentercola(in1, size[0], size[1], out) + +#define z2centerz2(in1,size, out) zcentera(in1,size[0],size[1],out) +#define z2g2centerz2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? zcenterrowa(in1, size[0], size[1], out) : zcentercola(in1, size[0], size[1], out) +#define z2d0centerz2(in1, size, in2 ,out) (in2 == 1) ? zcenterrowa(in1, size[0], size[1], out) : zcentercola(in1, size[0], size[1], out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h new file mode 100644 index 00000000..8dd5c31e --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h @@ -0,0 +1,34 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_CORREL_H__ +#define __INT_CORREL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define d2d2correld0(in1, size, in2, size2) dcorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define d2d2d2correld0(in1, size, in2, size2, in3, size3) dcorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + +#define s2s2correls0(in1, size, in2, size2) scorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define s2s2s2correls0(in1, size, in2, size2, in3, size3) scorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + +#define z2z2correlz0(in1, size, in2, size2) zcorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define z2z2z2correlz0(in1, size, in2, size2, in3, size3) zcorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CORREL_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h new file mode 100644 index 00000000..38273af1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h @@ -0,0 +1,36 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_WCENTER_H__ +#define __INT_WCENTER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2wcenterd2(in1,size, out) dwcentera(in1,size[0],size[1],out) +#define d2g2wcenterd2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? dwcenterrowa(in1, size[0], size[1], out) : dwcentercola(in1, size[0], size[1], out) +#define d2d0wcenterd2(in1, size, in2 ,out) (in2 == 1) ? dwcenterrowa(in1, size[0], size[1], out) : dwcentercola(in1, size[0], size[1], out) + +#define s2wcenters2(in1,size, out) swcentera(in1,size[0],size[1],out) +#define s2g2wcenters2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? swcenterrowa(in1, size[0], size[1], out) : swcentercola(in1, size[0], size[1], out) +#define s2d0wcenters2(in1, size, in2 ,out) (in2 == 1) ? swcenterrowa(in1, size[0], size[1], out) : swcentercola(in1, size[0], size[1], out) + +#define z2wcenterz2(in1,size, out) zwcentera(in1,size[0],size[1],out) +#define z2g2wcenterz2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? zwcenterrowa(in1, size[0], size[1], out) : zwcentercola(in1, size[0], size[1], out) +#define z2d0wcenterz2(in1, size, in2 ,out) (in2 == 1) ? zwcenterrowa(in1, size[0], size[1], out) : zwcentercola(in1, size[0], size[1], out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_WCENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c new file mode 100644 index 00000000..5c05cc86 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "wcenter.h" + +void dwcentera (double* inp, int row, int col, double* out) +{ + double sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum += inp[i]; + xbar = sum/(row*col); + + double one[row*col]; // Creating a matrix of ones + donesa(one,row,col); + + double prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = one[i]*xbar; + + for(int i = 0; i < row*col; i++) + out[i] = inp[i] - prod[i]; + + sum = 0; + for(int i = 0; i < row*col; i++) + sum = sum + out[i]*out[i]; + + sigma = sqrt(sum/(row*col-1)); + + for(int i = 0; i < row*col; i++) + out[i] = out[i]/sigma; +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c new file mode 100644 index 00000000..ab82acfe --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void dwcentercola (double* inp, int row, int col, double* out) +{ + + double sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + //for(int i = 0; i < row; i++) + //printf("%lf \n",sum[i]); + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + double one[col]; // Creating a matrix of ones + donesa(one,1,col); + + + double prod[row*col]; + dmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + for(int i = 0; i < row; i++) + sum[i] = 0; + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += out[i + j*row] * out[i + j*row]; + } + } + + double sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = sqrt(sum[i]/(col-1)); + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + dmulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c new file mode 100644 index 00000000..72e37931 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void dwcenterrowa (double* inp, int row, int col, double* out) +{ + + double sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = 0; + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += inp[j + i*row]; + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = sum[i]/row; + + double one[row]; // Creating a matrix of ones + donesa(one,row,1); + + double prod[row*col]; + dmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + + for(int i = 0; i < col; i++) + sum[i] = 0; + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += out[j + i*row] * out[j + i*row]; + } + } + + + + double sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = sqrt(sum[i]/(row-1)); + + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + dmulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c new file mode 100644 index 00000000..91206fcf --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "wcenter.h" + +void swcentera (float* inp, int row, int col, float* out) +{ + float sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum += inp[i]; + xbar = sum/(row*col); + + float one[row*col]; // Creating a matrix of ones + sonesa(one,row,col); + + float prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = one[i]*xbar; + + for(int i = 0; i < row*col; i++) + out[i] = inp[i] - prod[i]; + + sum = 0; + for(int i = 0; i < row*col; i++) + sum = sum + out[i]*out[i]; + + sigma = sqrt(sum/(row*col-1)); + + for(int i = 0; i < row*col; i++) + out[i] = out[i]/sigma; +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c new file mode 100644 index 00000000..6fafe9f9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void swcentercola (float* inp, int row, int col, float* out) +{ + + float sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + float one[col]; // Creating a matrix of ones + sonesa(one,1,col); + + + float prod[row*col]; + smulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + for(int i = 0; i < row; i++) + sum[i] = 0; + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += out[i + j*row] * out[i + j*row]; + } + } + + float sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = sqrt(sum[i]/(col-1)); + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + smulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c new file mode 100644 index 00000000..ce1df2e9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void swcenterrowa (float* inp, int row, int col, float* out) +{ + + float sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = 0; + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += inp[j + i*row]; + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = sum[i]/row; + + float one[row]; // Creating a matrix of ones + sonesa(one,row,1); + + float prod[row*col]; + smulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + + for(int i = 0; i < col; i++) + sum[i] = 0; + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] += out[j + i*row] * out[j + i*row]; + } + } + + + + float sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = sqrt(sum[i]/(row-1)); + + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + smulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c new file mode 100644 index 00000000..8571dd62 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcentera (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + doubleComplex sum = 0, xbar = 0, sigma = 0; + for(int i = 0; i < row*col; i++) // Findinag the maen of all the elements of the matrix + sum = zadds(sum,inp[i]); + xbar = zrdivs(sum,(row*col)); + + doubleComplex one[row*col]; // Creating a matrix of ones + zonesa(one,row,col); + + doubleComplex prod[row*col]; + for(int i = 0; i < row*col; i++) // Applying the formula (x(i,j)-xbar)/sigma + prod[i] = zmuls(one[i],xbar); + + for(int i = 0; i < row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); + + sum = DoubleComplex(0,0); + for(int i = 0; i < row*col; i++) + sum = zadds(sum, zmuls(out[i],out[i])); + + sigma = zsqrts(zrdivs(sum,(row*col-1))); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i],sigma); +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c new file mode 100644 index 00000000..5e4e2bdd --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c @@ -0,0 +1,66 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcentercola (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], inp[i + j*row]); + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = zrdivs(sum[i], col); + + doubleComplex one[col]; // Creating a matrix of ones + zonesa(one,1,col); + + + doubleComplex prod[row*col]; + zmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); + + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], zmuls(out[i + j*row], out[i + j*row])); + } + } + + doubleComplex sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = zsqrts(zrdivs(sum[i],(col-1))); + + for(int i = 0; i < row*col; i++) + prod[i] = DoubleComplex(0,0); + + zmulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i], prod[i]); + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c new file mode 100644 index 00000000..f68835d8 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c @@ -0,0 +1,72 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "addition.h" +#include "subtraction.h" +#include "multiplication.h" +#include "division.h" +#include "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], inp[j + i*row]); + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = zrdivs(sum[i], row); + + doubleComplex one[row]; // Creating a matrix of ones + zonesa(one,row,1); + + doubleComplex prod[row*col]; + zmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); + + + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], zmuls(out[j + i*row], out[j + i*row])); + } + } + + + + doubleComplex sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = zsqrts(zrdivs(sum[i],(row-1))); + + + for(int i = 0; i < row*col; i++) + prod[i] = DoubleComplex(0,0); + + zmulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i], prod[i]); + +} |