diff options
author | torset | 2009-02-05 12:53:51 +0000 |
---|---|---|
committer | torset | 2009-02-05 12:53:51 +0000 |
commit | 7e7df6ec419bfcb7d5dc97dc4af973b6ea5c2c09 (patch) | |
tree | 7655c8e6ceef4a1a68cd1d220713cb291252734c /src/auxiliaryFunctions/find2d/sfind2da.c | |
parent | 7616da91495decee1b3aabaa2099d4c25235ac72 (diff) | |
download | scilab2c-7e7df6ec419bfcb7d5dc97dc4af973b6ea5c2c09.tar.gz scilab2c-7e7df6ec419bfcb7d5dc97dc4af973b6ea5c2c09.tar.bz2 scilab2c-7e7df6ec419bfcb7d5dc97dc4af973b6ea5c2c09.zip |
Adapt find2d for generation
Diffstat (limited to 'src/auxiliaryFunctions/find2d/sfind2da.c')
-rw-r--r-- | src/auxiliaryFunctions/find2d/sfind2da.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/auxiliaryFunctions/find2d/sfind2da.c b/src/auxiliaryFunctions/find2d/sfind2da.c index 69b4081e..a0f9fae6 100644 --- a/src/auxiliaryFunctions/find2d/sfind2da.c +++ b/src/auxiliaryFunctions/find2d/sfind2da.c @@ -13,26 +13,23 @@ #include "find2d.h" #include <malloc.h> #include <stdio.h> - -void sfind2da(float* x, int rows, int columns, float** out1, float** out2) { +void sfind2da(float* x, int rows, int columns, float* out1,int* indiceOut1, float* out2,int* indiceOut2) { int i = 0, j=0; - int indiceOut = 0; - float* out_1 = NULL, *out_2=NULL; - - /* We suppose out1 and out2 are NULL on input */ + indiceOut1[1] = 0; + + /* if out are empties */ + out1[0]=-1; + out2[0]=-1; for (i = 0; i < rows ; ++i) { for (j = 0; j < columns ; ++j) { - if (x[i*columns+j] != 0) { - out_1 = realloc(out_1, (uint)(indiceOut+1)*sizeof(float)); - out_2 = realloc(out_2, (uint)(indiceOut+1)*sizeof(float)); + if (x[j*rows+i] != 0) { - out_1[indiceOut] = (float)i; - out_2[indiceOut] = (float)j; - indiceOut++; + out1[indiceOut1[1]] = (float)(i+1); + out2[indiceOut1[1]] = (float)(j+1); + indiceOut1[1]++; } } } - *out1=out_1; - *out2=out_2; + indiceOut2[1]=indiceOut1[1]; } |