summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/linearAlgebra/includes/rank.h29
-rw-r--r--src/c/linearAlgebra/interfaces/int_rank.h28
-rw-r--r--src/c/linearAlgebra/rank/dranka.c34
-rw-r--r--src/c/linearAlgebra/rank/zranka.c82
-rw-r--r--src/c/statisticsFunctions/gsort/dgsorta.c94
-rw-r--r--src/c/statisticsFunctions/gsort/dgsortcola.c44
-rw-r--r--src/c/statisticsFunctions/gsort/dgsortrowa.c42
-rw-r--r--src/c/statisticsFunctions/gsort/sgsorta.c94
-rw-r--r--src/c/statisticsFunctions/gsort/sgsortcola.c42
-rw-r--r--src/c/statisticsFunctions/gsort/sgsortrowa.c42
-rw-r--r--src/c/statisticsFunctions/gsort/u16gsorta.c94
-rw-r--r--src/c/statisticsFunctions/gsort/u16gsortcola.c42
-rw-r--r--src/c/statisticsFunctions/gsort/u16gsortrowa.c42
-rw-r--r--src/c/statisticsFunctions/gsort/zgsorta.c96
-rw-r--r--src/c/statisticsFunctions/gsort/zgsortcola.c43
-rw-r--r--src/c/statisticsFunctions/gsort/zgsortrowa.c42
-rw-r--r--src/c/statisticsFunctions/includes/gsort.h46
-rw-r--r--src/c/statisticsFunctions/interfaces/int_gsort.h43
-rw-r--r--src/c/statisticsFunctions/median/dmediana.c16
-rw-r--r--src/c/statisticsFunctions/median/smediana.c16
-rw-r--r--src/c/statisticsFunctions/median/u16mediana.c16
-rw-r--r--src/c/statisticsFunctions/median/zmediana.c16
22 files changed, 1015 insertions, 28 deletions
diff --git a/src/c/linearAlgebra/includes/rank.h b/src/c/linearAlgebra/includes/rank.h
new file mode 100644
index 0000000..0a21b4f
--- /dev/null
+++ b/src/c/linearAlgebra/includes/rank.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: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __RANK_H__
+#define __RANK_H__
+#include "types.h"
+#include "doubleComplex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+double dranka(double* in1, int rows, int cols);
+
+doubleComplex zranka(doubleComplex* in1, int rows, int cols);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RANK_H__*/
diff --git a/src/c/linearAlgebra/interfaces/int_rank.h b/src/c/linearAlgebra/interfaces/int_rank.h
new file mode 100644
index 0000000..5c04e71
--- /dev/null
+++ b/src/c/linearAlgebra/interfaces/int_rank.h
@@ -0,0 +1,28 @@
+ /* 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: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+#ifndef __INT_RANK_H__
+#define __INT_RANK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d2rankd0(in1,size1) dranka(in1, size1[0], size1[1])
+
+#define z2rankz0(in1,size1) zranka(in1, size1[0], size1[1])
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_RANK_H__*/
diff --git a/src/c/linearAlgebra/rank/dranka.c b/src/c/linearAlgebra/rank/dranka.c
new file mode 100644
index 0000000..ebfb5a8
--- /dev/null
+++ b/src/c/linearAlgebra/rank/dranka.c
@@ -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: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+/*Funtion to find inverse condition number of square matrix*/
+
+#include "lapack.h"
+#include "stdlib.h"
+#include "string.h"
+#include "rank.h"
+#include "svd.h"
+
+double dranka(double* in1, int rows, int cols)
+{
+ double out1[rows*rows];
+ double out2[rows*cols];
+ double out3[cols*cols];
+ double rk;
+
+
+ rk = dsvda(0,in1,rows,cols, 0, 4, out1, out2, out3);
+
+
+ return rk;
+
+}
diff --git a/src/c/linearAlgebra/rank/zranka.c b/src/c/linearAlgebra/rank/zranka.c
new file mode 100644
index 0000000..0efad25
--- /dev/null
+++ b/src/c/linearAlgebra/rank/zranka.c
@@ -0,0 +1,82 @@
+/* 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: Abhinav Dronamraju
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+
+/*Funtion to find inverse condition number of square matrix*/
+
+#include "lapack.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "rank.h"
+#include "svd.h"
+#include "doubleComplex.h"
+#include "addition.h"
+
+#define eps 2.22044604925e-16
+
+doubleComplex zranka(doubleComplex* in1, int rows, int cols)
+{
+ doubleComplex out1[rows*rows];
+ doubleComplex out2[rows*cols];
+ doubleComplex out3[cols*cols];
+ doubleComplex rk=0;
+
+
+ zsvda(in1,rows,cols, 0, 3, out1, out2, out3);
+
+double tol = (double)max(rows,cols)*eps*zreals(out2[0]) ;
+
+/*
+for(int i=0; i< rows*rows; i++)
+ printf("%lf + i*%lf \t", zreals(out1[i]), zimags(out1[i]));
+printf("\n");
+
+for(int i=0; i< rows*cols; i++)
+ printf("%lf + i*%lf \t", zreals(out2[i]), zimags(out2[i]));
+printf("\n");
+
+for(int i=0; i< cols*cols; i++)
+ printf("%lf + i*%lf \t", zreals(out3[i]), zimags(out3[i]));
+printf("\n");
+
+*/
+
+if(rows<cols)
+{
+ for(int i=0;i< rows;i++)
+ {
+ if( zreals(out2[i+i*rows]) > tol)
+ {
+ rk = zadds(rk,1);
+ }
+ }
+
+}
+
+else
+{
+
+ for(int i=0;i< cols;i++)
+ {
+ if( zreals(out2[i+i*rows]) > tol)
+ {
+ rk = zadds(rk,1);
+ }
+ }
+
+
+
+}
+
+ return rk;
+
+}
diff --git a/src/c/statisticsFunctions/gsort/dgsorta.c b/src/c/statisticsFunctions/gsort/dgsorta.c
new file mode 100644
index 0000000..8585b54
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/dgsorta.c
@@ -0,0 +1,94 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void dgsorta(double *in, int size, char check, double* out)
+{
+ double a; double fin; double in_copy[size];
+
+ for(int i=0; i< size; i++)
+
+ {
+ in_copy[i]= in[i];
+
+ }
+
+
+if(check == 'i')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] > in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+}
+
+if(check =='d')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] < in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+ for(int i=0; i< size; i++)
+
+ {
+ out[i]= in_copy[i];
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/dgsortcola.c b/src/c/statisticsFunctions/gsort/dgsortcola.c
new file mode 100644
index 0000000..56cb3e8
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/dgsortcola.c
@@ -0,0 +1,44 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+#include "stdio.h"
+
+void dgsortcola(double *in, int row, int col, char check, double* out)
+{
+ double inter[col];
+ double temp[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+
+ dgsorta( inter, col, check, temp);
+
+ for(int k=0; k< col; k++)
+ {
+ out[i + k*row]= temp[k];
+
+ }
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/dgsortrowa.c b/src/c/statisticsFunctions/gsort/dgsortrowa.c
new file mode 100644
index 0000000..cb2b819
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/dgsortrowa.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void dgsortrowa(double *in, int row, int col, char check, double* out)
+{
+ double inter[row];
+ double temp[row];
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ dgsorta( inter, row, check, temp);
+
+ for(int k=0; k< row; k++)
+ {
+ out[k + i*row]= temp[k];
+
+ }
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/sgsorta.c b/src/c/statisticsFunctions/gsort/sgsorta.c
new file mode 100644
index 0000000..35bbc93
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/sgsorta.c
@@ -0,0 +1,94 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void sgsorta(float *in, int size, char check, float* out)
+{
+ float a; float fin; float in_copy[size];
+
+ for(int i=0; i< size; i++)
+
+ {
+ in_copy[i]= in[i];
+
+ }
+
+
+if(check == 'i')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] > in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+}
+
+if(check =='d')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] < in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+ for(int i=0; i< size; i++)
+
+ {
+ out[i]= in_copy[i];
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/sgsortcola.c b/src/c/statisticsFunctions/gsort/sgsortcola.c
new file mode 100644
index 0000000..7296f7f
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/sgsortcola.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+#include "stdio.h"
+
+void sgsortcola(float *in, int row, int col, char check, float* out)
+{
+ float inter[col];
+ float temp[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ sgsorta( inter, col, check, temp);
+
+ for(int k=0; k< col; k++)
+ {
+ out[i + k*row]= temp[k];
+
+ }
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/sgsortrowa.c b/src/c/statisticsFunctions/gsort/sgsortrowa.c
new file mode 100644
index 0000000..220b45a
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/sgsortrowa.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void sgsortrowa(float *in, int row, int col, char check, float* out)
+{
+ float inter[row];
+ float temp[row];
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ sgsorta( inter, row, check, temp);
+
+ for(int k=0; k< row; k++)
+ {
+ out[k + i*row]= temp[k];
+
+ }
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/u16gsorta.c b/src/c/statisticsFunctions/gsort/u16gsorta.c
new file mode 100644
index 0000000..bca7b02
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/u16gsorta.c
@@ -0,0 +1,94 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void u16gsorta(uint16 *in, int size, char check, uint16* out)
+{
+ uint16 a; uint16 fin; uint16 in_copy[size];
+
+ for(int i=0; i< size; i++)
+
+ {
+ in_copy[i]= in[i];
+
+ }
+
+
+if(check == 'i')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] > in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+}
+
+if(check =='d')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in_copy[i] < in_copy[j])
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+ for(int i=0; i< size; i++)
+
+ {
+ out[i]= in_copy[i];
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/u16gsortcola.c b/src/c/statisticsFunctions/gsort/u16gsortcola.c
new file mode 100644
index 0000000..51ac7b5
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/u16gsortcola.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+#include "stdio.h"
+
+void u16gsortcola(uint16* in, int row, int col, char check, uint16* out)
+{
+ uint16 inter[col];
+ uint16 temp[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ u16gsorta( inter, col, check, temp);
+
+ for(int k=0; k< col; k++)
+ {
+ out[i + k*row]= temp[k];
+
+ }
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/u16gsortrowa.c b/src/c/statisticsFunctions/gsort/u16gsortrowa.c
new file mode 100644
index 0000000..c8cbf4e
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/u16gsortrowa.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+
+void u16gsortrowa(uint16 *in, int row, int col, char check, uint16* out)
+{
+ uint16 inter[row];
+ uint16 temp[row];
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ u16gsorta( inter, row, check, temp);
+
+ for(int k=0; k< row; k++)
+ {
+ out[k + i*row]= temp[k];
+
+ }
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/zgsorta.c b/src/c/statisticsFunctions/gsort/zgsorta.c
new file mode 100644
index 0000000..0620a8c
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/zgsorta.c
@@ -0,0 +1,96 @@
+/* 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 "gsort.h"
+#include "abs.h"
+#include "types.h"
+#include "uint16.h"
+#include "doubleComplex.h"
+
+void zgsorta(doubleComplex *in, int size, char check, doubleComplex* out)
+{
+ doubleComplex a; doubleComplex fin; doubleComplex in_copy[size];
+
+ for(int i=0; i< size; i++)
+
+ {
+ in_copy[i]= in[i];
+
+ }
+
+
+if(check == 'i')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (zabss(in_copy[i]) > zabss(in_copy[j]))
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+}
+
+if(check =='d')
+{
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (zabss(in_copy[i]) < zabss(in_copy[j]))
+
+ {
+
+ a = in_copy[i];
+
+ in_copy[i] = in_copy[j];
+
+ in_copy[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+ for(int i=0; i< size; i++)
+
+ {
+ out[i]= in_copy[i];
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/zgsortcola.c b/src/c/statisticsFunctions/gsort/zgsortcola.c
new file mode 100644
index 0000000..2c03623
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/zgsortcola.c
@@ -0,0 +1,43 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "uint16.h"
+#include "stdio.h"
+#include "doubleComplex.h"
+
+void zgsortcola(doubleComplex *in, int row, int col, char check, doubleComplex* out)
+{
+ doubleComplex inter[col];
+ doubleComplex temp[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ zgsorta( inter, col, check, temp);
+
+ for(int k=0; k< col; k++)
+ {
+ out[i + k*row]= temp[k];
+
+ }
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/gsort/zgsortrowa.c b/src/c/statisticsFunctions/gsort/zgsortrowa.c
new file mode 100644
index 0000000..f02b0b2
--- /dev/null
+++ b/src/c/statisticsFunctions/gsort/zgsortrowa.c
@@ -0,0 +1,42 @@
+/* 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 "gsort.h"
+#include "types.h"
+#include "doubleComplex.h"
+
+void zgsortrowa(doubleComplex *in, int row, int col, char check, doubleComplex* out)
+{
+ doubleComplex inter[row];
+ doubleComplex temp[row];
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ zgsorta( inter, row, check, temp);
+
+ for(int k=0; k< row; k++)
+ {
+ out[k + i*row]= temp[k];
+
+ }
+
+ }
+
+
+}
diff --git a/src/c/statisticsFunctions/includes/gsort.h b/src/c/statisticsFunctions/includes/gsort.h
new file mode 100644
index 0000000..a4d0870
--- /dev/null
+++ b/src/c/statisticsFunctions/includes/gsort.h
@@ -0,0 +1,46 @@
+/* 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 __GSORT_H__
+#define __GSORT_H__
+
+#include "types.h"
+#include "doubleComplex.h"
+#include "uint16.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dgsorta(double *in, int size, char check, double* out);
+void dgsortcola(double *in, int row, int col, char check, double* out);
+void dgsortrowa(double *in, int row, int col, char check, double* out);
+
+void sgsorta(float *in, int size, char check, float* out);
+void sgsortcola(float *in, int row, int col, char check, float* out);
+void sgsortrowa(float *in, int row, int col, char check, float* out);
+
+void u16gsorta(uint16 *in, int size, char check, uint16* out);
+void u16gsortcola(uint16 *in, int row, int col, char check, uint16* out);
+void u16gsortrowa(uint16 *in, int row, int col, char check, uint16* out);
+
+void zgsorta(doubleComplex *in, int size, char check, doubleComplex* out);
+void zgsortcola(doubleComplex *in, int row, int col, char check, doubleComplex* out);
+void zgsortrowa(doubleComplex*in, int row, int col, char check, doubleComplex* out);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__GSORT_H__*/
diff --git a/src/c/statisticsFunctions/interfaces/int_gsort.h b/src/c/statisticsFunctions/interfaces/int_gsort.h
new file mode 100644
index 0000000..d1e9bb9
--- /dev/null
+++ b/src/c/statisticsFunctions/interfaces/int_gsort.h
@@ -0,0 +1,43 @@
+/* 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_GSORT_H__
+#define __INT_GSORT_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d2gsortd2(in1, size, out) dgsorta(in1, size[0]* size[1], 'd', out)
+#define d2g2gsortd2(in1, size1, in2, size2, out) (in2[0]== 'r') ? dgsortrowa(in1, size1[0], size1[1],'d', out) :dgsortcola(in1, size1[0], size1[1],'d', out)
+#define d2g2g2gsortd2(in1, size1, in2, size2, in3, size3, out) (in2[0]== 'r') ? dgsortrowa(in1, size1[0], size1[1],in3[0], out) :dgsortcola(in1, size1[0], size1[1],in3[0], out)
+
+#define s2gsorts2(in1, size, out) sgsorta(in1, size[0]* size[1], 'd', out)
+#define s2g2gsorts2(in1, size1, in2, size2, out) (in2[0]== 'r') ? sgsortrowa(in1, size1[0], size1[1],'d', out) :sgsortcola(in1, size1[0], size1[1],'d', out)
+#define s2g2g2gsorts2(in1, size1, in2, size2, in3, size3, out) (in2[0]== 'r') ? sgsortrowa(in1, size1[0], size1[1],in3[0], out) :sgsortcola(in1, size1[0], size1[1],in3[0], out)
+
+#define u162gsortu162(in1, size, out) u16gsorta(in1, size[0]* size[1], 'd', out)
+#define u162g2gsortu162(in1, size1, in2, size2, out) (in2[0]== 'r') ? u16gsortrowa(in1, size1[0], size1[1],'d', out) :u16gsortcola(in1, size1[0], size1[1],'d', out)
+#define u162g2g2gsortu162(in1, size1, in2, size2, in3, size3, out) (in2[0]== 'r') ? u16gsortrowa(in1, size1[0], size1[1],in3[0], out) :u16gsortcola(in1, size1[0], size1[1],in3[0], out)
+
+#define z2gsortz2(in1, size, out) zgsorta(in1, size[0]* size[1], 'd', out)
+#define z2g2gsortz2(in1, size1, in2, size2, out) (in2[0]== 'r') ? zgsortrowa(in1, size1[0], size1[1],'d', out) :zgsortcola(in1, size1[0], size1[1],'d', out)
+#define z2g2g2gsortz2(in1, size1, in2, size2, in3, size3, out) (in2[0]== 'r') ? zgsortrowa(in1, size1[0], size1[1],in3[0], out) :zgsortcola(in1, size1[0], size1[1],in3[0], out)
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_GSORT_H__*/
diff --git a/src/c/statisticsFunctions/median/dmediana.c b/src/c/statisticsFunctions/median/dmediana.c
index cb2463c..8b37fd1 100644
--- a/src/c/statisticsFunctions/median/dmediana.c
+++ b/src/c/statisticsFunctions/median/dmediana.c
@@ -17,7 +17,9 @@
double dmediana(double *in, int size)
{
- double a; double fin;
+ double a; double fin; double in_copy[size];
+for(int i=0; i< size; i++)
+ in_copy[i]= in[i];
for (int i = 0; i < size; ++i)
@@ -28,15 +30,15 @@ double dmediana(double *in, int size)
{
- if (in[i] > in[j])
+ if (in_copy[i] > in_copy[j])
{
- a = in[i];
+ a = in_copy[i];
- in[i] = in[j];
+ in_copy[i] = in_copy[j];
- in[j] = a;
+ in_copy[j] = a;
}
@@ -47,11 +49,11 @@ double dmediana(double *in, int size)
if(size%2 ==0)
{
- fin= (in[size/2]+ in[(size/2)-1])/2;
+ fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2;
}
else
{
- fin= in[(size-1)/2];
+ fin= in_copy[(size-1)/2];
}
return fin;
diff --git a/src/c/statisticsFunctions/median/smediana.c b/src/c/statisticsFunctions/median/smediana.c
index 9e86b77..0d427e1 100644
--- a/src/c/statisticsFunctions/median/smediana.c
+++ b/src/c/statisticsFunctions/median/smediana.c
@@ -17,8 +17,10 @@
float smediana(float *in, int size)
{
- float a; float fin;
+ float a; float fin; float in_copy[size];
+for(int i=0; i< size; i++)
+ in_copy[i]= in[i];
for (int i = 0; i < size; ++i)
@@ -28,15 +30,15 @@ float smediana(float *in, int size)
{
- if (in[i] > in[j])
+ if (in_copy[i] > in_copy[j])
{
- a = in[i];
+ a = in_copy[i];
- in[i] = in[j];
+ in_copy[i] = in_copy[j];
- in[j] = a;
+ in_copy[j] = a;
}
@@ -46,11 +48,11 @@ float smediana(float *in, int size)
if(size%2 ==0)
{
- fin= (in[size/2]+ in[(size/2)-1])/2;
+ fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2;
}
else
{
- fin= in[(size-1)/2];
+ fin= in_copy[(size-1)/2];
}
return fin;
diff --git a/src/c/statisticsFunctions/median/u16mediana.c b/src/c/statisticsFunctions/median/u16mediana.c
index b45c530..85cfedc 100644
--- a/src/c/statisticsFunctions/median/u16mediana.c
+++ b/src/c/statisticsFunctions/median/u16mediana.c
@@ -17,8 +17,10 @@
uint16 u16mediana(uint16 *in, int size)
{
- uint16 a; uint16 fin;
+ uint16 a; uint16 fin; uint16 in_copy[size];
+for(int i=0; i< size; i++)
+ in_copy[i]= in[i];
for (int i = 0; i < size; ++i)
@@ -28,15 +30,15 @@ uint16 u16mediana(uint16 *in, int size)
{
- if (in[i] > in[j])
+ if (in_copy[i] > in_copy[j])
{
- a = in[i];
+ a = in_copy[i];
- in[i] = in[j];
+ in_copy[i] = in_copy[j];
- in[j] = a;
+ in_copy[j] = a;
}
@@ -46,11 +48,11 @@ uint16 u16mediana(uint16 *in, int size)
if(size%2 ==0)
{
- fin= (in[size/2]+ in[(size/2)-1])/2;
+ fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2;
}
else
{
- fin= in[(size-1)/2];
+ fin= in_copy[(size-1)/2];
}
return fin;
diff --git a/src/c/statisticsFunctions/median/zmediana.c b/src/c/statisticsFunctions/median/zmediana.c
index 32726e7..3680456 100644
--- a/src/c/statisticsFunctions/median/zmediana.c
+++ b/src/c/statisticsFunctions/median/zmediana.c
@@ -21,8 +21,10 @@
doubleComplex zmediana(doubleComplex *in, int size)
{
- doubleComplex a; doubleComplex fin; doubleComplex middle;
+ doubleComplex a; doubleComplex fin; doubleComplex middle; doubleComplex in_copy[size];
+for(int i=0; i< size; i++)
+ in_copy[i]= in[i];
for (int i = 0; i < size; ++i)
@@ -32,15 +34,15 @@ doubleComplex zmediana(doubleComplex *in, int size)
{
- if (zabss(in[i]) > zabss(in[j]))
+ if (zabss(in_copy[i]) > zabss(in_copy[j]))
{
- a = in[i];
+ a = in_copy[i];
- in[i] = in[j];
+ in_copy[i] = in_copy[j];
- in[j] = a;
+ in_copy[j] = a;
}
@@ -52,12 +54,12 @@ doubleComplex zmediana(doubleComplex *in, int size)
if(size%2 ==0)
{
- middle= zadds(in[size/2], in[(size/2)-1]);
+ middle= zadds(in_copy[size/2], in_copy[(size/2)-1]);
fin= zrdivs(middle, DoubleComplex(2,0));
}
else
{
- fin= in[(size-1)/2];
+ fin= in_copy[(size-1)/2];
}
return fin;