|
|
r2cfft
looks like:
|
|
|
|
is A supposed to be ~1.0? see line 11? |
ne0[i + (ny+1)*j]
is also matching between C++ and MATLAB. Only the FFT output is not. +3.82e+00 +0.00e+00 -1.80e+00 -4.00e+01 -1.97e+00 -6.30e-01 +4.05e-01 -1.52e+00 +9.34e-01 -6.64e-01 +1.05e+00 +0.00e+00 -1.85e+01 -2.02e+01 +6.62e-01 +2.07e+00 -1.23e+00 +6.41e-02 +2.02e-01 -8.18e-01 +6.36e-01 -4.72e-01 +9.01e-01 -6.76e-02 +6.46e-01 -8.28e-01 -5.02e-02 +1.32e+00 -1.19e+00 -6.35e-02 -9.81e-02 -5.93e-01 +1.47e-01 -4.52e-01 +3.12e-01 -3.33e-01 +6.04e-01 -4.22e-01 -2.48e-01 +9.81e-01 -9.30e-01 -2.42e-01 +4.00e-02 -4.36e-01 +1.82e-01 -2.85e-01 +2.70e-01 -1.70e-01 +5.91e-01 -1.87e-01 -4.27e-01 +7.81e-01 -7.76e-01 -4.23e-01 +1.37e-01 -3.52e-01 +2.15e-01 -1.90e-01 +2.38e+00 +4.92e+00 +5.88e-01 +0.00e+00 -6.02e-01 +6.27e-01 -6.59e-01 -6.19e-01 +2.24e-01 -2.89e-01 +6.16e-01 +5.00e+00 +2.54e-01 +0.00e+00 -1.80e+00 -4.00e+01 -1.97e+00 -6.30e-01 +4.05e-01 -1.52e+00 +9.34e-01 -6.64e-01 +1.05e+00 +0.00e+00 +9.34e-01 +6.64e-01 +6.62e-01 +2.07e+00 -1.23e+00 +6.41e-02 +2.02e-01 -8.18e-01 +6.36e-01 -4.72e-01 +9.01e-01 -6.76e-02 +1.10e+00 +5.46e-01 -5.02e-02 +1.32e+00 -1.19e+00 -6.35e-02 -9.81e-02 -5.93e-01 +1.47e-01 -4.52e-01 +3.12e-01 -3.33e-01 +4.76e-01 -1.93e-01 -2.48e-01 +9.81e-01 -9.30e-01 -2.42e-01 +4.00e-02 -4.36e-01 +1.82e-01 -2.85e-01 +2.70e-01 -1.70e-01 +4.73e+00 +4.76e+00 |
Columns 1 through 6 0.0000 + 0.0000i 5.1431 + 0.0000i 8.3217 + 0.0000i 8.3217 + 0.0000i 5.1431 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 2.4319 - 2.3526i 3.9350 - 3.8066i 3.9350 - 3.8066i 2.4319 - 2.3526i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.5249 - 1.0386i 0.8493 - 1.6805i 0.8493 - 1.6805i 0.5249 - 1.0386i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.5738 - 0.5483i 0.9284 - 0.8872i 0.9284 - 0.8872i 0.5738 - 0.5483i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.5843 - 0.2843i 0.9454 - 0.4601i 0.9454 - 0.4601i 0.5843 - 0.2843i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.5874 - 0.0890i 0.9505 - 0.1440i 0.9505 - 0.1440i 0.5874 - 0.0890i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.5874 + 0.0890i 0.9505 + 0.1440i 0.9505 + 0.1440i 0.5874 + 0.0890i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.5843 + 0.2843i 0.9454 + 0.4601i 0.9454 + 0.4601i 0.5843 + 0.2843i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.5738 + 0.5483i 0.9284 + 0.8872i 0.9284 + 0.8872i 0.5738 + 0.5483i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.5249 + 1.0386i 0.8493 + 1.6805i 0.8493 + 1.6805i 0.5249 + 1.0386i 0.0000 + 0.0000i 0.0000 + 0.0000i 2.4319 + 2.3526i 3.9350 + 3.8066i 3.9350 + 3.8066i 2.4319 + 2.3526i 0.0000 + 0.0000i Columns 7 through 10 -5.1431 + 0.0000i -8.3217 + 0.0000i -8.3217 + 0.0000i -5.1431 + 0.0000i -2.4319 + 2.3526i -3.9350 + 3.8066i -3.9350 + 3.8066i -2.4319 + 2.3526i -0.5249 + 1.0386i -0.8493 + 1.6805i -0.8493 + 1.6805i -0.5249 + 1.0386i -0.5738 + 0.5483i -0.9284 + 0.8872i -0.9284 + 0.8872i -0.5738 + 0.5483i -0.5843 + 0.2843i -0.9454 + 0.4601i -0.9454 + 0.4601i -0.5843 + 0.2843i -0.5874 + 0.0890i -0.9505 + 0.1440i -0.9505 + 0.1440i -0.5874 + 0.0890i -0.5874 - 0.0890i -0.9505 - 0.1440i -0.9505 - 0.1440i -0.5874 - 0.0890i -0.5843 - 0.2843i -0.9454 - 0.4601i -0.9454 - 0.4601i -0.5843 - 0.2843i -0.5738 - 0.5483i -0.9284 - 0.8872i -0.9284 - 0.8872i -0.5738 - 0.5483i -0.5249 - 1.0386i -0.8493 - 1.6805i -0.8493 - 1.6805i -0.5249 - 1.0386i -2.4319 - 2.3526i -3.9350 - 3.8066i -3.9350 - 3.8066i -2.4319 - 2.3526i |
|
|
Why isn’t your (stated) output from the c++ code a set of complex numbers? |
What is nyk? |
|
|
(3.82,0.00), (-1.80,-40.01), (-1.97,-0.63), (0.41,-1.52), (0.93,-0.66), (1.05,0.00), (-18.55,-20.20), (0.66,2.07), (-1.23,0.06), (0.20,-0.82), (0.64,-0.47), (0.90,-0.07), (0.65,-0.83), (-0.05,1.32), (-1.19,-0.06), (-0.10,-0.59), (0.15,-0.45), (0.31,-0.33), (0.60,-0.42), (-0.25,0.98), (-0.93,-0.24), (0.04,-0.44), (0.18,-0.28), (0.27,-0.17), (0.59,-0.19), (-0.43,0.78), (-0.78,-0.42), (0.14,-0.35), (0.21,-0.19), (2.38,4.92), (0.59,0.00), (-0.60,0.63), (-0.66,-0.62), (0.22,-0.29), (0.62,5.00), (0.25,0.00), (-1.80,-40.01), (-1.97,-0.63), (0.41,-1.52), (0.93,-0.66), (1.05,0.00), (0.93,0.66), (0.66,2.07), (-1.23,0.06), (0.20,-0.82), (0.64,-0.47), (0.90,-0.07), (1.10,0.55), (-0.05,1.32), (-1.19,-0.06), (-0.10,-0.59), (0.15,-0.45), (0.31,-0.33), (0.48,-0.19), (-0.25,0.98), (-0.93,-0.24), (0.04,-0.44), (0.18,-0.28), (0.27,-0.17), (4.73,4.76), |
12.69, 2.00, -4.85, -0.00, -1.50, 0.00, -1.50, 0.00, -4.85, -2.00, 10.99, -0.15, -4.20, 0.00, -1.30, 0.00, -1.30, -0.00, -4.20, 0.15, 8.90, -1.57, -3.40, 0.00, -1.05, 0.00, -1.05, -0.00, -3.40, 1.57, 6.50, -2.10, -2.48, 0.00, -0.77, 0.00, -0.77, -0.00, -2.48, 2.10, 4.34, -1.75, -1.66, 0.00, -0.51, 0.00, -0.51, -0.00, -1.66, 1.75, 2.84, -0.83, -1.08, -0.00, -0.34, 0.00, -0.34, 0.00, -1.08, 0.83, 2.13, 0.22, -0.81, 0.00, -0.25, 0.00, -0.25, -0.00, -0.81, -0.22, 1.98, 1.04, -0.76, -0.00, -0.23, 0.00, -0.23, 0.00, -0.76, -1.04, 1.96, 1.48, -0.75, -0.00, -0.23, 0.00, -0.23, 0.00, -0.75, -1.48, 1.54, 1.66, -0.59, 0.00, -0.18, 0.00, -0.18, -0.00, -0.59, -1.66, |
u = (Y-0.5).^2 .* sin( (2*pi / Lx) * X) |
14.53, 0.00, -5.55, 0.00, -1.71, 0.00, -1.71, 0.00, -5.55, 0.00, 13.59, 0.00, -5.19, 0.00, -1.60, 0.00, -1.60, 0.00, -5.19, 0.00, 11.06, 0.00, -4.23, 0.00, -1.31, 0.00, -1.31, 0.00, -4.23, 0.00, 7.64, 0.00, -2.92, 0.00, -0.90, 0.00, -0.90, 0.00, -2.92, 0.00, 4.23, 0.00, -1.61, 0.00, -0.50, 0.00, -0.50, 0.00, -1.61, 0.00, 1.61, 0.00, -0.62, 0.00, -0.19, 0.00, -0.19, 0.00, -0.62, 0.00, 0.24, 0.00, -0.09, 0.00, -0.03, 0.00, -0.03, 0.00, -0.09, 0.00, 0.05, 0.00, -0.02, 0.00, -0.01, 0.00, -0.01, 0.00, -0.02, 0.00, 0.62, 0.00, -0.24, 0.00, -0.07, 0.00, -0.07, 0.00, -0.24, 0.00, 1.31, 0.00, -0.50, 0.00, -0.15, 0.00, -0.15, 0.00, -0.50, 0.00, 1.61, 0.00, -0.62, 0.00, -0.19, 0.00, -0.19, 0.00, -0.62, 0.00, |
|
|
Original function: (0.0000,0.0000) (1.3225,0.0000) (2.1399,0.0000) (2.1399,0.0000) (1.3225,0.0000) (0.0000,0.0000) (-1.3225,0.0000) (-2.1399,0.0000) (-2.1399,0.0000) (-1.3225,0.0000) (0.0000,0.0000) (1.2376,0.0000) (2.0025,0.0000) (2.0025,0.0000) (1.2376,0.0000) (0.0000,0.0000) (-1.2376,0.0000) (-2.0025,0.0000) (-2.0025,0.0000) (-1.2376,0.0000) (0.0000,0.0000) (1.0072,0.0000) (1.6297,0.0000) (1.6297,0.0000) (1.0072,0.0000) (0.0000,0.0000) (-1.0072,0.0000) (-1.6297,0.0000) (-1.6297,0.0000) (-1.0072,0.0000) (0.0000,0.0000) (0.6955,0.0000) (1.1254,0.0000) (1.1254,0.0000) (0.6955,0.0000) (0.0000,0.0000) (-0.6955,0.0000) (-1.1254,0.0000) (-1.1254,0.0000) (-0.6955,0.0000) (0.0000,0.0000) (0.3847,0.0000) (0.6225,0.0000) (0.6225,0.0000) (0.3847,0.0000) (0.0000,0.0000) (-0.3847,0.0000) (-0.6225,0.0000) (-0.6225,0.0000) (-0.3847,0.0000) (0.0000,0.0000) (0.1469,0.0000) (0.2378,0.0000) (0.2378,0.0000) (0.1469,0.0000) (0.0000,0.0000) (-0.1469,0.0000) (-0.2378,0.0000) (-0.2378,0.0000) (-0.1469,0.0000) (0.0000,0.0000) (0.0214,0.0000) (0.0347,0.0000) (0.0347,0.0000) (0.0214,0.0000) (0.0000,0.0000) (-0.0214,0.0000) (-0.0347,0.0000) (-0.0347,0.0000) (-0.0214,0.0000) (0.0000,0.0000) (0.0045,0.0000) (0.0073,0.0000) (0.0073,0.0000) (0.0045,0.0000) (0.0000,0.0000) (-0.0045,0.0000) (-0.0073,0.0000) (-0.0073,0.0000) (-0.0045,0.0000) (0.0000,0.0000) (0.0561,0.0000) (0.0908,0.0000) (0.0908,0.0000) (0.0561,0.0000) (0.0000,0.0000) (-0.0561,0.0000) (-0.0908,0.0000) (-0.0908,0.0000) (-0.0561,0.0000) (0.0000,0.0000) (0.1196,0.0000) (0.1935,0.0000) (0.1935,0.0000) (0.1196,0.0000) (0.0000,0.0000) (-0.1196,0.0000) (-0.1935,0.0000) (-0.1935,0.0000) (-0.1196,0.0000) (0.0000,0.0000) (0.1469,0.0000) (0.2378,0.0000) (0.2378,0.0000) (0.1469,0.0000) (0.0000,0.0000) (-0.1469,0.0000) (-0.2378,0.0000) (-0.2378,0.0000) (-0.1469,0.0000) Discrete Fourier transform w.r.t. y ONLY: (0.0000,0.0000) (5.1431,0.0000) (8.3217,0.0000) (8.3217,0.0000) (5.1431,0.0000) (0.0000,0.0000) (-5.1431,0.0000) (-8.3217,0.0000) (-8.3217,0.0000) (-5.1431,0.0000) (0.0000,0.0000) (2.4319,-2.3526) (3.9350,-3.8066) (3.9350,-3.8066) (2.4319,-2.3526) (0.0000,-0.0000) (-2.4319,2.3526) (-3.9350,3.8066) (-3.9350,3.8066) (-2.4319,2.3526) (0.0000,0.0000) (0.5249,-1.0386) (0.8493,-1.6805) (0.8493,-1.6805) (0.5249,-1.0386) (0.0000,-0.0000) (-0.5249,1.0386) (-0.8493,1.6805) (-0.8493,1.6805) (-0.5249,1.0386) (0.0000,0.0000) (0.5738,-0.5483) (0.9284,-0.8872) (0.9284,-0.8872) (0.5738,-0.5483) (0.0000,-0.0000) (-0.5738,0.5483) (-0.9284,0.8872) (-0.9284,0.8872) (-0.5738,0.5483) (0.0000,0.0000) (0.5843,-0.2843) (0.9454,-0.4601) (0.9454,-0.4601) (0.5843,-0.2843) (0.0000,-0.0000) (-0.5843,0.2843) (-0.9454,0.4601) (-0.9454,0.4601) (-0.5843,0.2843) (0.0000,0.0000) (0.5874,-0.0890) (0.9505,-0.1440) (0.9505,-0.1440) (0.5874,-0.0890) (0.0000,-0.0000) (-0.5874,0.0890) (-0.9505,0.1440) (-0.9505,0.1440) (-0.5874,0.0890) (0.0000,0.0000) (0.5874,0.0890) (0.9505,0.1440) (0.9505,0.1440) (0.5874,0.0890) (0.0000,0.0000) (-0.5874,-0.0890) (-0.9505,-0.1440) (-0.9505,-0.1440) (-0.5874,-0.0890) (0.0000,0.0000) (0.5843,0.2843) (0.9454,0.4601) (0.9454,0.4601) (0.5843,0.2843) (0.0000,0.0000) (-0.5843,-0.2843) (-0.9454,-0.4601) (-0.9454,-0.4601) (-0.5843,-0.2843) (0.0000,0.0000) (0.5738,0.5483) (0.9284,0.8872) (0.9284,0.8872) (0.5738,0.5483) (0.0000,0.0000) (-0.5738,-0.5483) (-0.9284,-0.8872) (-0.9284,-0.8872) (-0.5738,-0.5483) (0.0000,0.0000) (0.5249,1.0386) (0.8493,1.6805) (0.8493,1.6805) (0.5249,1.0386) (0.0000,0.0000) (-0.5249,-1.0386) (-0.8493,-1.6805) (-0.8493,-1.6805) (-0.5249,-1.0386) (0.0000,0.0000) (2.4319,2.3526) (3.9350,3.8066) (3.9350,3.8066) (2.4319,2.3526) (0.0000,0.0000) (-2.4319,-2.3526) (-3.9350,-3.8066) (-3.9350,-3.8066) (-2.4319,-2.3526) |
fft(u)
and also the full MATLAB code is:
|
|
This doesn't quite compile for me because I didn't have the definitions of some constants, but I think int constexpr nx = 10, ny = 10, ncomp = 2, nyk = 6; and after adding that it compiles. |
|
|
|
|