Julia正常的DCT(fftw.jl)行为是吗?
我正在尝试对Julia进行一些压缩感的练习,但是我意识到身份矩阵的离散余弦转换(使用FFTW.JL)看起来并不是其他编程语言(又称Mathematica和Matlab)的结果。
例如,在朱莉娅(Julia)中
using Plots, FFTW, LinearAlgebra
n = 100
Psi = dct(Matrix(1.0I,n,n))
heatmap(Psi)
会导致此矩阵(本质上是具有一定噪声的身份矩阵)
https://i.sstatic.net/kdyvh.png
imagesc(dct(eye(100,100),'Type',2))
“
“ alt = ” 。 a>
终于在Mathematica中
MatrixPlot[N[FourierDCTMatrix[100, 2]], PlotLegends -> Automatic]
返回此
为什么Julia的行为如此不同? 这是正常的吗?
I'm trying to do some exercises of Compressed Sensing on Julia, but i realize that the discrete cosine transformation (using FFTW.jl) of an identity matrix doesn't looks as the result of other programming languages (aka. Mathematica and Matlab).
For example in Julia
using Plots, FFTW, LinearAlgebra
n = 100
Psi = dct(Matrix(1.0I,n,n))
heatmap(Psi)
results in this matrix (which is essentially an identity matrix with some noise)
But in Matlab
imagesc(dct(eye(100,100),'Type',2))
this is the result (as expected)
Finally in Mathematica
MatrixPlot[N[FourierDCTMatrix[100, 2]], PlotLegends -> Automatic]
returns this
Why Julia behaves so differently?
And is this normal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MATLAB(和我猜Mathematica),对矩阵中的每一列进行DCT。当输入是二维时,FFTW执行二维DCT。 FFT也是如此。
如果需要列的转换,则可以指定尺寸:
请注意,y轴的方向相对于MATLAB而言,绘制的方向是相反的。
(顺便说一句,您也可以写
i(n)
或1.0i(n)
,而不是matrix(1.0i,n,n,n,n,n) )
这是将朱莉娅与其他一些语言区分开来的东西。它倾向于将矩阵视为矩阵,而不仅仅是载体的集合或一堆标量。例如,
EXP(M)
和log(M)
用于矩阵不操作元素,但会根据其线性代数定义来计算矩阵指数和矩阵对数。Matlab (and I guess Mathematica), does dct of each column in your matrix. FFTW performs a 2-dimensional dct when the input is two-dimensional. The same happens for fft.
If you want column-wise transformation, you can specify the dimension:
Notice that the direction of the y-axis is opposite for Plots.jl relative to Matlab.
(BTW, you can also just write
I(n)
or1.0I(n)
instead ofMatrix(1.0I,n,n)
)This is something that sets Julia apart from some other languages. It tends to treat matrices as matrices, and not as just a collection of vectors or a bunch of scalars. For example
exp(M)
andlog(M)
for matrices not operate elementwise, but will calculate the matrix exponential and matrix logarithm according to their linear algebra definitions.