How is SVDS execution time related to the target rank?
Show older comments
I assumed that the higher the target rank, the longer the running time of the SVDS function would be, but I was getting weird results, so I tried this small test function:
C = rand(400,1024); % random matrix, actual rank = 400
ranks = [5:5:200 250 400];
n = numel(ranks);
running_times = zeros(n,1);
for r = 1:n
for j = 1:10 % average running time for current rank over 10 runs
t = tic;
svds(C, ranks(r));
running_times(r) = running_times(r) + toc(t);
end
running_times(r) = running_times(r)/10;
end
plot(running_times, 'marker', 'o');
set(gca, 'XTick', 1:n, 'XTickLabel', ranks);
xlabel('target rank');
ylabel('seconds');
set(gcf, 'position', [346 346 1334 338]);
set(findall(gca, 'Type', 'Line'), 'LineWidth', 2);
xlim([1 n]);
ylim([0 0.55]);
grid on;
and this are the results I get:

Do you guys know what may cause the huge drop between ranks 130 and 135? And why rank 130 is so much slower than 400 (full rank)?
Thanks!
4 Comments
KSSV
on 23 Aug 2021
I think a small change in calculating the time taken.
C = rand(400,1024); % random matrix, actual rank = 400
ranks = [5:5:200 250 400];
n = numel(ranks);
running_times = zeros(n,1);
for r = 1:n
rt = 0 ;
for j = 1:10 % average running time for current rank over 10 runs
t1 = tic;
svds(C, ranks(r));
t2 = toc(t1) ;
rt = rt+t2;
end
running_times(r) = rt/10;
end
plot(running_times, 'marker', 'o');
set(gca, 'XTick', 1:n, 'XTickLabel', ranks);
xlabel('target rank');
ylabel('seconds');
set(gcf, 'position', [346 346 1334 338]);
set(findall(gca, 'Type', 'Line'), 'LineWidth', 2);
xlim([1 n]);
ylim([0 0.55]);
grid on;
Francesco Di Mauro
on 23 Aug 2021
Francesco Di Mauro
on 23 Aug 2021
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!