diff options
author | Abhinav Dronamraju | 2017-07-27 18:16:59 +0530 |
---|---|---|
committer | Abhinav Dronamraju | 2017-07-27 18:16:59 +0530 |
commit | 9b3788e3f1b061bee62ad14c0bfbd7dfd64fbd01 (patch) | |
tree | 2facf6c7113b524e4dafda74d264de43c843ff74 /src/c | |
parent | 388b2e5e833667609f9ddca5f86f5859c8819399 (diff) | |
download | scilab2c-9b3788e3f1b061bee62ad14c0bfbd7dfd64fbd01.tar.gz scilab2c-9b3788e3f1b061bee62ad14c0bfbd7dfd64fbd01.tar.bz2 scilab2c-9b3788e3f1b061bee62ad14c0bfbd7dfd64fbd01.zip |
Nan Median Added
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/elementaryFunctions/interfaces/int_nanmax.h | 5 | ||||
-rw-r--r-- | src/c/elementaryFunctions/nanmax/dnanmax1a.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxa.c) | 25 | ||||
-rw-r--r-- | src/c/signalProcessing/interfaces/int_dct.h | 2 | ||||
-rw-r--r-- | src/c/statisticsFunctions/includes/nanmedian.h | 40 | ||||
-rw-r--r-- | src/c/statisticsFunctions/interfaces/int_nanmedian.h | 27 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/dnanmediana.c | 51 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/dnanmediancola.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxcola.c) | 9 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/dnanmedianrowa.c (renamed from src/c/elementaryFunctions/nanmax/znanmaxrowa.c) | 9 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/snanmediana.c | 49 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/snanmediancola.c | 36 | ||||
-rw-r--r-- | src/c/statisticsFunctions/nanmedian/snanmedianrowa.c | 37 |
11 files changed, 265 insertions, 25 deletions
diff --git a/src/c/elementaryFunctions/interfaces/int_nanmax.h b/src/c/elementaryFunctions/interfaces/int_nanmax.h index dd3df71d..45dd55e5 100644 --- a/src/c/elementaryFunctions/interfaces/int_nanmax.h +++ b/src/c/elementaryFunctions/interfaces/int_nanmax.h @@ -13,8 +13,9 @@ #ifndef __INT_NANMAX_H__ #define __INT_NANMAX_H__ -#define d2nanmaxd0(in1, size) dnanmaxa(in1,size[0]* size[1]) -#define d2g2nanmaxd2(in1, size1, in2, size2, out) (in2[0]=='r') ? dnanmaxrowa(in1, size1[0], size1[1], out) : dnanmaxcola(in1, size1[0] , size1[1], out) +#define d2nanmaxd0(in1, size) dnanmaxa(in1,size[0]* size[1]) +//#define d2nanmaxd0d2(in1, size, out) dnanmaxa(in1,size[0], size[1], out) +#define d2g2nanmaxd2(in1, size1, in2, size2, out) (in2[0]=='r') ? dnanmaxrowa(in1, size1[0], size1[1], out) : dnanmaxcola(in1, size1[0] , size1[1], out) #define s2nanmaxs0(in1, size) snanmaxa(in1,size[0]* size[1]) #define s2g2nanmaxs2(in1, size1, in2, size2, out) (in2[0]=='r') ? snanmaxrowa(in1, size1[0], size1[1], out) : snanmaxcola(in1, size1[0] , size1[1], out) diff --git a/src/c/elementaryFunctions/nanmax/znanmaxa.c b/src/c/elementaryFunctions/nanmax/dnanmax1a.c index 6283bf16..a0e7eede 100644 --- a/src/c/elementaryFunctions/nanmax/znanmaxa.c +++ b/src/c/elementaryFunctions/nanmax/dnanmax1a.c @@ -15,31 +15,30 @@ #include <math.h> #include "nanmax.h" #include "types.h" -#include "doubleComplex.h" -#include "abs.h" - -doubleComplex znanmaxa(doubleComplex* in, int size) +double dnanmax1a(double* in, int row, int col, double* out) { -doubleComplex high=0; int k=0; -for(int i=0; i<size; i++) +double high; +int ival=0; +for(int i=0; i<row*col; i++) { if( !(isnan(in[i])) ) { high= in[i]; break; - k= 1; + } } - for(int i=0; i< size; i++) + for(int i=0; i< row*col; i++) { if( !(isnan(in[i])) ) { - if( zabss(in[i]) > zabss(high)) + if( in[i] > high) { high= in[i]; + ival=i; } @@ -48,10 +47,12 @@ for(int i=0; i<size; i++) } + +out[0]= ival%row +1; +out[1]= ival/row +1; -if(k != 0) + return high; -else -return - 0.0/0.0; + } diff --git a/src/c/signalProcessing/interfaces/int_dct.h b/src/c/signalProcessing/interfaces/int_dct.h index ef58b48e..b5cbc282 100644 --- a/src/c/signalProcessing/interfaces/int_dct.h +++ b/src/c/signalProcessing/interfaces/int_dct.h @@ -17,7 +17,7 @@ -#define d2dctd2(in,size,out) ddcta(in,size[0],size[1],-1,out) +#define d2d2dctd2(in,size,out) ddcta(in,size[0],size[1],-1,out) #define d2d0dctd2(in,size,sign,out) ddcta(in,size[0],size[1],sign,out) diff --git a/src/c/statisticsFunctions/includes/nanmedian.h b/src/c/statisticsFunctions/includes/nanmedian.h new file mode 100644 index 00000000..85bbcf56 --- /dev/null +++ b/src/c/statisticsFunctions/includes/nanmedian.h @@ -0,0 +1,40 @@ +/* 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 +*/ + +#ifndef __NANMEDIAN_H__ +#define __NANMEDIAN_H__ + + +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include "int16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double dnanmediana (double* , int); +void dnanmedianrowa (double*, int , int, double*); +void dnanmediancola (double*, int , int, double*); + +float snanmediana (float* , int); +void snanmedianrowa (float*, int , int, float*); +void snanmediancola (float*, int , int, float*); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/c/statisticsFunctions/interfaces/int_nanmedian.h b/src/c/statisticsFunctions/interfaces/int_nanmedian.h new file mode 100644 index 00000000..26b74878 --- /dev/null +++ b/src/c/statisticsFunctions/interfaces/int_nanmedian.h @@ -0,0 +1,27 @@ + /*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 +*/ + + + +#ifndef __INT_NANMEDIAN_H__ +#define __INT_NANMEDIAN_H__ + +#define d2nanmediand0(in1, size) dnanmediana(in1,size[0]* size[1]) +#define d2g2nanmediand2(in1, size1, in2, size2, out) (in2[0]=='r') ? dnanmedianrowa(in1, size1[0], size1[1], out) : dnanmediancola(in1, size1[0] , size1[1], out) + +#define s2nanmedians0(in1, size) snanmediana(in1,size[0]* size[1]) +#define s2g2nanmedians2(in1, size1, in2, size2, out) (in2[0]=='r') ? snanmedianrowa(in1, size1[0], size1[1], out) : snanmediancola(in1, size1[0] , size1[1], out) + + +//#define i160i160pmoduloi160(in1, in2) i16pmodulos(in1,in2) +//#define i162i162pmoduloi162(in1, size1, in2, size2, out) i16pmoduloa(in1,size1[0]*size1[1],in2, out) + + +#endif diff --git a/src/c/statisticsFunctions/nanmedian/dnanmediana.c b/src/c/statisticsFunctions/nanmedian/dnanmediana.c new file mode 100644 index 00000000..0fb7de12 --- /dev/null +++ b/src/c/statisticsFunctions/nanmedian/dnanmediana.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: Abhinav Dronamraju + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "nanmedian.h" +#include "median.h" +#include "types.h" +double dnanmediana(double* in, int size) +{ + +double temp[size]; +double out; +int j=0; + +double a= 0.0/0.0; + + + + for(int i=0; i< size; i++) + { + if( !(isnan(in[i])) ) + { + temp[j]= in[i]; + j=j+1; + + + } + + + } + + +out= dmediana(temp, j); + +if(j=0) +return a; +else +return out; + +} diff --git a/src/c/elementaryFunctions/nanmax/znanmaxcola.c b/src/c/statisticsFunctions/nanmedian/dnanmediancola.c index ffb96b20..37b3f128 100644 --- a/src/c/elementaryFunctions/nanmax/znanmaxcola.c +++ b/src/c/statisticsFunctions/nanmedian/dnanmediancola.c @@ -11,14 +11,13 @@ */ -#include "nanmax.h" +#include "nanmedian.h" #include "types.h" #include "uint16.h" -#include "doubleComplex.h" -void znanmaxcola(doubleComplex *in, int row, int col, doubleComplex* out) +void dnanmediancola(double *in, int row, int col, double* out) { - 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); + out[i]= dnanmediana( inter, col); } diff --git a/src/c/elementaryFunctions/nanmax/znanmaxrowa.c b/src/c/statisticsFunctions/nanmedian/dnanmedianrowa.c index e035e778..d24ba828 100644 --- a/src/c/elementaryFunctions/nanmax/znanmaxrowa.c +++ b/src/c/statisticsFunctions/nanmedian/dnanmedianrowa.c @@ -11,14 +11,13 @@ */ -#include "nanmax.h" +#include "nanmedian.h" #include "types.h" #include "uint16.h" -#include "doubleComplex.h" -void znanmaxrowa(doubleComplex *in, int row, int col, doubleComplex* out) +void dnanmedianrowa(double *in, int row, int col, double* out) { - doubleComplex inter[row]; + double inter[row]; @@ -29,7 +28,7 @@ for(int i=0; i< col; i++) inter[j]= in[j+ (i*row)]; } - out[i]= znanmaxa( inter, row); + out[i]= dnanmediana( inter, row); } diff --git a/src/c/statisticsFunctions/nanmedian/snanmediana.c b/src/c/statisticsFunctions/nanmedian/snanmediana.c new file mode 100644 index 00000000..cddb990e --- /dev/null +++ b/src/c/statisticsFunctions/nanmedian/snanmediana.c @@ -0,0 +1,49 @@ +/* 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 "nanmedian.h" +#include "median.h" +#include "types.h" +float snanmediana(float* in, int size) +{ + +float temp[size]; +float out; +int j=0; + +float a= 0.0/0.0; + + for(int i=0; i< size; i++) + { + if( !(isnan(in[i])) ) + { + temp[j]= in[i]; + j=j+1; + + + } + + + } + + +out= smediana(temp, j); + +if(j=0) +return a; +else +return out; + +} diff --git a/src/c/statisticsFunctions/nanmedian/snanmediancola.c b/src/c/statisticsFunctions/nanmedian/snanmediancola.c new file mode 100644 index 00000000..a8077f19 --- /dev/null +++ b/src/c/statisticsFunctions/nanmedian/snanmediancola.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 "nanmedian.h" +#include "mean.h" +#include "types.h" +#include "uint16.h" + +void snanmediancola(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]= snanmediana( inter, col); + + } + + +} diff --git a/src/c/statisticsFunctions/nanmedian/snanmedianrowa.c b/src/c/statisticsFunctions/nanmedian/snanmedianrowa.c new file mode 100644 index 00000000..47425e0f --- /dev/null +++ b/src/c/statisticsFunctions/nanmedian/snanmedianrowa.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 "nanmedian.h" +#include "mean.h" +#include "types.h" +#include "uint16.h" + +void snanmedianrowa(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]= snanmediana( inter, row); + + } + + +} |