summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/gsort
diff options
context:
space:
mode:
authorAbhinav Dronamraju2017-08-10 20:30:45 +0530
committerAbhinav Dronamraju2017-08-10 20:30:45 +0530
commit6422b5c0a45161d6571fd6d7077b6d551cbb5e26 (patch)
tree42c7f31e0567f88bb0ebd550cbda363d8ee6799d /src/c/statisticsFunctions/gsort
parentff2e111f068342863fc3ca66f40f5822d0b19415 (diff)
downloadScilab2C_fossee_old-6422b5c0a45161d6571fd6d7077b6d551cbb5e26.tar.gz
Scilab2C_fossee_old-6422b5c0a45161d6571fd6d7077b6d551cbb5e26.tar.bz2
Scilab2C_fossee_old-6422b5c0a45161d6571fd6d7077b6d551cbb5e26.zip
rank and gsort added
Diffstat (limited to 'src/c/statisticsFunctions/gsort')
-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
12 files changed, 717 insertions, 0 deletions
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];
+
+ }
+
+ }
+
+
+}