summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/center/zcentera.c
diff options
context:
space:
mode:
authorBrijeshcr2017-08-04 17:58:41 +0530
committerBrijeshcr2017-08-04 17:58:41 +0530
commitee498f417540084c08cf335a03cdefcd3fa853e4 (patch)
tree57baa6014bb85da001014ab74468a6922f5f6b2a /src/c/statisticsFunctions/center/zcentera.c
parente47a705e2a330fc6745ad406d04d63075df65492 (diff)
downloadScilab2C_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/zcentera.c')
-rw-r--r--src/c/statisticsFunctions/center/zcentera.c29
1 files changed, 29 insertions, 0 deletions
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]);
+}