Note that there are some explanatory texts on larger screens.

plurals
  1. PODifficulty with zeros from 2D FFTW
    primarykey
    data
    text
    <p>I have a real matrix represented by the structure <code>double input[N][M]</code> where I want to take a 1D FT for each column j = 0..M along the N direction. My attempt at this is as follows:</p> <pre><code>#include &lt;fftw3.h&gt; #include &lt;math.h&gt; #define M_PI 3.14159265358979323846264338327 int main(void) { int N = 16; int M = 2; double input[N][M]; // input data double *in = (double *) input; fftw_complex output[N][M]; // output data fftw_complex *out = (fftw_complex *) output; for (int i = 0; i &lt; N; ++i) { for (int j = 0; j &lt; M; ++j) { double x = (double) i / (double) N; input[i][j] = sin(2*(j+1) * M_PI * x); fprintf (stderr, "input[%d][%d] = %.9f, ", i, j, input[i][j]); } fprintf (stderr, "\n"); } fprintf (stderr, "\n"); // setup plans int rank = 1; int howmany = M; int istride = M; int ostride = M; int idist = 1; int odist = 1; fftw_plan fp = fftw_plan_many_dft_r2c(rank, &amp;N, howmany, in, NULL, istride, idist, out, NULL, ostride, odist, FFTW_MEASURE); // take the forward transform fftw_execute(fp); fprintf (stderr, "FFT complete\n"); for (int j = 0; j &lt; M; ++j) for (int i = 0; i &lt; N/2; ++i) fprintf (stderr, "OUT[%3d] = (%.4f + %.4fi)\n", i, output[i][j][0], output[i][j][1]); fprintf (stderr, "\n"); fftw_destroy_plan(fp); return 0; } </code></pre> <p>which I'm compiling with <code>gcc fft.c -std=c99 -g -lfftw3 -lm</code>. However the code doesn't appear to be working: FT output is all zeros (see <a href="http://pastebin.com/Km2nZx6H" rel="nofollow">here</a>)</p> <p>Documentation for the function is <a href="http://www.fftw.org/doc/Advanced-Real_002ddata-DFTs.html#Advanced-Real_002ddata-DFTs" rel="nofollow">here</a>.</p> <p><strong>EDIT</strong>: update, so it only seems to work for FFTW_ESTIMATE and not any of the <a href="http://www.fftw.org/doc/Planner-Flags.html#Planner-Flags" rel="nofollow">other flags</a>. Any idea why this might be?</p>
    singulars
    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