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