diff options
Diffstat (limited to '2.3-1/src')
30 files changed, 1350 insertions, 0 deletions
diff --git a/2.3-1/src/c/statisticsFunctions/center/dcentera.c b/2.3-1/src/c/statisticsFunctions/center/dcentera.c new file mode 100644 index 00000000..87480386 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcentera.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 dcentera (double* inp, int row, int col, double* out) +{ + double 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); + + double one[row*col]; // Creating a matrix of ones + donesa(one,row,col); + + double 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]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/dcentercola.c b/2.3-1/src/c/statisticsFunctions/center/dcentercola.c new file mode 100644 index 00000000..e92a1d29 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcentercola.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void dcentercola (double* inp, int row, int col, double* out) +{ + + double sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + double one[col]; // Creating a matrix of ones + donesa(one,1,col); + + + double prod[row*col]; + dmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c new file mode 100644 index 00000000..e6f7e3cd --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/dcenterrowa.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void dcenterrowa (double* inp, int row, int col, double* out) +{ + + double 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; + + double one[row]; // Creating a matrix of ones + donesa(one,row,1); + + double prod[row*col]; + dmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} 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]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/scentercola.c b/2.3-1/src/c/statisticsFunctions/center/scentercola.c new file mode 100644 index 00000000..d5ef5eeb --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/scentercola.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "center.h" + +void scentercola (float* inp, int row, int col, float* out) +{ + + float sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + float one[col]; // Creating a matrix of ones + sonesa(one,1,col); + + + float prod[row*col]; + smulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c new file mode 100644 index 00000000..b5910cd9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/scenterrowa.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#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]; +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcentera.c b/2.3-1/src/c/statisticsFunctions/center/zcentera.c new file mode 100644 index 00000000..22ce70d7 --- /dev/null +++ b/2.3-1/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]); +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcentercola.c b/2.3-1/src/c/statisticsFunctions/center/zcentercola.c new file mode 100644 index 00000000..8a838bc5 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/zcentercola.c @@ -0,0 +1,42 @@ +#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 zcentercola (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], inp[i + j*row]); + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = zrdivs(sum[i], col); + + doubleComplex one[col]; // Creating a matrix of ones + zonesa(one,1,col); + + + doubleComplex prod[row*col]; + zmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); +} diff --git a/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c b/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c new file mode 100644 index 00000000..cddd3403 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/center/zcenterrowa.c @@ -0,0 +1,44 @@ +#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 zcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], inp[j + i*row]); + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = zrdivs(sum[i], row); + + doubleComplex one[row]; // Creating a matrix of ones + zonesa(one,row,1); + + doubleComplex prod[row*col]; + zmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c new file mode 100644 index 00000000..7d4c718a --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/dcorrelfres.c @@ -0,0 +1,56 @@ +#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 dcorrelfres (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* inp3, int sr3, int sc3) +{ + double p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + double fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 += inp3[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = inp3[i]/s3; + + + + dcolumnsuma(fr, sr3, sc3, p1); + drowsuma(fr, sr3, sc3, p2); + + + + m1 = dmulv(inp1, p1, sr3); + m2 = dmulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = dsqrts(dmulv(diff1, p1, sr3)); + s2 = dsqrts(dmulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = inp1[i] - m1; + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = inp2[i] - m2; + + dmulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return dmulv(diff1, prod, sr3)/(s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c b/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c new file mode 100644 index 00000000..eda07fc1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/dcorrels.c @@ -0,0 +1,35 @@ +#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 dcorrels (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2) +{ + double m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = dmeana(inp1, sr1*sc1); + m2 = dmeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = dsqrts(dsuma(diff1, sr1*sc1)); + s2 = dsqrts(dsuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum += (inp1[i] - m1) * (inp2[i] - m2); + + return sum / (s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c new file mode 100644 index 00000000..2d056a5b --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/scorrelfres.c @@ -0,0 +1,56 @@ +#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 scorrelfres (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* inp3, int sr3, int sc3) +{ + float p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + float fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 += inp3[i]; + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = inp3[i]/s3; + + + + scolumnsuma(fr, sr3, sc3, p1); + srowsuma(fr, sr3, sc3, p2); + + + + m1 = smulv(inp1, p1, sr3); + m2 = smulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = ssqrts(smulv(diff1, p1, sr3)); + s2 = ssqrts(smulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = inp1[i] - m1; + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = inp2[i] - m2; + + smulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return smulv(diff1, prod, sr3)/(s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/scorrels.c b/2.3-1/src/c/statisticsFunctions/correl/scorrels.c new file mode 100644 index 00000000..892d8762 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/scorrels.c @@ -0,0 +1,35 @@ +#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 scorrels (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2) +{ + float m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = smeana(inp1, sr1*sc1); + m2 = smeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = pow(inp1[i] - m1, 2); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = pow(inp2[i] - m2, 2); + + + s1 = ssqrts(ssuma(diff1, sr1*sc1)); + s2 = ssqrts(ssuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum += (inp1[i] - m1) * (inp2[i] - m2); + + return sum / (s1*s2); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c b/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c new file mode 100644 index 00000000..b026c58a --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/zcorrelfres.c @@ -0,0 +1,58 @@ +#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 "pow.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" +#include "doubleComplex.h" + +doubleComplex zcorrelfres (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* inp3, int sr3, int sc3) +{ + doubleComplex p1[sr3], p2[sc3], m1 = 0, m2 = 0, s1 = 0, s2 = 0, s3 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0, prod[sr3]; + + doubleComplex fr[sr3*sc3]; + + for(int i = 0; i < sr3*sc3; i++) + s3 = zadds(s3, inp3[i]); + + for(int i = 0; i < sr3*sc3; i++) + fr[i] = zrdivs(inp3[i],s3); + + + + zcolumnsuma(fr, sr3, sc3, p1); + zrowsuma(fr, sr3, sc3, p2); + + + + m1 = zmulv(inp1, p1, sr3); + m2 = zmulv(inp2, p2, sc3); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zpows(zdiffs(inp1[i], m1), DoubleComplex(2,0)); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zpows(zdiffs(inp2[i], m2), DoubleComplex(2,0)); + + + s1 = zsqrts(zmulv(diff1, p1, sr3)); + s2 = zsqrts(zmulv(p2, diff2, sc3)); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zdiffs(inp1[i], m1); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zdiffs(inp2[i], m2); + + zmulma(fr, sr3, sc3, diff2, sc2, 1, prod); + + return zrdivs(zmulv(diff1, prod, sr3), zmuls(s1, s2)); +} diff --git a/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c b/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c new file mode 100644 index 00000000..818a6800 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/correl/zcorrels.c @@ -0,0 +1,37 @@ +#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 "pow.h" +#include "sqrt.h" +#include "sum.h" +#include "correl.h" +#include "matrix.h" +#include "mean.h" +#include "doubleComplex.h" + +doubleComplex zcorrels (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2) +{ + doubleComplex m1 = 0, m2 = 0, s1 = 0, s2 = 0, diff1[sr1*sc1], diff2[sr2*sc2], sum = 0; + m1 = zmeana(inp1, sr1*sc1); + m2 = zmeana(inp2, sr2*sc2); + + for(int i = 0; i < sr1*sc1; i++) + diff1[i] = zpows(zdiffs(inp1[i], m1), DoubleComplex(2,0)); + + for(int i = 0; i < sr2*sc2; i++) + diff2[i] = zpows(zdiffs(inp2[i], m2), DoubleComplex(2,0)); + + + s1 = zsqrts(zsuma(diff1, sr1*sc1)); + s2 = zsqrts(zsuma(diff2, sr2*sc2)); + + for(int i = 0; i < sr2*sc2; i++) + sum = zadds(sum, zmuls(zdiffs(inp1[i], m1), zdiffs(inp2[i], m2))); + + return zrdivs(sum, zmuls(s1,s2)); +} diff --git a/2.3-1/src/c/statisticsFunctions/includes/center.h b/2.3-1/src/c/statisticsFunctions/includes/center.h new file mode 100644 index 00000000..57a109b3 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/center.h @@ -0,0 +1,47 @@ + /* 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 __CENTER_H__ +#define __CENTER_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" + +#ifdef __cplusplus +extern "C" { +#endif + +void dcentera (double* inp, int row, int col, double* out); +void dcentercola (double* inp, int row, int col, double* out); +void dcenterrowa (double* inp, int row, int col, double* out); + +void scentera (float* inp, int row, int col, float* out); +void scentercola (float* inp, int row, int col, float* out); +void scenterrowa (float* inp, int row, int col, float* out); + +void zcentera (doubleComplex* inp, int row, int col, doubleComplex* out); +void zcentercola (doubleComplex* inp, int row, int col, doubleComplex* out); +void zcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/includes/correl.h b/2.3-1/src/c/statisticsFunctions/includes/correl.h new file mode 100644 index 00000000..8a9c0365 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/correl.h @@ -0,0 +1,48 @@ + /* 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 __CORREL_H__ +#define __CORREL_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 dcorrels (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2); +double dcorrelfres (double* inp1, int sr1, int sc1, double* inp2, int sr2, int sc2, double* inp3, int sr3, int sc3); + +float scorrels (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2); +float scorrelfres (float* inp1, int sr1, int sc1, float* inp2, int sr2, int sc2, float* inp3, int sr3, int sc3); + +doubleComplex zcorrels (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2); +doubleComplex zcorrelfres (doubleComplex* inp1, int sr1, int sc1, doubleComplex* inp2, int sr2, int sc2, doubleComplex* inp3, int sr3, int sc3); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CORREL_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/includes/wcenter.h b/2.3-1/src/c/statisticsFunctions/includes/wcenter.h new file mode 100644 index 00000000..3919fd37 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/includes/wcenter.h @@ -0,0 +1,47 @@ + /* 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 __WCENTER_H__ +#define __WCENTER_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" + +#ifdef __cplusplus +extern "C" { +#endif + +void dwcentera (double* inp, int row, int col, double* out); +void dwcentercola (double* inp, int row, int col, double* out); +void dwcenterrowa (double* inp, int row, int col, double* out); + +void swcentera (float* inp, int row, int col, float* out); +void swcentercola (float* inp, int row, int col, float* out); +void swcenterrowa (float* inp, int row, int col, float* out); + +void zwcentera (doubleComplex* inp, int row, int col, doubleComplex* out); +void zwcentercola (doubleComplex* inp, int row, int col, doubleComplex* out); +void zwcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__WCENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h new file mode 100644 index 00000000..041937e0 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_center.h @@ -0,0 +1,36 @@ + /* 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_CENTER_H__ +#define __INT_CENTER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2centerd2(in1,size, out) dcentera(in1,size[0],size[1],out) +#define d2g2centerd2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? dcenterrowa(in1, size[0], size[1], out) : dcentercola(in1, size[0], size[1], out) +#define d2d0centerd2(in1, size, in2 ,out) (in2 == 1) ? dcenterrowa(in1, size[0], size[1], out) : dcentercola(in1, size[0], size[1], out) + +#define s2centers2(in1,size, out) scentera(in1,size[0],size[1],out) +#define s2g2centers2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? scenterrowa(in1, size[0], size[1], out) : scentercola(in1, size[0], size[1], out) +#define s2d0centers2(in1, size, in2 ,out) (in2 == 1) ? scenterrowa(in1, size[0], size[1], out) : scentercola(in1, size[0], size[1], out) + +#define z2centerz2(in1,size, out) zcentera(in1,size[0],size[1],out) +#define z2g2centerz2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? zcenterrowa(in1, size[0], size[1], out) : zcentercola(in1, size[0], size[1], out) +#define z2d0centerz2(in1, size, in2 ,out) (in2 == 1) ? zcenterrowa(in1, size[0], size[1], out) : zcentercola(in1, size[0], size[1], out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h new file mode 100644 index 00000000..8dd5c31e --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_correl.h @@ -0,0 +1,34 @@ + /* 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_CORREL_H__ +#define __INT_CORREL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define d2d2correld0(in1, size, in2, size2) dcorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define d2d2d2correld0(in1, size, in2, size2, in3, size3) dcorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + +#define s2s2correls0(in1, size, in2, size2) scorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define s2s2s2correls0(in1, size, in2, size2, in3, size3) scorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + +#define z2z2correlz0(in1, size, in2, size2) zcorrels(in1, size[0], size[1], in2, size2[0], size2[1]) +#define z2z2z2correlz0(in1, size, in2, size2, in3, size3) zcorrelfres(in1, size[0], size[1], in2, size2[0], size2[1], in3, size3[0], size3[1]) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CORREL_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h b/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h new file mode 100644 index 00000000..38273af1 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/interfaces/int_wcenter.h @@ -0,0 +1,36 @@ + /* 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_WCENTER_H__ +#define __INT_WCENTER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2wcenterd2(in1,size, out) dwcentera(in1,size[0],size[1],out) +#define d2g2wcenterd2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? dwcenterrowa(in1, size[0], size[1], out) : dwcentercola(in1, size[0], size[1], out) +#define d2d0wcenterd2(in1, size, in2 ,out) (in2 == 1) ? dwcenterrowa(in1, size[0], size[1], out) : dwcentercola(in1, size[0], size[1], out) + +#define s2wcenters2(in1,size, out) swcentera(in1,size[0],size[1],out) +#define s2g2wcenters2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? swcenterrowa(in1, size[0], size[1], out) : swcentercola(in1, size[0], size[1], out) +#define s2d0wcenters2(in1, size, in2 ,out) (in2 == 1) ? swcenterrowa(in1, size[0], size[1], out) : swcentercola(in1, size[0], size[1], out) + +#define z2wcenterz2(in1,size, out) zwcentera(in1,size[0],size[1],out) +#define z2g2wcenterz2(in1, size, in2, size2 ,out) (in2[0] == 'r') ? zwcenterrowa(in1, size[0], size[1], out) : zwcentercola(in1, size[0], size[1], out) +#define z2d0wcenterz2(in1, size, in2 ,out) (in2 == 1) ? zwcenterrowa(in1, size[0], size[1], out) : zwcentercola(in1, size[0], size[1], out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_WCENTER_H__*/ diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c new file mode 100644 index 00000000..5c05cc86 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentera.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "wcenter.h" + +void dwcentera (double* inp, int row, int col, double* out) +{ + double 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); + + double one[row*col]; // Creating a matrix of ones + donesa(one,row,col); + + double 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]; + + sum = 0; + for(int i = 0; i < row*col; i++) + sum = sum + out[i]*out[i]; + + sigma = sqrt(sum/(row*col-1)); + + for(int i = 0; i < row*col; i++) + out[i] = out[i]/sigma; +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c new file mode 100644 index 00000000..ab82acfe --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcentercola.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void dwcentercola (double* inp, int row, int col, double* out) +{ + + double sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + //for(int i = 0; i < row; i++) + //printf("%lf \n",sum[i]); + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + double one[col]; // Creating a matrix of ones + donesa(one,1,col); + + + double prod[row*col]; + dmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + for(int i = 0; i < row; i++) + sum[i] = 0; + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += out[i + j*row] * out[i + j*row]; + } + } + + double sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = sqrt(sum[i]/(col-1)); + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + dmulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c new file mode 100644 index 00000000..72e37931 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/dwcenterrowa.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void dwcenterrowa (double* inp, int row, int col, double* out) +{ + + double 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; + + double one[row]; // Creating a matrix of ones + donesa(one,row,1); + + double prod[row*col]; + dmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + + 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] += out[j + i*row] * out[j + i*row]; + } + } + + + + double sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = sqrt(sum[i]/(row-1)); + + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + dmulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c new file mode 100644 index 00000000..91206fcf --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcentera.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "multiplication.h" +#include "wcenter.h" + +void swcentera (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]; + + sum = 0; + for(int i = 0; i < row*col; i++) + sum = sum + out[i]*out[i]; + + sigma = sqrt(sum/(row*col-1)); + + for(int i = 0; i < row*col; i++) + out[i] = out[i]/sigma; +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c new file mode 100644 index 00000000..6fafe9f9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcentercola.c @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void swcentercola (float* inp, int row, int col, float* out) +{ + + float sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = 0; + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += inp[i + j*row]; + } + } + + for(int i = 0; i < row; i++) + xbar[i] = sum[i]/col; + + float one[col]; // Creating a matrix of ones + sonesa(one,1,col); + + + float prod[row*col]; + smulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = inp[i] - prod[i]; + + for(int i = 0; i < row; i++) + sum[i] = 0; + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] += out[i + j*row] * out[i + j*row]; + } + } + + float sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = sqrt(sum[i]/(col-1)); + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + smulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c new file mode 100644 index 00000000..ce1df2e9 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/swcenterrowa.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <ones.h> +#include "subtraction.h" +#include "matrixMultiplication.h" +#include "wcenter.h" + +void swcenterrowa (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]; + + + 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] += out[j + i*row] * out[j + i*row]; + } + } + + + + float sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = sqrt(sum[i]/(row-1)); + + + for(int i = 0; i < row*col; i++) + prod[i] = 0; + + smulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = out[i] / prod[i]; + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c new file mode 100644 index 00000000..8571dd62 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentera.c @@ -0,0 +1,38 @@ +#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 "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcentera (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]); + + sum = DoubleComplex(0,0); + for(int i = 0; i < row*col; i++) + sum = zadds(sum, zmuls(out[i],out[i])); + + sigma = zsqrts(zrdivs(sum,(row*col-1))); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i],sigma); +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c new file mode 100644 index 00000000..5e4e2bdd --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcentercola.c @@ -0,0 +1,66 @@ +#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 "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcentercola (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[row], xbar[row]; + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], inp[i + j*row]); + } + } + + + for(int i = 0; i < row; i++) + xbar[i] = zrdivs(sum[i], col); + + doubleComplex one[col]; // Creating a matrix of ones + zonesa(one,1,col); + + + doubleComplex prod[row*col]; + zmulma(xbar, row, 1, one, 1, col, prod); + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); + + for(int i = 0; i < row; i++) + sum[i] = DoubleComplex(0,0); + + for(int i = 0; i < row; i++) + { + for(int j = 0; j < col; j++) + { + sum[i] = zadds(sum[i], zmuls(out[i + j*row], out[i + j*row])); + } + } + + doubleComplex sigma[row]; + for(int i = 0; i < row; i++) + sigma[i] = zsqrts(zrdivs(sum[i],(col-1))); + + for(int i = 0; i < row*col; i++) + prod[i] = DoubleComplex(0,0); + + zmulma(sigma, row, 1, one, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i], prod[i]); + +} diff --git a/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c b/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c new file mode 100644 index 00000000..f68835d8 --- /dev/null +++ b/2.3-1/src/c/statisticsFunctions/wcenter/zwcenterrowa.c @@ -0,0 +1,72 @@ +#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 "wcenter.h" +#include "doubleComplex.h" +#include "sqrt.h" + +void zwcenterrowa (doubleComplex* inp, int row, int col, doubleComplex* out) +{ + + doubleComplex sum[col], xbar[col]; + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], inp[j + i*row]); + } + } + + + + for(int i = 0; i < col; i++) + xbar[i] = zrdivs(sum[i], row); + + doubleComplex one[row]; // Creating a matrix of ones + zonesa(one,row,1); + + doubleComplex prod[row*col]; + zmulma(one, row, 1, xbar, 1, col, prod); + + + + for(int i = 0; i< row*col; i++) + out[i] = zdiffs(inp[i], prod[i]); + + + for(int i = 0; i < col; i++) + sum[i] = DoubleComplex(0,0); + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + sum[i] = zadds(sum[i], zmuls(out[j + i*row], out[j + i*row])); + } + } + + + + doubleComplex sigma[col]; + for(int i = 0; i < col; i++) + sigma[i] = zsqrts(zrdivs(sum[i],(row-1))); + + + for(int i = 0; i < row*col; i++) + prod[i] = DoubleComplex(0,0); + + zmulma(one, row, 1, sigma, 1, col, prod); + + for(int i = 0; i < row*col; i++) + out[i] = zrdivs(out[i], prod[i]); + +} |