- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从我读到的内容来看,当 A 是二维数组时,使用 FFTW.jl/AbstractFFTs.jl 的 fft(A) 应该在二维中执行 fft,而不是按列执行。知道为什么当(我认为)我将缩放的二阶空间导数添加到 u(t,x) 时,我只看到按列扩散,就好像使用显式求解器一样?
谢谢!我对此很陌生。
code and heatmap screenshot
using Random
using FFTW
using Plots
gr()
N = (100,100)
# initialize with gaussian noise
u = randn(Float16, (N[1], N[2])).*0.4.+0.4
# include square of high concentration to observe diffusion clearly
u[40:50,40:50] .= 3
N = size(x)
L = 100
k1 = fftfreq(51)
k2 = fftfreq(51)
lap_mat = -(k1.^2 + k2.^2)
function lap_fft(x)
lapF = rfft(x)
lap = irfft(lap_mat.*lapF, 100)
return lap
end
# ode stepper or Implicit-Explicit solver
for i in 1:100000
u+=lap_fft(u)*0.0001
end
# plot state
heatmap(u)
最佳答案
仅仅因为您正在执行真正的 FFT,并不意味着您可以对结果进行真正的逆fft。 rfft 来自 R -> C。但是你可以做的是以下内容:
function lap_fft(x)
lapF = complex(zeros(100,100)); # only upper half filled
lapF[1:51,1:100] = rfft(x) .* lap_mat; # R -> C
return abs.(ifft(lapF)); # C -> R
end
真正的 FFT 到复频域(由于数据冗余,只填充了上半部分),在频域中乘以您的滤波器,将 FFT 逆向复数图像域并获得幅度
abs.()
, 实部
real.()
等等。
using Random
using FFTW
using Plots
gr()
N = (100,100)
# initialize with gaussian noise
u = randn(Float16, (N[1], N[2])).*0.4.+0.4;
# include square of high concentration to observe diffusion clearly
u[40:50,40:50] .= 3;
N = size(u);
L = 100;
k1 = fftfreq(100);
k2 = fftfreq(100);
tmp = -(k1.^2 + k2.^2);
lap_mat = sqrt.(tmp.*reshape(tmp,1,100));
function lap_fft(x)
return abs.(ifftshift(ifft(fftshift(ifftshift(fft(fftshift(x))).*lap_mat))));
end
# ode stepper or Implicit-Explicit solver
for i in 1:100000
u+=lap_fft(u)*0.001;
end
# plot state
heatmap(u)
关于julia - 二维数组 : Diffusion only happening in 1D 的 FFTW.jl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67513291/
上周我一直在用 FFTW 编程一些二维卷积,方法是将两个信号传递到频域,相乘,然后返回。 令人惊讶的是,只有当输入大小小于固定数字时,我才能得到正确的结果! 我发布了一些工作代码,其中我采用简单的初始
有没有办法检查 - 凋零 FFTW 是以单精度还是 double 编译的? 最佳答案 如果库的名称以 f 为后缀,则为单精度。否则就是双标。例如, libfftw3.a 是 double libfft
我正在学习如何使用 Fortran 处理 FFTW 包。为了生成一个易于验证的示例,我计算了一个二维平面的功率谱,我用两个不同的叠加波填充它。这样,我就可以确切地知道功率谱中的峰值在哪里。 由于 FF
我需要使用具有不同算术精度和多线程计划的 FFTW。 我需要为所有精度设置多线程?像这样: fftwf_init_threads(); fftwf_plan_with_nthreads(nthread
我正在尝试在 C 中使用 fftw3.3.5 进行 DFT。但是我目前在将 DFT 应用于实际数据时遇到了麻烦,它会导致一些奇怪的结果,比如极大的数字,以及不对称的东西。 这是测试代码: #inclu
我正在使用 FFTW 来计算二维复数数据的逆 DFT。默认设置(复数到复数)的输出是复数,虚部不为零。但是,我只对结果的实部感兴趣,而不对复数部分感兴趣。 FFTW 的交错实数复数输出对我来说并不理想
我在程序中使用 FFTW3 对 2D 数组(大约 3k x 3k,复杂数据类型)进行一些处理。 该计划最激烈的部分基本上是这样做的: Break the array up into N threads
我正在读取一个原始声音文件,并尝试对其运行 fft,目的是在最后获取 PSD,但我在开始时收到了一个错误,我可以'不太明白,希望在这里得到一些帮助,代码是: #include #include i
我使用以下代码来执行复数数组的 COMPLEX IFFT(我必须获得复数结果): #include #include #include #include #include #include
我正在努力为 FFTW 操作实现更好的性能。出于这个原因,我决定使用智慧文件来创建计划,但问题是它无法从智慧文件中加载计划(导出智慧效果很好)。我试图将智慧导出到一个文件,并在下一个程序运行时将其加载
我想在线程中使用 fftw3。但是代码粘贴在http://codepad.org/lIjdGF5z导致“double free or corruption”错误。如何正确调用线程中的 fftw3 例程
我的最终目标是从单声道波形文件中提取所有低于 15KHz 的声音信息。该程序将样本加载到内存中,并将其表示为 16 位有符号整数数组。 我用的是FFTW,它有复数多维fft、实数多维fft、实数一维f
我正在尝试在拆分数组上使用 fftw (3.3.4)。我从 C/MEX 指南 (PDF: http://www.researchgate.net/publictopics.PublicPostFile
我安装了一个新系统和上面的所有库。但是,我对 fftw 有疑问。 cmake 命令后出现以下错误 CMake Error at /usr/share/cmake/Modules/FindPackage
我正试图让 FFTW 在 C 中工作。它曾经为另一个项目(在 JNI 中)工作,我或多或少地从那个项目中复制代码,遗憾的是没有结果。 首先我生成一个正弦信号,如下所示: double* generat
我正在尝试使用 FFTW 库计算 53k 双样本的 FFT,并在此基础上猜测信号的基频是多少。样本由sndfile库在wav输入文件的基础上生成(程序加载wav文件,生成double数据的样本并保存到
我对信号处理还很陌生,所以请原谅我的吐槽。我已经下载并安装了适用于 Windows 的 FFTW。文档没问题,但我仍有疑问。 我的总体目标是从计算机上的声卡捕获以 44100 采样/秒采样的原始音频数
我正在使用 FFTW 的线程版本(一个 FFT 库)来尝试加速双 CPU 机器上的一些代码。这是只有 1 个线程的时间输出: 131.838u 1.979s 2:13.91 99.9% 这里有 2 个
我想知道是否可以存储来自 FFTW 的一维 FFT 调用的转置矩阵。考虑我的矩阵 nrows_1 x w_size。目前它存储在大小为 w_size 的 block 中 for (ix = 0 ; i
我实现了一个 fftw (fftw.org) 示例来使用快速傅立叶变换...这是代码.... 我加载了一张我从 uint8_t 转换为 double 的图像(此代码工作正常...)。 string b
我是一名优秀的程序员,十分优秀!