summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/statisticsFunctions/median
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/median')
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/dmediana.c58
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/dmediancola.c35
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c36
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/smediana.c57
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/smediancola.c35
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/smedianrowa.c36
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/u16mediana.c57
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/u16mediancola.c35
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c36
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/zmediana.c64
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/zmediancola.c36
-rw-r--r--2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c37
12 files changed, 522 insertions, 0 deletions
diff --git a/2.3-1/src/c/statisticsFunctions/median/dmediana.c b/2.3-1/src/c/statisticsFunctions/median/dmediana.c
new file mode 100644
index 00000000..cb2463c5
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/dmediana.c
@@ -0,0 +1,58 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+double dmediana(double *in, int size)
+{
+ double a; double fin;
+
+
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in[i] > in[j])
+
+ {
+
+ a = in[i];
+
+ in[i] = in[j];
+
+ in[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+ if(size%2 ==0)
+ {
+ fin= (in[size/2]+ in[(size/2)-1])/2;
+ }
+ else
+ {
+ fin= in[(size-1)/2];
+ }
+
+ return fin;
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/dmediancola.c b/2.3-1/src/c/statisticsFunctions/median/dmediancola.c
new file mode 100644
index 00000000..b3ff4fb8
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/dmediancola.c
@@ -0,0 +1,35 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void dmediancola(double *in, int row, int col, double* out)
+{
+ double inter[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ out[i]= dmediana( inter, col);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c
new file mode 100644
index 00000000..4b5879c5
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/dmedianrowa.c
@@ -0,0 +1,36 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void dmedianrowa(double *in, int row, int col, double* out)
+{
+ double inter[row];
+
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ out[i]= dmediana( inter, row);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/smediana.c b/2.3-1/src/c/statisticsFunctions/median/smediana.c
new file mode 100644
index 00000000..9e86b77e
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/smediana.c
@@ -0,0 +1,57 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+float smediana(float *in, int size)
+{
+ float a; float fin;
+
+
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in[i] > in[j])
+
+ {
+
+ a = in[i];
+
+ in[i] = in[j];
+
+ in[j] = a;
+
+ }
+
+ }
+
+ }
+
+ if(size%2 ==0)
+ {
+ fin= (in[size/2]+ in[(size/2)-1])/2;
+ }
+ else
+ {
+ fin= in[(size-1)/2];
+ }
+
+ return fin;
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/smediancola.c b/2.3-1/src/c/statisticsFunctions/median/smediancola.c
new file mode 100644
index 00000000..2fc4eaf1
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/smediancola.c
@@ -0,0 +1,35 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void smediancola(float *in, int row, int col, float* out)
+{
+ float inter[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ out[i]= smediana( inter, col);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c
new file mode 100644
index 00000000..aab59382
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/smedianrowa.c
@@ -0,0 +1,36 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void smedianrowa(float *in, int row, int col, float* out)
+{
+ float inter[row];
+
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ out[i]= smediana( inter, row);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c
new file mode 100644
index 00000000..b45c5302
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c
@@ -0,0 +1,57 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+uint16 u16mediana(uint16 *in, int size)
+{
+ uint16 a; uint16 fin;
+
+
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (in[i] > in[j])
+
+ {
+
+ a = in[i];
+
+ in[i] = in[j];
+
+ in[j] = a;
+
+ }
+
+ }
+
+ }
+
+ if(size%2 ==0)
+ {
+ fin= (in[size/2]+ in[(size/2)-1])/2;
+ }
+ else
+ {
+ fin= in[(size-1)/2];
+ }
+
+ return fin;
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c b/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c
new file mode 100644
index 00000000..77952a35
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/u16mediancola.c
@@ -0,0 +1,35 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void u16mediancola(uint16 *in, int row, int col, uint16* out)
+{
+ uint16 inter[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ out[i]= u16mediana( inter, col);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c b/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c
new file mode 100644
index 00000000..8e5b98ef
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/u16medianrowa.c
@@ -0,0 +1,36 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+
+void u16medianrowa(uint16 *in, int row, int col, uint16* out)
+{
+ uint16 inter[row];
+
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ out[i]= u16mediana( inter, row);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/zmediana.c b/2.3-1/src/c/statisticsFunctions/median/zmediana.c
new file mode 100644
index 00000000..32726e77
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/zmediana.c
@@ -0,0 +1,64 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+#include "doubleComplex.h"
+#include "addition.h"
+#include "division.h"
+#include "abs.h"
+
+doubleComplex zmediana(doubleComplex *in, int size)
+{
+ doubleComplex a; doubleComplex fin; doubleComplex middle;
+
+
+ for (int i = 0; i < size; ++i)
+
+ {
+
+ for (int j = i + 1; j < size; ++j)
+
+ {
+
+ if (zabss(in[i]) > zabss(in[j]))
+
+ {
+
+ a = in[i];
+
+ in[i] = in[j];
+
+ in[j] = a;
+
+ }
+
+ }
+
+ }
+
+
+
+ if(size%2 ==0)
+ {
+ middle= zadds(in[size/2], in[(size/2)-1]);
+ fin= zrdivs(middle, DoubleComplex(2,0));
+ }
+ else
+ {
+ fin= in[(size-1)/2];
+ }
+
+ return fin;
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/zmediancola.c b/2.3-1/src/c/statisticsFunctions/median/zmediancola.c
new file mode 100644
index 00000000..d709d98b
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/zmediancola.c
@@ -0,0 +1,36 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+#include "doubleComplex.h"
+
+void zmediancola(doubleComplex *in, int row, int col, doubleComplex * out)
+{
+ doubleComplex inter[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ out[i]= zmediana( inter, col);
+
+ }
+
+
+}
diff --git a/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c b/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c
new file mode 100644
index 00000000..ab2e0d4a
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/median/zmedianrowa.c
@@ -0,0 +1,37 @@
+/* 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 "median.h"
+#include "types.h"
+#include "uint16.h"
+#include "doubleComplex.h"
+
+void zmedianrowa(doubleComplex *in, int row, int col, doubleComplex* out)
+{
+ doubleComplex inter[row];
+
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ out[i]= zmediana( inter, row);
+
+ }
+
+
+}