summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/statisticsFunctions')
-rw-r--r--src/c/statisticsFunctions/includes/mvcorrel.h33
-rw-r--r--src/c/statisticsFunctions/interfaces/int_mvcorrel.h28
-rw-r--r--src/c/statisticsFunctions/mvcorrel/dmvcorrela.c69
3 files changed, 130 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/includes/mvcorrel.h b/src/c/statisticsFunctions/includes/mvcorrel.h
new file mode 100644
index 0000000..857bfd6
--- /dev/null
+++ b/src/c/statisticsFunctions/includes/mvcorrel.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+
+#ifndef __MVCORREL_H__
+#define __MVCORREL_H__
+
+#include "types.h"
+#include "doubleComplex.h"
+#include "uint16.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dmvcorrela(double* , int, int, double* );
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__MVCORREL_H__*/
diff --git a/src/c/statisticsFunctions/interfaces/int_mvcorrel.h b/src/c/statisticsFunctions/interfaces/int_mvcorrel.h
new file mode 100644
index 0000000..361687b
--- /dev/null
+++ b/src/c/statisticsFunctions/interfaces/int_mvcorrel.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#ifndef __INT_MVCORREL_H__
+#define __INT_MVCORREL_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d2mvcorreld2(in1, size, out) dmvcorrela(in1, size[0] ,size[1], out)
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_MVCORREL_H__*/
diff --git a/src/c/statisticsFunctions/mvcorrel/dmvcorrela.c b/src/c/statisticsFunctions/mvcorrel/dmvcorrela.c
new file mode 100644
index 0000000..646e3db
--- /dev/null
+++ b/src/c/statisticsFunctions/mvcorrel/dmvcorrela.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+
+#include "mvcorrel.h"
+#include "stdio.h"
+#include "types.h"
+#include "uint16.h"
+#include "zeros.h"
+#include "sum.h"
+#include "ones.h"
+#include "matrixMultiplication.h"
+#include "subtraction.h"
+
+void dmvcorrela(double *in, int lx, int cx, double* out)
+{
+ double temp1[1* cx];
+ double xbar[1* cx];
+ double temp2[lx*1];
+ double temp3[lx*cx];
+ double temp4[lx*cx];
+ double temp5[1* cx];
+ double std[1*cx];
+
+ donesa ( temp2 , lx , 1 ); //temp2= ones(lx,1)
+
+ if(lx==1)
+ {
+ dzerosa ( out , lx ,cx ); //out= zeros(lx,cx)
+
+ }
+
+ else
+ {
+
+ drowsuma(in, lx, cx, temp1); //temp1= sum(x, "r")
+
+ for(int i=0; i< 1*cx; i++)
+ xbar[i]= temp1[i]/ lx; // xbar= sum(x, "r")/ lx
+ //Debug Only
+ for(int i= 0; i< 1*cx; i++)
+ printf("xbar[%d]= %lf", i, xbar[i]);
+ printf("\n");
+
+ dmulma(temp2, lx,1, xbar, 1, cx, temp3 ); //temp3= ones(lx,1)*xbar
+ ddiffa(in, lx*cx, temp3, lx*cx, temp4); //temp4= x-ones(lx,1)*xbar
+ for(int i=0; i< lx*cx; i++)
+ temp4[i]= pow(temp4[i], 2);
+ drowsuma(temp4, lx, cx, temp5); //temp5= sum(r.^2, "r")
+ for(int i=0; i< 1*cx; i++)
+ std[i]= pow(temp5[i], 0.5);
+ //Debug Only
+ for(int i= 0; i< 1*cx; i++)
+ printf("std[%d]= %lf", i, std[i]);
+ printf("\n");
+ }
+
+
+
+}