R
richardveitch77
I'm writting a peice of code for the numerical reconstruction of
digital holograms. I have carried out a two dimensional fft using
fftw. The output of which is stored in an array of fftw_complex.
After the fft I need to manipulate the output array so I have used a
nested for loop to cycle through the values. My code for the loop
looks like this
double intensity_array [MAXX][MAXY];
for (int xx=0 ; xx < width ; xx++)
{
for (int yy=0 ; yy < height ; yy++)
{
intensity_array[xx][yy] =
(out[yy+height*xx][0]*out[yy+height*xx][0])+(out[yy+height*xx][1]*out[yy+height*xx][1]);
}
}
This code compiles fine with msvs.net but when I run the program I get
a message stating that my program has encountered a problem and needs
to end.
Through experimentation I have found that if I change the code so that
the result of each iteration is stored in one column the original array
like this
for (int xx=0 ; xx < width ; xx++)
{
for (int yy=0 ; yy < height ; yy++)
{
out[yy+height*xx][0] =
(out[yy+height*xx][0]*out[yy+height*xx][0])+(out[yy+height*xx][1]*out[yy+height*xx][1]);
}
}
my code will run fine. I'd like to avoid this however as I loose the
original data which I may use later. Any help or advise would be
greatly appreciated.
digital holograms. I have carried out a two dimensional fft using
fftw. The output of which is stored in an array of fftw_complex.
After the fft I need to manipulate the output array so I have used a
nested for loop to cycle through the values. My code for the loop
looks like this
double intensity_array [MAXX][MAXY];
for (int xx=0 ; xx < width ; xx++)
{
for (int yy=0 ; yy < height ; yy++)
{
intensity_array[xx][yy] =
(out[yy+height*xx][0]*out[yy+height*xx][0])+(out[yy+height*xx][1]*out[yy+height*xx][1]);
}
}
This code compiles fine with msvs.net but when I run the program I get
a message stating that my program has encountered a problem and needs
to end.
Through experimentation I have found that if I change the code so that
the result of each iteration is stored in one column the original array
like this
for (int xx=0 ; xx < width ; xx++)
{
for (int yy=0 ; yy < height ; yy++)
{
out[yy+height*xx][0] =
(out[yy+height*xx][0]*out[yy+height*xx][0])+(out[yy+height*xx][1]*out[yy+height*xx][1]);
}
}
my code will run fine. I'd like to avoid this however as I loose the
original data which I may use later. Any help or advise would be
greatly appreciated.