summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/statisticsFunctions/center/scentera.c
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/center/scentera.c')
-rw-r--r--2.3-1/src/c/statisticsFunctions/center/scentera.c25
1 files changed, 25 insertions, 0 deletions
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];
+}