diff options
Diffstat (limited to 'src/c/auxiliaryFunctions/find/zfinda.c')
-rw-r--r-- | src/c/auxiliaryFunctions/find/zfinda.c | 35 |
1 files changed, 21 insertions, 14 deletions
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; + } } - } } |