summaryrefslogtreecommitdiff
path: root/src/c/elementaryFunctions/nanmax
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/elementaryFunctions/nanmax')
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmax1a.c58
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmax2a.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxa.c)16
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmaxcol1a.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxcola.c)7
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmaxcola.c4
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmaxrow1a.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxrowa.c)8
-rw-r--r--src/c/elementaryFunctions/nanmax/dnanmaxrowa.c7
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmax1a.c58
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmax2a.c53
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmaxcol1a.c35
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmaxcola.c4
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmaxrow1a.c37
-rw-r--r--src/c/elementaryFunctions/nanmax/snanmaxrowa.c7
12 files changed, 266 insertions, 28 deletions
diff --git a/src/c/elementaryFunctions/nanmax/dnanmax1a.c b/src/c/elementaryFunctions/nanmax/dnanmax1a.c
new file mode 100644
index 0000000..a0e7eed
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmax/dnanmax1a.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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmax.h"
+#include "types.h"
+double dnanmax1a(double* in, int row, int col, double* out)
+{
+double high;
+int ival=0;
+for(int i=0; i<row*col; i++)
+{
+ if( !(isnan(in[i])) )
+ {
+ high= in[i];
+ break;
+
+ }
+}
+
+
+
+ for(int i=0; i< row*col; i++)
+ {
+ if( !(isnan(in[i])) )
+ {
+ if( in[i] > high)
+ {
+ high= in[i];
+ ival=i;
+
+ }
+
+
+ }
+
+
+ }
+
+out[0]= ival%row +1;
+out[1]= ival/row +1;
+
+
+
+return high;
+
+}
diff --git a/src/c/elementaryFunctions/nanmax/znanmaxa.c b/src/c/elementaryFunctions/nanmax/dnanmax2a.c
index 6283bf1..82ddda6 100644
--- a/src/c/elementaryFunctions/nanmax/znanmaxa.c
+++ b/src/c/elementaryFunctions/nanmax/dnanmax2a.c
@@ -15,19 +15,16 @@
#include <math.h>
#include "nanmax.h"
#include "types.h"
-#include "doubleComplex.h"
-#include "abs.h"
-
-doubleComplex znanmaxa(doubleComplex* in, int size)
+double dnanmax2a(double* in, int size, double* out)
{
-doubleComplex high=0; int k=0;
+double high;
for(int i=0; i<size; i++)
{
if( !(isnan(in[i])) )
{
high= in[i];
break;
- k= 1;
+
}
}
@@ -37,9 +34,10 @@ for(int i=0; i<size; i++)
{
if( !(isnan(in[i])) )
{
- if( zabss(in[i]) > zabss(high))
+ if( in[i] > high)
{
high= in[i];
+ *out= i+1;
}
@@ -50,8 +48,6 @@ for(int i=0; i<size; i++)
}
-if(k != 0)
return high;
-else
-return - 0.0/0.0;
+
}
diff --git a/src/c/elementaryFunctions/nanmax/znanmaxcola.c b/src/c/elementaryFunctions/nanmax/dnanmaxcol1a.c
index ffb96b2..1198dce 100644
--- a/src/c/elementaryFunctions/nanmax/znanmaxcola.c
+++ b/src/c/elementaryFunctions/nanmax/dnanmaxcol1a.c
@@ -14,11 +14,10 @@
#include "nanmax.h"
#include "types.h"
#include "uint16.h"
-#include "doubleComplex.h"
-void znanmaxcola(doubleComplex *in, int row, int col, doubleComplex* out)
+void dnanmaxcol1a(double *in, int row, int col, double* out1)
{
- doubleComplex inter[col];
+ double inter[col];
for(int i=0; i< row; i++)
@@ -28,7 +27,7 @@ for(int i=0; i< row; i++)
inter[j]= in[i+ (j*row)];
}
- out[i]= znanmaxa( inter, col);
+ out1[i]= dnanmaxa( inter, col);
}
diff --git a/src/c/elementaryFunctions/nanmax/dnanmaxcola.c b/src/c/elementaryFunctions/nanmax/dnanmaxcola.c
index 9db0742..388337e 100644
--- a/src/c/elementaryFunctions/nanmax/dnanmaxcola.c
+++ b/src/c/elementaryFunctions/nanmax/dnanmaxcola.c
@@ -15,7 +15,7 @@
#include "types.h"
#include "uint16.h"
-void dnanmaxcola(double *in, int row, int col, double* out)
+void dnanmaxcola(double *in, int row, int col, double* out1, double* out2)
{
double inter[col];
@@ -27,7 +27,7 @@ for(int i=0; i< row; i++)
inter[j]= in[i+ (j*row)];
}
- out[i]= dnanmaxa( inter, col);
+ out1[i]= dnanmax2a( inter, col, &out2[i]);
}
diff --git a/src/c/elementaryFunctions/nanmax/znanmaxrowa.c b/src/c/elementaryFunctions/nanmax/dnanmaxrow1a.c
index e035e77..c4a7a4d 100644
--- a/src/c/elementaryFunctions/nanmax/znanmaxrowa.c
+++ b/src/c/elementaryFunctions/nanmax/dnanmaxrow1a.c
@@ -14,11 +14,10 @@
#include "nanmax.h"
#include "types.h"
#include "uint16.h"
-#include "doubleComplex.h"
-void znanmaxrowa(doubleComplex *in, int row, int col, doubleComplex* out)
+void dnanmaxrow1a(double *in, int row, int col, double* out1)
{
- doubleComplex inter[row];
+ double inter[row];
@@ -29,9 +28,10 @@ for(int i=0; i< col; i++)
inter[j]= in[j+ (i*row)];
}
- out[i]= znanmaxa( inter, row);
+ out1[i]= dnanmaxa( inter, row);
}
+
}
diff --git a/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c b/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c
index 191fa01..47d4d38 100644
--- a/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c
+++ b/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c
@@ -15,9 +15,9 @@
#include "types.h"
#include "uint16.h"
-void dnanmaxrowa(double *in, int row, int col, double* out)
+void dnanmaxrowa(double *in, int row, int col, double* out1, double* out2)
{
- double inter[row];
+ double inter[row];
@@ -28,9 +28,10 @@ for(int i=0; i< col; i++)
inter[j]= in[j+ (i*row)];
}
- out[i]= dnanmaxa( inter, row);
+ out1[i]= dnanmax2a( inter, row, &out2[i]);
}
+
}
diff --git a/src/c/elementaryFunctions/nanmax/snanmax1a.c b/src/c/elementaryFunctions/nanmax/snanmax1a.c
new file mode 100644
index 0000000..7420c3a
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmax/snanmax1a.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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmax.h"
+#include "types.h"
+float snanmax1a(float* in, int row, int col, float* out)
+{
+float high;
+int ival=0;
+for(int i=0; i<row*col; i++)
+{
+ if( !(isnan(in[i])) )
+ {
+ high= in[i];
+ break;
+
+ }
+}
+
+
+
+ for(int i=0; i< row*col; i++)
+ {
+ if( !(isnan(in[i])) )
+ {
+ if( in[i] > high)
+ {
+ high= in[i];
+ ival=i;
+
+ }
+
+
+ }
+
+
+ }
+
+out[0]= ival%row +1;
+out[1]= ival/row +1;
+
+
+
+return high;
+
+}
diff --git a/src/c/elementaryFunctions/nanmax/snanmax2a.c b/src/c/elementaryFunctions/nanmax/snanmax2a.c
new file mode 100644
index 0000000..59c282d
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmax/snanmax2a.c
@@ -0,0 +1,53 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmax.h"
+#include "types.h"
+float snanmax2a(float* in, int size, float* out)
+{
+float high;
+for(int i=0; i<size; i++)
+{
+ if( !(isnan(in[i])) )
+ {
+ high= in[i];
+ break;
+
+ }
+}
+
+
+
+ for(int i=0; i< size; i++)
+ {
+ if( !(isnan(in[i])) )
+ {
+ if( in[i] > high)
+ {
+ high= in[i];
+ *out= i+1;
+
+ }
+
+
+ }
+
+
+ }
+
+
+return high;
+
+}
diff --git a/src/c/elementaryFunctions/nanmax/snanmaxcol1a.c b/src/c/elementaryFunctions/nanmax/snanmaxcol1a.c
new file mode 100644
index 0000000..a737033
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmax/snanmaxcol1a.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 "nanmax.h"
+#include "types.h"
+#include "uint16.h"
+
+void snanmaxcol1a(float *in, int row, int col, float* out1)
+{
+ float inter[col];
+
+
+for(int i=0; i< row; i++)
+ {
+ for(int j=0 ; j< col; j++)
+ {
+ inter[j]= in[i+ (j*row)];
+
+ }
+ out1[i]= snanmaxa( inter, col);
+
+ }
+
+
+}
diff --git a/src/c/elementaryFunctions/nanmax/snanmaxcola.c b/src/c/elementaryFunctions/nanmax/snanmaxcola.c
index b408052..2703319 100644
--- a/src/c/elementaryFunctions/nanmax/snanmaxcola.c
+++ b/src/c/elementaryFunctions/nanmax/snanmaxcola.c
@@ -15,7 +15,7 @@
#include "types.h"
#include "uint16.h"
-void snanmaxcola(float *in, int row, int col, float* out)
+void snanmaxcola(float *in, int row, int col, float* out1, float* out2)
{
float inter[col];
@@ -27,7 +27,7 @@ for(int i=0; i< row; i++)
inter[j]= in[i+ (j*row)];
}
- out[i]= snanmaxa( inter, col);
+ out1[i]= snanmax2a( inter, col, &out2[i]);
}
diff --git a/src/c/elementaryFunctions/nanmax/snanmaxrow1a.c b/src/c/elementaryFunctions/nanmax/snanmaxrow1a.c
new file mode 100644
index 0000000..09d062c
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmax/snanmaxrow1a.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 "nanmax.h"
+#include "types.h"
+#include "uint16.h"
+
+void snanmaxrow1a(float *in, int row, int col, float* out1)
+{
+ float inter[row];
+
+
+
+for(int i=0; i< col; i++)
+ {
+ for(int j=0 ; j< row; j++)
+ {
+ inter[j]= in[j+ (i*row)];
+
+ }
+ out1[i]= snanmaxa( inter, row);
+
+ }
+
+
+
+}
diff --git a/src/c/elementaryFunctions/nanmax/snanmaxrowa.c b/src/c/elementaryFunctions/nanmax/snanmaxrowa.c
index ab1ce0c..c438ae0 100644
--- a/src/c/elementaryFunctions/nanmax/snanmaxrowa.c
+++ b/src/c/elementaryFunctions/nanmax/snanmaxrowa.c
@@ -15,9 +15,9 @@
#include "types.h"
#include "uint16.h"
-void snanmaxrowa(float *in, int row, int col, float* out)
+void snanmaxrowa(float *in, int row, int col, float* out1, float* out2)
{
- float inter[row];
+ float inter[row];
@@ -28,9 +28,10 @@ for(int i=0; i< col; i++)
inter[j]= in[j+ (i*row)];
}
- out[i]= snanmaxa( inter, row);
+ out1[i]= snanmax2a( inter, row, &out2[i]);
}
+
}