Why does MATLAB take a longer time to compute the SVD of matrices whos size is a power of 2?
4 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2024-6-17
There is a significant difference in the Singular Value Decomposition computation time when the matrix size is a power of two.
For example, if I compute the SVD of randomly generated square matrices of sizes 511, 512 and 513, note the difference in the computaion times.
A=randn(512);
tic;[u s v]=svd(A);toc
This displays:
Elapsed time is 24.476422 seconds.
However, the following:
A=randn(511);
tic;[u s v]=svd(A);toc
displays:
Elapsed time is 5.049256 seconds.
and
A=randn(513);
tic;[u s v]=svd(A);toc
displays:
Elapsed time is 4.974085 seconds.
I would like to increase the speed and capabilities of SVD computation in MATLAB.
采纳的回答
MathWorks Support Team
2024-6-12
编辑:MathWorks Support Team
2024-6-17
This is expected behavior. This behavior is due to what is called the "cache resonance effect". When the size of a matrix is a power of 2, the cache replacement algorithm is not as effective.
For more information on increasing the speed and capabilities of matrix computation refer to the following URL:
1 个评论
Philip Borghesani
2017-10-23
Although this effect is expected the times and size of the effect are a bit overstated for modern systems, on my machine (Xeon E5-1650 v3) and R2017b I see:
A=randn(511);B=randn(512);C=randn(513);
>> timeit(@()svd(A),3)
ans =
0.0470
>> timeit(@()svd(B),3)
ans =
0.0507
>> timeit(@()svd(C),3)
ans =
0.0466
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!