diff options
author | jofret | 2010-07-16 22:47:53 +0000 |
---|---|---|
committer | jofret | 2010-07-16 22:47:53 +0000 |
commit | e3724c71f70b0349950996d30575f155e9deb3a9 (patch) | |
tree | 9dd35d6a7831a3be3d25a5e06fc8f21152871e55 /src/c/auxiliaryFunctions/find | |
parent | 63c58ca04a24d7016b5301d28193895272e61799 (diff) | |
download | scilab2c-e3724c71f70b0349950996d30575f155e9deb3a9.tar.gz scilab2c-e3724c71f70b0349950996d30575f155e9deb3a9.tar.bz2 scilab2c-e3724c71f70b0349950996d30575f155e9deb3a9.zip |
Correct FIND function prototypes
Diffstat (limited to 'src/c/auxiliaryFunctions/find')
-rw-r--r-- | src/c/auxiliaryFunctions/find/cfinda.c | 29 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/dfinda.c | 37 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/sfinda.c | 39 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/zfinda.c | 35 |
4 files changed, 84 insertions, 56 deletions
diff --git a/src/c/auxiliaryFunctions/find/cfinda.c b/src/c/auxiliaryFunctions/find/cfinda.c index 819d423b..54374903 100644 --- a/src/c/auxiliaryFunctions/find/cfinda.c +++ b/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/src/c/auxiliaryFunctions/find/dfinda.c b/src/c/auxiliaryFunctions/find/dfinda.c index 1f07b674..ac223ae2 100644 --- a/src/c/auxiliaryFunctions/find/dfinda.c +++ b/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/src/c/auxiliaryFunctions/find/sfinda.c b/src/c/auxiliaryFunctions/find/sfinda.c index 73c86d37..ac445fac 100644 --- a/src/c/auxiliaryFunctions/find/sfinda.c +++ b/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/src/c/auxiliaryFunctions/find/zfinda.c b/src/c/auxiliaryFunctions/find/zfinda.c index 0fa7e178..cb6295a3 100644 --- a/src/c/auxiliaryFunctions/find/zfinda.c +++ b/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; + } } - } } |