diff options
author | Brijeshcr | 2017-07-28 15:41:36 +0530 |
---|---|---|
committer | GitHub | 2017-07-28 15:41:36 +0530 |
commit | 6494599083ecf3035d060e1bec483350e647c265 (patch) | |
tree | bec805df23a29ae83af9515f2bc551caee0fbded /2.3-1/src/c/elementaryFunctions/nanmax | |
parent | c9544c623c53e01c5e81709c92b25b6aa05bd7bd (diff) | |
parent | 81419aa6b4f55ae75192f704d2e52dbad3f34033 (diff) | |
download | Scilab2C-6494599083ecf3035d060e1bec483350e647c265.tar.gz Scilab2C-6494599083ecf3035d060e1bec483350e647c265.tar.bz2 Scilab2C-6494599083ecf3035d060e1bec483350e647c265.zip |
Merge pull request #25 from abhinavdronamraju/master
Added Nansum and merged
Diffstat (limited to '2.3-1/src/c/elementaryFunctions/nanmax')
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmax1a.c | 58 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmax2a.c (renamed from 2.3-1/src/c/elementaryFunctions/nanmax/znanmaxa.c) | 16 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcol1a.c (renamed from 2.3-1/src/c/elementaryFunctions/nanmax/znanmaxcola.c) | 7 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcola.c | 4 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrow1a.c (renamed from 2.3-1/src/c/elementaryFunctions/nanmax/znanmaxrowa.c) | 8 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c | 7 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmax1a.c | 58 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmax2a.c | 53 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcol1a.c | 35 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcola.c | 4 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrow1a.c | 37 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrowa.c | 7 |
12 files changed, 266 insertions, 28 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/nanmax/dnanmax1a.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmax1a.c new file mode 100644 index 00000000..a0e7eede --- /dev/null +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxa.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmax2a.c index 6283bf16..82ddda6b 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxa.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxcola.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcol1a.c index ffb96b20..1198dcea 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxcola.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcola.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcola.c index 9db07423..388337e7 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxcola.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxrowa.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrow1a.c index e035e778..c4a7a4d1 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/znanmaxrowa.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c b/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c index 191fa012..47d4d386 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/dnanmaxrowa.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmax1a.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmax1a.c new file mode 100644 index 00000000..7420c3a3 --- /dev/null +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmax2a.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmax2a.c new file mode 100644 index 00000000..59c282d8 --- /dev/null +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcol1a.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcol1a.c new file mode 100644 index 00000000..a737033b --- /dev/null +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcola.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcola.c index b4080525..2703319a 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxcola.c +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrow1a.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrow1a.c new file mode 100644 index 00000000..09d062c7 --- /dev/null +++ b/2.3-1/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/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrowa.c b/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrowa.c index ab1ce0cb..c438ae0f 100644 --- a/2.3-1/src/c/elementaryFunctions/nanmax/snanmaxrowa.c +++ b/2.3-1/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]); } + } |