From ee498f417540084c08cf335a03cdefcd3fa853e4 Mon Sep 17 00:00:00 2001 From: Brijeshcr Date: Fri, 4 Aug 2017 17:58:41 +0530 Subject: Added Center, Wcenter and Correl --- src/c/statisticsFunctions/center/scenterrowa.c | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/c/statisticsFunctions/center/scenterrowa.c (limited to 'src/c/statisticsFunctions/center/scenterrowa.c') 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 +#include +#include +#include +#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]; +} -- cgit