Why does MATLAB take a longer time to compute the SVD of matrices whos size is a power of 2?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 27 de Jun. de 2009
Editada: MathWorks Support Team
el 17 de Jun. de 2024
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.
Respuesta aceptada
MathWorks Support Team
el 12 de Jun. de 2024
Editada: MathWorks Support Team
el 17 de Jun. de 2024
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 comentario
Philip Borghesani
el 23 de Oct. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!