summaryrefslogtreecommitdiff
path: root/src/c/auxiliaryFunctions/find/zfinda.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/auxiliaryFunctions/find/zfinda.c')
-rw-r--r--src/c/auxiliaryFunctions/find/zfinda.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/c/auxiliaryFunctions/find/zfinda.c b/src/c/auxiliaryFunctions/find/zfinda.c
index f9c3f970..0fa7e178 100644
--- a/src/c/auxiliaryFunctions/find/zfinda.c
+++ b/src/c/auxiliaryFunctions/find/zfinda.c
@@ -12,7 +12,7 @@
#include "find.h"
-void zfinda(doubleComplex* z, int size, double *out, int* indiceOut) {
+void zfinda(doubleComplex* z, int size, double *out, int* indiceOut, int max ) {
int i = 0;
indiceOut[1]=0;
@@ -20,6 +20,8 @@ void zfinda(doubleComplex* z, int size, double *out, int* indiceOut) {
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]++;