diff options
author | Abhinav Dronamraju | 2017-08-10 20:33:46 +0530 |
---|---|---|
committer | Abhinav Dronamraju | 2017-08-10 20:33:46 +0530 |
commit | 5b728d8239b1a1f4467e2485d54c7ed7db1d4f11 (patch) | |
tree | d8db631e058bae294362b2087079150569fc9581 /src/c/statisticsFunctions/center/scentercola.c | |
parent | 6422b5c0a45161d6571fd6d7077b6d551cbb5e26 (diff) | |
parent | 4bc007e5b44a13b582b0275bf7fc6693942ba2ac (diff) | |
download | scilab2c-5b728d8239b1a1f4467e2485d54c7ed7db1d4f11.tar.gz scilab2c-5b728d8239b1a1f4467e2485d54c7ed7db1d4f11.tar.bz2 scilab2c-5b728d8239b1a1f4467e2485d54c7ed7db1d4f11.zip |
Merge and functions added
Diffstat (limited to 'src/c/statisticsFunctions/center/scentercola.c')
-rw-r--r-- | src/c/statisticsFunctions/center/scentercola.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/center/scentercola.c b/src/c/statisticsFunctions/center/scentercola.c new file mode 100644 index 00000000..d5ef5eeb --- /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]; +} |