diff options
author | Brijeshcr | 2017-08-04 17:58:41 +0530 |
---|---|---|
committer | Brijeshcr | 2017-08-04 17:58:41 +0530 |
commit | ee498f417540084c08cf335a03cdefcd3fa853e4 (patch) | |
tree | 57baa6014bb85da001014ab74468a6922f5f6b2a /src/c/statisticsFunctions/center | |
parent | e47a705e2a330fc6745ad406d04d63075df65492 (diff) | |
download | Scilab2C_fossee_old-ee498f417540084c08cf335a03cdefcd3fa853e4.tar.gz Scilab2C_fossee_old-ee498f417540084c08cf335a03cdefcd3fa853e4.tar.bz2 Scilab2C_fossee_old-ee498f417540084c08cf335a03cdefcd3fa853e4.zip |
Added Center, Wcenter and Correl
Diffstat (limited to 'src/c/statisticsFunctions/center')
-rw-r--r-- | src/c/statisticsFunctions/center/dcentera.c | 25 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/dcentercola.c | 38 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/dcenterrowa.c | 40 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/scentera.c | 25 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/scentercola.c | 37 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/scenterrowa.c | 40 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/zcentera.c | 29 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/zcentercola.c | 42 | ||||
-rw-r--r-- | src/c/statisticsFunctions/center/zcenterrowa.c | 44 |
9 files changed, 320 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/center/dcentera.c b/src/c/statisticsFunctions/center/dcentera.c new file mode 100644 index 0000000..8748038 --- /dev/null +++ b/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/src/c/statisticsFunctions/center/dcentercola.c b/src/c/statisticsFunctions/center/dcentercola.c new file mode 100644 index 0000000..e92a1d2 --- /dev/null +++ b/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/src/c/statisticsFunctions/center/dcenterrowa.c b/src/c/statisticsFunctions/center/dcenterrowa.c new file mode 100644 index 0000000..e6f7e3c --- /dev/null +++ b/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/src/c/statisticsFunctions/center/scentera.c b/src/c/statisticsFunctions/center/scentera.c new file mode 100644 index 0000000..2b165be --- /dev/null +++ b/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/src/c/statisticsFunctions/center/scentercola.c b/src/c/statisticsFunctions/center/scentercola.c new file mode 100644 index 0000000..d5ef5ee --- /dev/null +++ b/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/src/c/statisticsFunctions/center/scenterrowa.c b/src/c/statisticsFunctions/center/scenterrowa.c new file mode 100644 index 0000000..b5910cd --- /dev/null +++ b/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/src/c/statisticsFunctions/center/zcentera.c b/src/c/statisticsFunctions/center/zcentera.c new file mode 100644 index 0000000..22ce70d --- /dev/null +++ b/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/src/c/statisticsFunctions/center/zcentercola.c b/src/c/statisticsFunctions/center/zcentercola.c new file mode 100644 index 0000000..8a838bc --- /dev/null +++ b/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/src/c/statisticsFunctions/center/zcenterrowa.c b/src/c/statisticsFunctions/center/zcenterrowa.c new file mode 100644 index 0000000..cddd340 --- /dev/null +++ b/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]); +} |