diff options
Diffstat (limited to 'src/c/auxiliaryFunctions')
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/dfind2da.c | 44 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/includes/find2d.h | 2 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_find.h | 2 |
3 files changed, 26 insertions, 22 deletions
diff --git a/src/c/auxiliaryFunctions/find2d/dfind2da.c b/src/c/auxiliaryFunctions/find2d/dfind2da.c index a4df47ec..22d4cf55 100644 --- a/src/c/auxiliaryFunctions/find2d/dfind2da.c +++ b/src/c/auxiliaryFunctions/find2d/dfind2da.c @@ -12,25 +12,29 @@ #include "find2d.h" -void dfind2da(double* x, int rows, int columns, double* out1,int* indiceOut1, double* out2,int* indiceOut2,int max) { - int i = 0, j=0; - indiceOut1[1] = 0; - - /* if out are empties */ - out1[0]=-1; - out2[0]=-1; - - for (j = 0; j < columns ; ++j){ - for (i = 0; i < rows ; ++i) { +void dfind2da(double* x, int rows, int columns, double* out1, double* out2, int max) { + int i = 0, j=0, k = 0; + + /* if out are empties */ + out1[0]=-1; + out2[0]=-1; + + for (j = 0; j < columns ; ++j) + { + for (i = 0; i < rows ; ++i) + { /*to avoid useless search if we only want to find the max first founded value */ - if (indiceOut1[1] == max ) return ; - if (x[j*rows+i] != 0) { - - out1[indiceOut1[1]] = (double)(i+1); - out2[indiceOut1[1]] = (double)(j+1); - indiceOut1[1]++; - } - } - } - indiceOut2[1]=indiceOut1[1]; + if (max == 0) + { + return; + } + + if (x[j*rows+i] != 0) + { + out1[k] = (double)(i+1); + out2[k] = (double)(j+1); + k++; + } + } + } } diff --git a/src/c/auxiliaryFunctions/includes/find2d.h b/src/c/auxiliaryFunctions/includes/find2d.h index 6e365107..2e9be6fa 100644 --- a/src/c/auxiliaryFunctions/includes/find2d.h +++ b/src/c/auxiliaryFunctions/includes/find2d.h @@ -30,7 +30,7 @@ EXTERN_AUXFUNCT void sfind2da(float* x, int rows, int columns, float* out1, int* ** \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 dfind2da(double* x, int rows, int columns, double* out1, int* sizeOut1, double* out2, int* sizeOut2,int max); +EXTERN_AUXFUNCT void dfind2da(double* x, int rows, int columns, double* out1, double* out2, int max); /* ** \brief Float Complex Find function diff --git a/src/c/auxiliaryFunctions/interfaces/int_find.h b/src/c/auxiliaryFunctions/interfaces/int_find.h index e0244b29..737afc28 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_find.h +++ b/src/c/auxiliaryFunctions/interfaces/int_find.h @@ -46,7 +46,7 @@ #define s2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) sfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) -#define d2findd2d2(in,size,out1,sizeOut1,out2,sizeOut2) dfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) +#define d2findd2d2(in,size,out1,out2) dfind2da(in,size[0],size[1],out1,out2,-1) #define c2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) cfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) |