silversurfer2025
2006-07-27 14:21:25 UTC
Hello everybdy,
I am a little confused for the following reason:
In my code I used a simple for-loop in order to initialize a 2D-array
of floats to zero. Because of efficiency reasons, I changed it to use
memset and I get totally different results.. How can this be?
Here is the example:
float gaborfilter[filtersize][filtersize];
memset(gaborfilter, 0, sizeof(float) * filtersize * filtersize);
OR
for(int i = 0; i < filtersize;i++){
for(int j = 0; j < filtersize;j++){
gaborfilter[i][j] = 0;
}
}
Later calculations give totally different results using these two
methods. Is there something really obviously different, which I am
currently missing?
Thanks a lot
Tim
I am a little confused for the following reason:
In my code I used a simple for-loop in order to initialize a 2D-array
of floats to zero. Because of efficiency reasons, I changed it to use
memset and I get totally different results.. How can this be?
Here is the example:
float gaborfilter[filtersize][filtersize];
memset(gaborfilter, 0, sizeof(float) * filtersize * filtersize);
OR
for(int i = 0; i < filtersize;i++){
for(int j = 0; j < filtersize;j++){
gaborfilter[i][j] = 0;
}
}
Later calculations give totally different results using these two
methods. Is there something really obviously different, which I am
currently missing?
Thanks a lot
Tim