Note that there are some explanatory texts on larger screens.

plurals
  1. POfftwpp creates a zero filled array after a convolution
    primarykey
    data
    text
    <p>I use fftwpp to transform both my data and my convolution kernel into the fourier space, multiply them together like in a scalar product and convert them back to the real space. When I first run the program, it creates an array which is completely filled with zeros. When I run it again, it gives me the desired results.</p> <p>While running it, a <code>wisdom3.txt</code> is created. If I delete it, the program takes a lot of time to create a zero filled array again.</p> <p>What is wrong with my code?</p> <pre><code>// sx, sy and sz are the dimensions of my data int szp = sz / 2 + 1; size_t align = sizeof(Complex); // creates arrays to store the data in, the double one is for the real data // the Complex one for the fourier data array3&lt;double&gt; f(sx, sy, sz, align); array3&lt;Complex&gt; g(sx, sy, szp, align); // copying data into double array for(int k = 0; k &lt; sz; k++) for(int j = 0; j &lt; sy; j++) for(int i = 0; i &lt; sx; i++) f(i, j, k) = data[i + sx * j + sx * sy * k]; // transforming data into fourier space rcfft3d Forward3(sz, f, g); Forward3.fft(f, g); // generate the kernel array3&lt;double&gt; kernel(sx, sy, sz); array3&lt;Complex&gt; kernel2(sx, sy, szp, align); // more code to create the kernel left out ... // transform the kernel into the fourier space rcfft3d ForwardKernel3(sz, kernel, kernel2); ForwardKernel3.fft(kernel, kernel2); // multiplying data and kernel in fourier space together for(int k = 0; k &lt; szp; k++) for(int j = 0; j &lt; sy; j++) for(int i = 0; i &lt; sx; i++) g(i, j, k) = g(i, j, k) * kernel2(i, j, k); // transform back to normal space crfft3d Backward3(sz, g, f); Backward3.fftNormalized(g, f); // putting everything in the results array and normalize for(int k = 0; k &lt; sz; k++) for(int j = 0; j &lt; sy; j++) for(int i = 0; i &lt; sx; i++) result[i + sx * j + sx * sy * k] = (f(i, j, k) &gt;= thresholdValue ? f(i, j, k) : 0); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload