diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c/auxiliaryFunctions/find/cfinda.c | 4 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/dfinda.c | 4 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/sfinda.c | 4 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find/zfinda.c | 4 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/cfind2da.c | 8 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/dfind2da.c | 8 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/sfind2da.c | 10 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/testFind2d.c | 62 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/find2d/zfind2da.c | 8 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/includes/find.h | 12 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/includes/find2d.h | 12 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_conj.h | 2 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_find.h | 90 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_isnan.h | 8 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_max.h | 4 | ||||
-rw-r--r-- | src/c/auxiliaryFunctions/interfaces/int_min.h | 4 |
16 files changed, 131 insertions, 113 deletions
diff --git a/src/c/auxiliaryFunctions/find/cfinda.c b/src/c/auxiliaryFunctions/find/cfinda.c index f846ce50..819d423b 100644 --- a/src/c/auxiliaryFunctions/find/cfinda.c +++ b/src/c/auxiliaryFunctions/find/cfinda.c @@ -12,7 +12,7 @@ #include "find.h" -void cfinda(floatComplex* z, int size, float *out, int *indiceOut) { +void cfinda(floatComplex* z, int size, float *out, int *indiceOut , int max) { int i = 0; indiceOut[1]=0; @@ -20,6 +20,8 @@ void cfinda(floatComplex* z, int size, float *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 (creals(z[i]) != 0 || cimags(z[i]) != 0) { out[indiceOut[1]] = (float)(i+1); indiceOut[1]++; diff --git a/src/c/auxiliaryFunctions/find/dfinda.c b/src/c/auxiliaryFunctions/find/dfinda.c index 986be373..1f07b674 100644 --- a/src/c/auxiliaryFunctions/find/dfinda.c +++ b/src/c/auxiliaryFunctions/find/dfinda.c @@ -13,7 +13,7 @@ #include "find.h" -void dfinda(double* x, int size ,double *out, int *indiceOut) { +void dfinda(double* x, int size ,double *out, int *indiceOut , int max ) { int i = 0; indiceOut[1]=0; @@ -22,6 +22,8 @@ void dfinda(double* x, int size ,double *out, int *indiceOut) { 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]++; diff --git a/src/c/auxiliaryFunctions/find/sfinda.c b/src/c/auxiliaryFunctions/find/sfinda.c index 6a23a9dd..73c86d37 100644 --- a/src/c/auxiliaryFunctions/find/sfinda.c +++ b/src/c/auxiliaryFunctions/find/sfinda.c @@ -12,7 +12,7 @@ #include "find.h" -void sfinda(float* x, int size, float* out, int *indiceOut) { +void sfinda(float* x, int size, float* out, int *indiceOut , int max ) { int i = 0; indiceOut[1]=0; @@ -22,6 +22,8 @@ void sfinda(float* x, int size, float* out, int *indiceOut) { 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]++; 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]++; diff --git a/src/c/auxiliaryFunctions/find2d/cfind2da.c b/src/c/auxiliaryFunctions/find2d/cfind2da.c index 8aefa06d..e44bab0e 100644 --- a/src/c/auxiliaryFunctions/find2d/cfind2da.c +++ b/src/c/auxiliaryFunctions/find2d/cfind2da.c @@ -13,7 +13,7 @@ #include "find2d.h" #include <malloc.h> -void cfind2da(floatComplex* x, int rows, int columns, float* out1,int* indiceOut1, float* out2,int* indiceOut2) { +void cfind2da(floatComplex* x, int rows, int columns, float* out1,int* indiceOut1, float* out2,int* indiceOut2,int max) { int i = 0, j=0; indiceOut1[1] = 0; @@ -21,8 +21,10 @@ void cfind2da(floatComplex* x, int rows, int columns, float* out1,int* indiceOut out1[0]=-1; out2[0]=-1; - for (i = 0; i < rows ; ++i) { - for (j = 0; j < columns ; ++j) { + 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 ((creals(x[j*rows+i]) != 0) || (cimags(x[j*rows+i])!=0) ) { out1[indiceOut1[1]] = (float)(i+1); diff --git a/src/c/auxiliaryFunctions/find2d/dfind2da.c b/src/c/auxiliaryFunctions/find2d/dfind2da.c index f4e80de8..74551817 100644 --- a/src/c/auxiliaryFunctions/find2d/dfind2da.c +++ b/src/c/auxiliaryFunctions/find2d/dfind2da.c @@ -13,7 +13,7 @@ #include "find2d.h" #include <malloc.h> -void dfind2da(double* x, int rows, int columns, double* out1,int* indiceOut1, double* out2,int* indiceOut2) { +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; @@ -21,8 +21,10 @@ void dfind2da(double* x, int rows, int columns, double* out1,int* indiceOut1, do out1[0]=-1; out2[0]=-1; - for (i = 0; i < rows ; ++i) { - for (j = 0; j < columns ; ++j) { + 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); diff --git a/src/c/auxiliaryFunctions/find2d/sfind2da.c b/src/c/auxiliaryFunctions/find2d/sfind2da.c index a0f9fae6..241e1e58 100644 --- a/src/c/auxiliaryFunctions/find2d/sfind2da.c +++ b/src/c/auxiliaryFunctions/find2d/sfind2da.c @@ -12,8 +12,8 @@ #include "find2d.h" #include <malloc.h> -#include <stdio.h> -void sfind2da(float* x, int rows, int columns, float* out1,int* indiceOut1, float* out2,int* indiceOut2) { + +void sfind2da(float* x, int rows, int columns, float* out1,int* indiceOut1, float* out2,int* indiceOut2,int max) { int i = 0, j=0; indiceOut1[1] = 0; @@ -21,8 +21,10 @@ void sfind2da(float* x, int rows, int columns, float* out1,int* indiceOut1, floa out1[0]=-1; out2[0]=-1; - for (i = 0; i < rows ; ++i) { - for (j = 0; j < columns ; ++j) { + 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]] = (float)(i+1); diff --git a/src/c/auxiliaryFunctions/find2d/testFind2d.c b/src/c/auxiliaryFunctions/find2d/testFind2d.c index b726ab7d..a6f38b56 100644 --- a/src/c/auxiliaryFunctions/find2d/testFind2d.c +++ b/src/c/auxiliaryFunctions/find2d/testFind2d.c @@ -30,7 +30,7 @@ int sfind2daTest() { printf(">> Floats \n"); /* Test tab 1 ligne 6 colonnes */ - sfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2); + sfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2 , -1); for (i=0;i<size1[1];i++){ @@ -54,7 +54,7 @@ int sfind2daTest() { printf("\n"); /* Test tab 2 lignes 3 colonnes */ - sfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2); + sfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2 , -1); for (i=0;i<size1[1];i++){ @@ -67,7 +67,7 @@ int sfind2daTest() { } printf("\n"); - sfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2); + sfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2 , -1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -78,7 +78,7 @@ int sfind2daTest() { printf("\n"); /* Test tab 3 lignes 2 colonnes */ - sfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size1); + sfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size1, -1); for (i=0;i<size1[1];i++){ @@ -91,7 +91,7 @@ int sfind2daTest() { } printf("\n"); - sfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size1); + sfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size1,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -102,7 +102,7 @@ int sfind2daTest() { printf("\n"); /* Test tab 6 lignes 1 colonne */ - sfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size1); + sfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size1,-1); for (i=0;i<size1[1];i++){ @@ -115,7 +115,7 @@ int sfind2daTest() { } printf("\n"); - sfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size1); + sfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size1,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -147,7 +147,7 @@ int dfind2daTest() { printf(">> Double \n"); /* Test tab 1 ligne 6 colonnes */ - dfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2); + dfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -160,7 +160,7 @@ int dfind2daTest() { } printf("\n"); - dfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2); + dfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -171,7 +171,7 @@ int dfind2daTest() { printf("\n"); /* Test tab 2 lignes 3 colonnes */ - dfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2); + dfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -184,7 +184,7 @@ int dfind2daTest() { } printf("\n"); - dfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2); + dfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -195,7 +195,7 @@ int dfind2daTest() { printf("\n"); /* Test tab 3 lignes 2 colonnes */ - dfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2); + dfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -208,7 +208,7 @@ int dfind2daTest() { } printf("\n"); - dfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2); + dfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -219,7 +219,7 @@ int dfind2daTest() { printf("\n"); /* Test tab 6 lignes 1 colonne */ - dfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2); + dfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -232,7 +232,7 @@ int dfind2daTest() { } printf("\n"); - dfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2); + dfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -279,7 +279,7 @@ int cfind2daTest() { printf(">> Float Complex \n"); /* Test tab 1 ligne 6 colonnes */ - cfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2); + cfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -292,7 +292,7 @@ int cfind2daTest() { } printf("\n"); - cfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2); + cfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -303,7 +303,7 @@ int cfind2daTest() { printf("\n"); /* Test tab 2 lignes 3 colonnes */ - cfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2); + cfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -316,7 +316,7 @@ int cfind2daTest() { } printf("\n"); - cfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2); + cfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -327,7 +327,7 @@ int cfind2daTest() { printf("\n"); /* Test tab 3 lignes 2 colonnes */ - cfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2); + cfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -340,7 +340,7 @@ int cfind2daTest() { } printf("\n"); - cfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2); + cfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -351,7 +351,7 @@ int cfind2daTest() { printf("\n"); /* Test tab 6 lignes 1 colonne */ - cfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2); + cfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -364,7 +364,7 @@ int cfind2daTest() { } printf("\n"); - cfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2); + cfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out2Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -413,7 +413,7 @@ int zfind2daTest() { printf(">> Double Complex \n"); /* Test tab 1 ligne 6 colonnes */ - zfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2); + zfind2da(goodArray, 1, 6, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -426,7 +426,7 @@ int zfind2daTest() { } printf("\n"); - zfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2); + zfind2da(badArray, 1, 6, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out1Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -437,7 +437,7 @@ int zfind2daTest() { printf("\n"); /* Test tab 2 lignes 3 colonnes */ - zfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2); + zfind2da(goodArray, 2, 3, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -450,7 +450,7 @@ int zfind2daTest() { } printf("\n"); - zfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2); + zfind2da(badArray, 2, 3, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out1Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -461,7 +461,7 @@ int zfind2daTest() { printf("\n"); /* Test tab 3 lignes 2 colonnes */ - zfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2); + zfind2da(goodArray, 3, 2, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -474,7 +474,7 @@ int zfind2daTest() { } printf("\n"); - zfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2); + zfind2da(badArray, 3, 2, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out1Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; @@ -485,7 +485,7 @@ int zfind2daTest() { printf("\n"); /* Test tab 6 lignes 1 colonne */ - zfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2); + zfind2da(goodArray, 6, 1, out1Good, size1, out2Good, size2,-1); for (i=0;i<size1[1];i++){ @@ -498,7 +498,7 @@ int zfind2daTest() { } printf("\n"); - zfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2); + zfind2da(badArray, 6, 1, out1Bad, size1, out2Bad, size2,-1); if ((out1Bad[0]!=-1) || (out1Bad[0]!=-1) ) { printf("ERROR ! : Test Failed (empty array)\n"); result = ERROR; diff --git a/src/c/auxiliaryFunctions/find2d/zfind2da.c b/src/c/auxiliaryFunctions/find2d/zfind2da.c index db263544..5b33ccbc 100644 --- a/src/c/auxiliaryFunctions/find2d/zfind2da.c +++ b/src/c/auxiliaryFunctions/find2d/zfind2da.c @@ -13,7 +13,7 @@ #include "find2d.h" #include <malloc.h> -void zfind2da(doubleComplex* x, int rows, int columns, double* out1,int* indiceOut1, double* out2,int* indiceOut2) { +void zfind2da(doubleComplex* x, int rows, int columns, double* out1,int* indiceOut1, double* out2,int* indiceOut2,int max) { int i = 0, j=0; indiceOut1[1] = 0; @@ -21,8 +21,10 @@ void zfind2da(doubleComplex* x, int rows, int columns, double* out1,int* indiceO out1[0]=-1; out2[0]=-1; - for (i = 0; i < rows ; ++i) { - for (j = 0; j < columns ; ++j) { + 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 ((zreals(x[j*rows+i]) != 0) || (zimags(x[j*rows+i])!=0) ) { out1[indiceOut1[1]] = (double)(i+1); diff --git a/src/c/auxiliaryFunctions/includes/find.h b/src/c/auxiliaryFunctions/includes/find.h index 202219c8..7cc876e9 100644 --- a/src/c/auxiliaryFunctions/includes/find.h +++ b/src/c/auxiliaryFunctions/includes/find.h @@ -22,23 +22,27 @@ extern "C" { #endif /* ** \brief Float Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void sfinda(float* x, int size, float *out, int *sizeOut); +EXTERN_AUXFUNCT void sfinda(float* x, int size, float *out, int *sizeOut,int max); /* ** \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 dfinda(double*x, int size, double *out, int *sizeOut); +EXTERN_AUXFUNCT void dfinda(double*x, int size, double *out, int *sizeOut,int max); /* ** \brief Float Complex Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int *sizeOut); +EXTERN_AUXFUNCT void cfinda(floatComplex* z, int size, float *out, int *sizeOut,int max); /* ** \brief Double Complex Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int *sizeOut); +EXTERN_AUXFUNCT void zfinda(doubleComplex* z, int size, double *out, int *sizeOut,int max); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/c/auxiliaryFunctions/includes/find2d.h b/src/c/auxiliaryFunctions/includes/find2d.h index 72c036d5..6e365107 100644 --- a/src/c/auxiliaryFunctions/includes/find2d.h +++ b/src/c/auxiliaryFunctions/includes/find2d.h @@ -22,23 +22,27 @@ extern "C" { #endif /* ** \brief Float Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void sfind2da(float* x, int rows, int columns, float* out1, int* sizeOut1, float* out2, int* sizeOut2); +EXTERN_AUXFUNCT void sfind2da(float* x, int rows, int columns, float* out1, int* sizeOut1, float* out2, int* sizeOut2,int max); /* ** \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); +EXTERN_AUXFUNCT void dfind2da(double* x, int rows, int columns, double* out1, int* sizeOut1, double* out2, int* sizeOut2,int max); /* ** \brief Float Complex Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void cfind2da(floatComplex* z, int rows, int columns, float* out1, int* sizeOut1, float* out2, int* sizeOut2); +EXTERN_AUXFUNCT void cfind2da(floatComplex* z, int rows, int columns, float* out1, int* sizeOut1, float* out2, int* sizeOut2,int max); /* ** \brief Double Complex Find function +** max is an integer giving the maximum number of indices to return. (use -1 to search them all) */ -EXTERN_AUXFUNCT void zfind2da(doubleComplex* z, int rows, int columns, double* out1, int* sizeOut1, double* out2, int* sizeOut2); +EXTERN_AUXFUNCT void zfind2da(doubleComplex* z, int rows, int columns, double* out1, int* sizeOut1, double* out2, int* sizeOut2,int max); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_conj.h b/src/c/auxiliaryFunctions/interfaces/int_conj.h index e37819e4..f54de243 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_conj.h +++ b/src/c/auxiliaryFunctions/interfaces/int_conj.h @@ -15,7 +15,7 @@ #ifndef __INT_CONJ_H__ #define __INT_CONJ_H__ -#define copy(in, size, out) {int i;for (i=0; i<size;i++) out[i]=in[i];} +#define copy(in,size,out) {int i;for (i=0; i<size[0]*size[1];i++) out[i]=in[i];} #define s0conjs0(in) in diff --git a/src/c/auxiliaryFunctions/interfaces/int_find.h b/src/c/auxiliaryFunctions/interfaces/int_find.h index c57f0148..2448cf88 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_find.h +++ b/src/c/auxiliaryFunctions/interfaces/int_find.h @@ -25,13 +25,13 @@ #define z0findd0(in) ((zreals(in) == 0) && (zimags(in) == 0)) ? -1 : 1 -#define s2finds2(in,size,out,sizeOut) sfinda(in, size[0]*size[1], out, sizeOut) +#define s2finds2(in,size,out,sizeOut) sfinda(in, size[0]*size[1], out, sizeOut,-1) -#define d2findd2(in,size,out,sizeOut) dfinda(in, size[0]*size[1], out, sizeOut) +#define d2findd2(in,size,out,sizeOut) dfinda(in, size[0]*size[1], out, sizeOut,-1) -#define c2finds2(in,size,out,sizeOut) cfinda(in, size[0]*size[1], out, sizeOut) +#define c2finds2(in,size,out,sizeOut) cfinda(in, size[0]*size[1], out, sizeOut,-1) -#define z2findd2(in,size,out,sizeOut) zfinda(in, size[0]*size[1], out, sizeOut) +#define z2findd2(in,size,out,sizeOut) zfinda(in, size[0]*size[1], out, sizeOut,-1) /* 1 input, 2 outputs */ @@ -44,13 +44,13 @@ #define z0findd0d0(in,out2) if ((zreals(in)==0) && (zimags(in)==0)) {out2=0;} else {out2=1;} -#define s2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) sfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2) +#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) +#define d2findd2d2(in,size,out1,sizeOut1,out2,sizeOut2) dfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) -#define c2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) cfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2) +#define c2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) cfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) -#define z2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) zfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2) +#define z2finds2s2(in,size,out1,sizeOut1,out2,sizeOut2) zfind2da(in,size[0],size[1],out1,sizeOut1,out2,sizeOut2,-1) /* 2 inputs, 1 output */ @@ -62,29 +62,26 @@ #define z0d0findd0(in1,in2) z0findd0(in1) -#define s2s0finds2(in1,size,in2,out,sizeOut) {\ - float* out_tmp = out;\ - int i = 0 ;\ - s2finds2(in1,size,out_tmp,sizeOut);for( i=0;i<in2;i++){out[i]=out_tmp[i];}\ +#define s2s0finds2(in1,size,in2,out) {\ + int temp_out_indice[2] = {0} ;\ + sfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ } -#define d2d0findd2(in1,size,in2,out,sizeOut) {\ - double* out_tmp = out;\ - int i = 0 ;\ - d2findd2(in1,size,out_tmp,sizeOut);for( i=0;i<in2;i++){out[i]=out_tmp[i];}\ +#define d2d0findd2(in1,size,in2,out) {\ + int temp_out_indice[2] = {0} ;\ + dfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ } -#define c2s0finds2(in1,size,in2,out,sizeOut) {\ - floatComplex* out_tmp = out;\ - int i = 0 ;\ - c2finds2(in1,size,out_tmp,sizeOut);for( i=0;i<in2;i++){out[i]=out_tmp[i];}\ +#define c2s0finds2(in1,size,in2,out) {\ + int temp_out_indice[2] = {0} ;\ + cfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ } -#define z2d0findd2(in1,size,in2,out,sizeOut) {\ - doubleComplex* out_tmp = out;\ - int i = 0 ;\ - z2findd2(in1,size,out_tmp,sizeOut);for( i=0;i<in2;i++){out[i]=out_tmp[i];}\ +#define z2d0findd2(in1,size,in2,out) {\ + int temp_out_indice[2] = {0} ;\ + zfinda(in1,size[0]*size[1],out,temp_out_indice,in2);\ } + /* 2 inputs, 2 outputs */ #define s0s0finds0s0(in1,in2,out2) s0finds0s0(in1,out2) @@ -97,32 +94,29 @@ /*FIXME : prototypes are wrong*/ -#define s2s0finds2s2(in1,size,in2,out1,sizeOut1,out2,sizeOut2) {\ - float* out1_tmp = out1;\ - float* out2_tmp = out2;\ - int i = 0 ;\ - s2finds2s2(in1,size,out1_tmp,sizeOut1,out2_tmp,sizeOut2);for( i=0;i<in2;i++) {out1[i]=out1_tmp[i];out2[i]= out2_tmp[i];}\ +#define s2s0finds2s2(in1,size,in2,out1,out2) {\ + int temp_out_indice1[2] = {0} ;\ + int temp_out_indice2[2] = {0} ;\ + sfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ + } + +#define d2d0findd2d2(in1,size,in2,out1,out2) {\ + int temp_out_indice1[2] = {0} ;\ + int temp_out_indice2[2] = {0} ;\ + dfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ } + + +#define c2s0finds2s2(in1,size,in2,out1,out2) {\ + int temp_out_indice1[2] = {0} ;\ + int temp_out_indice2[2] = {0} ;\ + cfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ + } -#define d2d0findd2d2(in1,size,in2,out1,sizeOut1,out2,sizeOut2) {\ - double* out1_tmp = out1;\ - double* out2_tmp = out2;\ - int i = 0 ;\ - d2findd2d2(in1,size,out1_tmp,sizeOut1,out2_tmp,sizeOut2);for( i=0;i<in2;i++) {out1[i]=out1_tmp[i];out2[i]= out2_tmp[i];}\ - } - -#define c2s0finds2s2(in1,size,in2,out1,sizeOut1,out2,sizeOut2) {\ - floatComplex* out1_tmp = out1;\ - floatComplex* out2_tmp = out2;\ - int i = 0 ;\ - c2finds2s2(in1,size,out1_tmp,sizeOut1,out_tmp2,sizeOut2);for( i=0;i<in2;i++) {out1[i]=out1_tmp[i];out2[i]= out2_tmp[i];}\ - } - -#define z2d0findd2d2(in1,size,in2,out1,sizeOut1,out2,sizeOut2) {\ - doubleComplex* out1_tmp = out1;\ - doubleComplex* out2_tmp = out2;\ - int i = 0 ;\ - z2findd2d2(in1,size,out1_tmp,sizeOut1,out2_tmp,sizeOut2);for( i=0;i<in2;i++) {out1[i]=out1_tmp[i];out2[i]= out2_tmp[i];}\ +#define z2d0findd2d2(in1,size,in2,out1,out2) {\ + int temp_out_indice1[2] = {0} ;\ + int temp_out_indice2[2] = {0} ;\ + zfind2da(in1,size[0],size[1],out1,temp_out_indice1,out2,temp_out_indice2,in2);\ } diff --git a/src/c/auxiliaryFunctions/interfaces/int_isnan.h b/src/c/auxiliaryFunctions/interfaces/int_isnan.h index 4e2e4d7f..8ab7c74c 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_isnan.h +++ b/src/c/auxiliaryFunctions/interfaces/int_isnan.h @@ -19,16 +19,16 @@ #define d0isnand0(in) disnans(in) -#define c0isnanc0(in) cisnans(in) +#define c0isnans0(in) cisnans(in) -#define z0isnanz0(in) zisnans(in) +#define z0isnand0(in) zisnans(in) #define s2isnans2(in,size,out) sisnana(in, size[0]*size[1], out) #define d2isnand2(in,size,out) disnana(in, size[0]*size[1], out) -#define c2isnanc2(in,size,out) cisnana(in, size[0]*size[1], out) +#define c2isnans2(in,size,out) cisnana(in, size[0]*size[1], out) -#define z2isnanz2(in,size,out) zisnana(in, size[0]*size[1], out) +#define z2isnand2(in,size,out) zisnana(in, size[0]*size[1], out) #endif /* !__INT_ISNAN_H__ */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_max.h b/src/c/auxiliaryFunctions/interfaces/int_max.h index efef39d3..0dc0eef0 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_max.h +++ b/src/c/auxiliaryFunctions/interfaces/int_max.h @@ -29,9 +29,9 @@ #define d0d0maxd0(in1,in2) max(in1,in2) -#define s2s2maxs2(in1,size1,in2,size2,out) maxa(in1, size1[0]*size1[1], in2, size2[0]*size2[1], out) +#define s2s2maxs2(in1,size1,in2,size2,out) maxa(in1, size1, in2, size2, out) -#define d2d2maxd2(in1,size1,in2,size2,out) maxa(in1, size1[0]*size1[1], in2, size2[0]*size2[1], out) +#define d2d2maxd2(in1,size1,in2,size2,out) maxa(in1, size1, in2, size2, out) #define s2s0maxs2(in1,size,in2,out) {int i;\ diff --git a/src/c/auxiliaryFunctions/interfaces/int_min.h b/src/c/auxiliaryFunctions/interfaces/int_min.h index d7bd5669..ec48da72 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_min.h +++ b/src/c/auxiliaryFunctions/interfaces/int_min.h @@ -29,9 +29,9 @@ #define d0d0mind0(in1,in2) min(in1,in2) -#define s2s2mins2(in1,size1,in2,size2,out) mina(in1, size1[0]*size1[1], in2, size2[0]*size2[1], out) +#define s2s2mins2(in1,size1,in2,size2,out) mina(in1, size1, in2, size2, out) -#define d2d2mind2(in1,size1,in2,size2,out) mina(in1, size1[0]*size1[1], in2, size2[0]*size2[1], out) +#define d2d2mind2(in1,size1,in2,size2,out) mina(in1, size1, in2, size2, out) #define s2s0mins2(in1,size,in2,out) {int i;\ |