summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrijeshcr2017-08-04 21:40:41 +0530
committerBrijeshcr2017-08-04 21:40:41 +0530
commitad787796e65e1debe25871a98f9713f23d655ae4 (patch)
tree366cdd52cae4308686b47a5f30894f591155c2ef /src
parent49dd0d9d013d80ad685a3c32b6f0a2f97349e710 (diff)
downloadScilab2C_fossee_old-ad787796e65e1debe25871a98f9713f23d655ae4.tar.gz
Scilab2C_fossee_old-ad787796e65e1debe25871a98f9713f23d655ae4.tar.bz2
Scilab2C_fossee_old-ad787796e65e1debe25871a98f9713f23d655ae4.zip
Added Covar
Diffstat (limited to 'src')
-rw-r--r--src/c/statisticsFunctions/covar/dcovars.c70
-rw-r--r--src/c/statisticsFunctions/covar/scovars.c70
-rw-r--r--src/c/statisticsFunctions/covar/zcovars.c71
-rw-r--r--src/c/statisticsFunctions/includes/covar.h43
-rw-r--r--src/c/statisticsFunctions/interfaces/int_covar.h29
5 files changed, 283 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/covar/dcovars.c b/src/c/statisticsFunctions/covar/dcovars.c
new file mode 100644
index 0000000..f67905e
--- /dev/null
+++ b/src/c/statisticsFunctions/covar/dcovars.c
@@ -0,0 +1,70 @@
+#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 "sqrt.h"
+#include "sum.h"
+#include "correl.h"
+#include "matrix.h"
+#include "mean.h"
+
+double dcovars (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* fre, int sr3, int sc3)
+{
+ double fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0;
+
+ for(int i = 0; i < sr3*sc3; i++)
+ s3 += fre[i];
+
+ for(int i = 0; i < sr3*sc3; i++)
+ fr[i] = fre[i]/s3;
+
+ drowsuma(fr, sr3, sc3, sfrr);
+
+ for(int i = 0; i < sc3; i++)
+ p1[i] = inp2[i] * sfrr[i];
+
+ for(int i = 0; i < sc3; i++)
+ s1 += p1[i];
+
+
+
+ for(int i = 0; i < sc2; i++)
+ d1[i] = inp2[i] - s1;
+
+ donesa(one, sr1*sc1, 1);
+
+ dmulma(one, sr1*sc1, 1, d1, 1, sc2, p2);
+
+ for(int i = 0; i < sr3*sc3; i++)
+ p3[i] = fr[i] * p2[i];
+
+ dcolumnsuma(fr, sr3, sc3, sfrc);
+
+ for(int i = 0; i < sr3; i++)
+ p4[i] = inp1[i] * sfrc[i];
+
+ for(int i = 0; i < sr3; i++)
+ s2 += p4[i];
+
+ for(int i = 0; i < sr1*sc1; i++)
+ d2[i] = inp1[i] - s2;
+
+ donesa(one2, 1, sr2*sc2);
+
+ dmulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5);
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ p6[i] = p5[i] * p3[i];
+
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ s4 += p6[i];
+
+
+ return s4;
+
+}
diff --git a/src/c/statisticsFunctions/covar/scovars.c b/src/c/statisticsFunctions/covar/scovars.c
new file mode 100644
index 0000000..daff6b9
--- /dev/null
+++ b/src/c/statisticsFunctions/covar/scovars.c
@@ -0,0 +1,70 @@
+#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 "sqrt.h"
+#include "sum.h"
+#include "correl.h"
+#include "matrix.h"
+#include "mean.h"
+
+float scovars (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* fre, int sr3, int sc3)
+{
+ float fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0;
+
+ for(int i = 0; i < sr3*sc3; i++)
+ s3 += fre[i];
+
+ for(int i = 0; i < sr3*sc3; i++)
+ fr[i] = fre[i]/s3;
+
+ srowsuma(fr, sr3, sc3, sfrr);
+
+ for(int i = 0; i < sc3; i++)
+ p1[i] = inp2[i] * sfrr[i];
+
+ for(int i = 0; i < sc3; i++)
+ s1 += p1[i];
+
+
+
+ for(int i = 0; i < sc2; i++)
+ d1[i] = inp2[i] - s1;
+
+ sonesa(one, sr1*sc1, 1);
+
+ smulma(one, sr1*sc1, 1, d1, 1, sc2, p2);
+
+ for(int i = 0; i < sr3*sc3; i++)
+ p3[i] = fr[i] * p2[i];
+
+ scolumnsuma(fr, sr3, sc3, sfrc);
+
+ for(int i = 0; i < sr3; i++)
+ p4[i] = inp1[i] * sfrc[i];
+
+ for(int i = 0; i < sr3; i++)
+ s2 += p4[i];
+
+ for(int i = 0; i < sr1*sc1; i++)
+ d2[i] = inp1[i] - s2;
+
+ sonesa(one2, 1, sr2*sc2);
+
+ smulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5);
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ p6[i] = p5[i] * p3[i];
+
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ s4 += p6[i];
+
+
+ return s4;
+
+}
diff --git a/src/c/statisticsFunctions/covar/zcovars.c b/src/c/statisticsFunctions/covar/zcovars.c
new file mode 100644
index 0000000..6adbd3c
--- /dev/null
+++ b/src/c/statisticsFunctions/covar/zcovars.c
@@ -0,0 +1,71 @@
+#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 "sqrt.h"
+#include "sum.h"
+#include "correl.h"
+#include "matrix.h"
+#include "mean.h"
+#include "doubleComplex.h"
+
+doubleComplex zcovars (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* fre, int sr3, int sc3)
+{
+ doubleComplex fr[sr3*sc3], s3 = 0, sfrr[sc3], p1[sc2*sc3], s1 = 0, d1[sc2] , one[sr1*sc1], p2[sc1 * sc2], p3[sr3*sc3], sfrc[sr3], p4[sr3], s2 = 0, d2[sr1*sc1], one2[sr2*sc2], p5[sr1*sc1*sr2*sc2], p6[sr1*sc1*sr2*sc2],s4 = 0;
+
+ for(int i = 0; i < sr3*sc3; i++)
+ s3 = zadds(s3, fre[i]);
+
+ for(int i = 0; i < sr3*sc3; i++)
+ fr[i] = zrdivs(fre[i], s3);
+
+ zrowsuma(fr, sr3, sc3, sfrr);
+
+ for(int i = 0; i < sc3; i++)
+ p1[i] = zmuls(inp2[i], sfrr[i]);
+
+ for(int i = 0; i < sc3; i++)
+ s1 = zadds(s1, p1[i]);
+
+
+
+ for(int i = 0; i < sc2; i++)
+ d1[i] = zdiffs(inp2[i], s1);
+
+ zonesa(one, sr1*sc1, 1);
+
+ zmulma(one, sr1*sc1, 1, d1, 1, sc2, p2);
+
+ for(int i = 0; i < sr3*sc3; i++)
+ p3[i] = fr[i] * p2[i];
+
+ zcolumnsuma(fr, sr3, sc3, sfrc);
+
+ for(int i = 0; i < sr3; i++)
+ p4[i] = zmuls(inp1[i], sfrc[i]);
+
+ for(int i = 0; i < sr3; i++)
+ s2 = zadds(s2, p4[i]);
+
+ for(int i = 0; i < sr1*sc1; i++)
+ d2[i] = zdiffs(inp1[i], s2);
+
+ zonesa(one2, 1, sr2*sc2);
+
+ zmulma(d2, sr1*sc1, 1, one2, 1, sr2*sc2, p5);
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ p6[i] = zmuls(p5[i], p3[i]);
+
+
+ for(int i = 0; i < sr1*sc1*sr2*sc2; i++)
+ s4 = zadds(s4, p6[i]);
+
+
+ return s4;
+
+}
diff --git a/src/c/statisticsFunctions/includes/covar.h b/src/c/statisticsFunctions/includes/covar.h
new file mode 100644
index 0000000..4f37f85
--- /dev/null
+++ b/src/c/statisticsFunctions/includes/covar.h
@@ -0,0 +1,43 @@
+ /* Copyright (C) 2017 - 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __COVAR_H__
+#define __COVAR_H__
+#include "types.h"
+#include "doubleComplex.h"
+#include "floatComplex.h"
+#include <math.h>
+#include <ones.h>
+#include "addition.h"
+#include "subtraction.h"
+#include "multiplication.h"
+#include "division.h"
+#include "sqrt.h"
+#include "sum.h"
+#include "correl.h"
+#include "matrix.h"
+#include "mean.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+double dcovars (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* fre, int sr3, int sc3);
+float scovars (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* fre, int sr3, int sc3);
+doubleComplex zcovars (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* fre, int sr3, int sc3);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__COVAR_H__*/
diff --git a/src/c/statisticsFunctions/interfaces/int_covar.h b/src/c/statisticsFunctions/interfaces/int_covar.h
new file mode 100644
index 0000000..5ebef22
--- /dev/null
+++ b/src/c/statisticsFunctions/interfaces/int_covar.h
@@ -0,0 +1,29 @@
+ /* Copyright (C) 2017 - 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_COVAR_H__
+#define __INT_COVAR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define d2d2d2covard0(in1, size, in2, size2, in3, size3) dcovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1])
+#define s2s2s2covars0(in1, size, in2, size2, in3, size3) scovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1])
+#define z2z2z2covarz0(in1, size, in2, size2, in3, size3) zcovars(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1])
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_COVAR_H__*/