summaryrefslogtreecommitdiff
path: root/src/c/elementaryFunctions/nanmin
diff options
context:
space:
mode:
authorBrijeshcr2017-07-27 18:29:25 +0530
committerBrijeshcr2017-07-27 18:29:25 +0530
commit4bd28238003609980b66edbd25dae9239a237843 (patch)
tree49c5f6b3e0bbf1d5ad8f4b432fbb2de5e9e77ffe /src/c/elementaryFunctions/nanmin
parent07d9e48f562ecdfc20192c0af6cb06a413caf30e (diff)
downloadScilab2C_fossee_old-4bd28238003609980b66edbd25dae9239a237843.tar.gz
Scilab2C_fossee_old-4bd28238003609980b66edbd25dae9239a237843.tar.bz2
Scilab2C_fossee_old-4bd28238003609980b66edbd25dae9239a237843.zip
Nanmin and Nanmean added
Diffstat (limited to 'src/c/elementaryFunctions/nanmin')
-rw-r--r--src/c/elementaryFunctions/nanmin/dnanmina.c53
-rw-r--r--src/c/elementaryFunctions/nanmin/dnanminnpa.c51
-rw-r--r--src/c/elementaryFunctions/nanmin/dnanminnps.c25
-rw-r--r--src/c/elementaryFunctions/nanmin/dnanmins.c32
4 files changed, 161 insertions, 0 deletions
diff --git a/src/c/elementaryFunctions/nanmin/dnanmina.c b/src/c/elementaryFunctions/nanmin/dnanmina.c
new file mode 100644
index 0000000..f2bce00
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmin/dnanmina.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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmin.h"
+
+double dnanmina(double* in, int row, int col, double* pos)
+{
+ double low = 0;
+ int ival = 0, nanflag = 1;
+
+ for(int i = 0; i<row*col; i++)
+ {
+ if(!(isnan(in[i])))
+ {
+ low = in[i];
+ nanflag = 0;
+ break;
+ }
+ }
+
+ for(int i = 0; i<row*col; i++)
+ {
+ if(!(isnan(in[i])))
+ {
+ if(in[i]<low)
+ {
+ low = in[i];
+ ival = i;
+ }
+ }
+ }
+
+ pos[0] = ival % row + 1;
+ pos[1] = ival / row + 1;
+
+ if (nanflag == 1)
+ return 0.0/0.0;
+
+ return low;
+}
+
diff --git a/src/c/elementaryFunctions/nanmin/dnanminnpa.c b/src/c/elementaryFunctions/nanmin/dnanminnpa.c
new file mode 100644
index 0000000..6456ebe
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmin/dnanminnpa.c
@@ -0,0 +1,51 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmin.h"
+
+double dnanminnpa(double* in, int row, int col)
+{
+ double low = 0;
+ int nanflag = 1;
+
+
+ for(int i = 0; i<row*col; i++)
+ {
+ if(!(isnan(in[i])))
+ {
+ low = in[i];
+ nanflag = 0;
+ break;
+ }
+ }
+
+ for(int i = 0; i<row*col; i++)
+ {
+ if(!(isnan(in[i])))
+ {
+ if(in[i]<low)
+ {
+ low = in[i];
+
+ }
+ }
+ }
+
+ if (nanflag == 1)
+ return 0.0/0.0;
+
+ return low;
+}
+
diff --git a/src/c/elementaryFunctions/nanmin/dnanminnps.c b/src/c/elementaryFunctions/nanmin/dnanminnps.c
new file mode 100644
index 0000000..9a33d2f
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmin/dnanminnps.c
@@ -0,0 +1,25 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmin.h"
+
+double dnanminnps(double in)
+{
+ if(isnan(in))
+ return 0;
+
+ return in;
+}
+
diff --git a/src/c/elementaryFunctions/nanmin/dnanmins.c b/src/c/elementaryFunctions/nanmin/dnanmins.c
new file mode 100644
index 0000000..86764a2
--- /dev/null
+++ b/src/c/elementaryFunctions/nanmin/dnanmins.c
@@ -0,0 +1,32 @@
+/* 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: Brijesh Gupta C R
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "nanmin.h"
+
+double dnanmins(double in, double* pos)
+{
+ pos[0] = 1;
+ pos[1] = 1;
+
+ if(isnan(in))
+ {
+ pos[0] = 0;
+ pos[1] = 0;
+ return 0;
+ }
+
+ return in;
+}
+