diff options
author | jofret | 2010-07-16 22:47:53 +0000 |
---|---|---|
committer | jofret | 2010-07-16 22:47:53 +0000 |
commit | 7490295bae633fc76235291158393f6413cc39d0 (patch) | |
tree | 1494972d8dc435b287c37e1e50c006e382527aad | |
parent | 33751b04f9a0245a1a7f2d8f5f4c8db350e58636 (diff) | |
download | scilab2c-7490295bae633fc76235291158393f6413cc39d0.tar.gz scilab2c-7490295bae633fc76235291158393f6413cc39d0.tar.bz2 scilab2c-7490295bae633fc76235291158393f6413cc39d0.zip |
Correct FIND function prototypes
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/find/cfinda.c | 29 | ||||
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/find/dfinda.c | 37 | ||||
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/find/sfinda.c | 39 | ||||
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/find/zfinda.c | 35 | ||||
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/includes/find.h | 8 | ||||
-rw-r--r-- | scilab2c/src/c/auxiliaryFunctions/interfaces/int_find.h | 34 |
6 files changed, 105 insertions, 77 deletions
diff --git a/scilab2c/src/c/auxiliaryFunctions/find/cfinda.c b/scilab2c/src/c/auxiliaryFunctions/find/cfinda.c index 819d423b..54374903 100644 --- a/scilab2c/src/c/auxiliaryFunctions/find/cfinda.c +++ b/scilab2c/src/c/auxiliaryFunctions/find/cfinda.c @@ -12,19 +12,26 @@ #include "find.h" -void cfinda(floatComplex* z, int size, float *out, int *indiceOut , int max) { +void cfinda(floatComplex* z, int size, float *out, int max) +{ int i = 0; - indiceOut[1]=0; - + int j = 0; + /* if out is empty */ out[0]=-1; - - for (i = 0; i < size ; ++i) { - /*to avoid useless search if we only want to find the max first founded value */ - if (indiceOut[1] == max ) return ; - if (creals(z[i]) != 0 || cimags(z[i]) != 0) { - out[indiceOut[1]] = (float)(i+1); - indiceOut[1]++; - } + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (creals(z[i]) != 0 || cimags(z[i]) != 0) + { + out[j] = (float)(i+1); + ++j; + } } } diff --git a/scilab2c/src/c/auxiliaryFunctions/find/dfinda.c b/scilab2c/src/c/auxiliaryFunctions/find/dfinda.c index 1f07b674..ac223ae2 100644 --- a/scilab2c/src/c/auxiliaryFunctions/find/dfinda.c +++ b/scilab2c/src/c/auxiliaryFunctions/find/dfinda.c @@ -13,21 +13,28 @@ #include "find.h" -void dfinda(double* x, int size ,double *out, int *indiceOut , int max ) { - int i = 0; - indiceOut[1]=0; - - /* if out is empty */ - out[0]=-1; - - - for (i = 0; i < size ; ++i) { - /*to avoid useless search if we only want to find the max first founded value */ - if (indiceOut[1] == max ) return ; - if (x[i] != 0) { - out[indiceOut[1]] = (double)(i+1); - indiceOut[1]++; +void dfinda(double* x, int size, double *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (double)(i+1); + ++j; + } } - } } diff --git a/scilab2c/src/c/auxiliaryFunctions/find/sfinda.c b/scilab2c/src/c/auxiliaryFunctions/find/sfinda.c index 73c86d37..ac445fac 100644 --- a/scilab2c/src/c/auxiliaryFunctions/find/sfinda.c +++ b/scilab2c/src/c/auxiliaryFunctions/find/sfinda.c @@ -12,23 +12,30 @@ #include "find.h" -void sfinda(float* x, int size, float* out, int *indiceOut , int max ) { - int i = 0; - - indiceOut[1]=0; - - /* if out is empty */ - out[0]=-1; - - - for (i = 0; i < size ; ++i) { - /*to avoid useless search if we only want to find the max first founded value */ - if (indiceOut[1] == max ) return ; - if (x[i] != 0) { - out[indiceOut[1]] = (float)(i+1); - indiceOut[1]++; +void sfinda(float* x, int size, float* out, int max) +{ + int i = 0; + int j = 0; + + + /* if out is empty */ + out[0]=-1; + + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max ) + { + return ; + } + + if (x[i] != 0) + { + out[j] = (float)(i+1); + ++j; + } } - } } diff --git a/scilab2c/src/c/auxiliaryFunctions/find/zfinda.c b/scilab2c/src/c/auxiliaryFunctions/find/zfinda.c index 0fa7e178..cb6295a3 100644 --- a/scilab2c/src/c/auxiliaryFunctions/find/zfinda.c +++ b/scilab2c/src/c/auxiliaryFunctions/find/zfinda.c @@ -12,19 +12,26 @@ #include "find.h" -void zfinda(doubleComplex* z, int size, double *out, int* indiceOut, int max ) { - int i = 0; - indiceOut[1]=0; - - /* if out is empty */ - out[0]=-1; - - for (i = 0; i < size ; ++i) { - /*to avoid useless search if we only want to find the max first founded value */ - if (indiceOut[1] == max ) return ; - if (zreals(z[i]) != 0 || zimags(z[i]) != 0) { - out[indiceOut[1]] = (double)(i+1); - indiceOut[1]++; +void zfinda(doubleComplex* z, int size, double *out, int max) +{ + int i = 0; + int j = 0; + + /* if out is empty */ + out[0]=-1; + + for (i = 0; i < size ; ++i) + { + /*to avoid useless search if we only want to find the max first founded value */ + if (j == max ) + { + return ; + } + + if (zreals(z[i]) != 0 || zimags(z[i]) != 0) + { + out[j] = (double)(i+1); + ++j; + } } - } } diff --git a/scilab2c/src/c/auxiliaryFunctions/includes/find.h b/scilab2c/src/c/auxiliaryFunctions/includes/find.h index 7cc876e9..3104e957 100644 --- a/scilab2c/src/c/auxiliaryFunctions/includes/find.h +++ b/scilab2c/src/c/auxiliaryFunctions/includes/find.h @@ -24,25 +24,25 @@ extern "C" { ** \brief Float Find function ** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void sfinda(float* x, int size, float *out, int *sizeOut,int max); +EXTERN_AUXFUNCT void sfinda(float* x, int size, float *out, int max); /* ** \brief Double Find function ** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void dfinda(double*x, int size, double *out, int *sizeOut,int max); +EXTERN_AUXFUNCT void dfinda(double*x, int size, double *out, int max); /* ** \brief Float Complex Find function ** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int *sizeOut,int max); +EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int max); /* ** \brief Double Complex Find function ** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int *sizeOut,int max); +EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int max); #ifdef __cplusplus } /* extern "C" */ diff --git a/scilab2c/src/c/auxiliaryFunctions/interfaces/int_find.h b/scilab2c/src/c/auxiliaryFunctions/interfaces/int_find.h index 2448cf88..e0244b29 100644 --- a/scilab2c/src/c/auxiliaryFunctions/interfaces/int_find.h +++ b/scilab2c/src/c/auxiliaryFunctions/interfaces/int_find.h @@ -1,11 +1,11 @@ /* * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET - * + * * 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 + * are also available at * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * */ @@ -18,25 +18,25 @@ /* 1 input, 1 output */ #define s0finds0(in) (in == 0) ? -1 : 1 - + #define d0findd0(in) (in == 0) ? -1 : 1 - + #define c0finds0(in) ((creals(in) == 0) && (cimags(in) == 0)) ? -1 : 1 #define z0findd0(in) ((zreals(in) == 0) && (zimags(in) == 0)) ? -1 : 1 -#define s2finds2(in,size,out,sizeOut) sfinda(in, size[0]*size[1], out, sizeOut,-1) +#define s2finds2(in,size,out) sfinda(in, size[0]*size[1], out, -1) -#define d2findd2(in,size,out,sizeOut) dfinda(in, size[0]*size[1], out, sizeOut,-1) +#define d2findd2(in,size,out) dfinda(in, size[0]*size[1], out, -1) -#define c2finds2(in,size,out,sizeOut) cfinda(in, size[0]*size[1], out, sizeOut,-1) +#define c2finds2(in,size,out) cfinda(in, size[0]*size[1], out, -1) -#define z2findd2(in,size,out,sizeOut) zfinda(in, size[0]*size[1], out, sizeOut,-1) +#define z2findd2(in,size,out) zfinda(in, size[0]*size[1], out, -1) /* 1 input, 2 outputs */ #define s0finds0s0(in,out2) *out2 = s0finds0(in);s0finds0(in) - + #define d0findd0d0(in,out2) *out2 = d0findd0(in);d0findd0(in) #define c0finds0s0(in,out2) if ((creals(in)==0) && (cimags(in)==0)) {out2=0;} else {out2=1;} @@ -61,7 +61,7 @@ #define c0s0finds0(in1,in2) c0finds0(in1) #define z0d0findd0(in1,in2) z0findd0(in1) - + #define s2s0finds2(in1,size,in2,out) {\ int temp_out_indice[2] = {0} ;\ sfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ @@ -82,13 +82,13 @@ zfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ } -/* 2 inputs, 2 outputs */ +/* 2 inputs, 2 outputs */ -#define s0s0finds0s0(in1,in2,out2) s0finds0s0(in1,out2) +#define s0s0finds0s0(in1,in2,out2) s0finds0s0(in1,out2) -#define d0d0findd0d0(in1,in2,out2) d0findd0d0(in1,out2) +#define d0d0findd0d0(in1,in2,out2) d0findd0d0(in1,out2) -#define c0s0finds0s0(in1,in2,out2) c0finds0s0(in1,out2) +#define c0s0finds0s0(in1,in2,out2) c0finds0s0(in1,out2) #define z0d0findd0d0(in1,in2,out2) z0findd0d0(in1,out2) @@ -105,19 +105,19 @@ int temp_out_indice2[2] = {0} ;\ dfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ } - + #define c2s0finds2s2(in1,size,in2,out1,out2) {\ int temp_out_indice1[2] = {0} ;\ int temp_out_indice2[2] = {0} ;\ cfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ - } + } #define z2d0findd2d2(in1,size,in2,out1,out2) {\ int temp_out_indice1[2] = {0} ;\ int temp_out_indice2[2] = {0} ;\ zfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ - } + } |