Why does MATLAB take a longer time to compute the SVD of matrices whos size is a power of 2?
14 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Commented: Philip Borghesani
on 23 Oct 2017
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.
Accepted Answer
MathWorks Support Team
on 25 Jan 2017
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 Comment
Philip Borghesani
on 23 Oct 2017
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
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!