Computational time of qr, svd and eig?

조회 수: 4 (최근 30일)
Duc Anh Le
Duc Anh Le 2019년 5월 2일
편집: Duc Anh Le 2019년 5월 3일
How does the time for qr depend on the dimensions of the matrix m and n (does it depend on on the type of linear systems: overdetermined and underdetermined?) How about svd and eig? Does the time depend on whether you ask only for the eigenvalues (as in E=eig(A)) or also for the eigenvectors (as in [V,E]=eig(A))?
  댓글 수: 4
KSSV
KSSV 2019년 5월 3일
why not...show us your code....let us check....
Duc Anh Le
Duc Anh Le 2019년 5월 3일
편집: Duc Anh Le 2019년 5월 3일
%% Computational time for qr.
clear all; clc; close all;
m = 700;
n = 500;
for k = 1:100
B1 = randn(m,n); % m>n
B2 = randn(n,m); % m<n
tic;
[Q1,R1] = qr(B1);
toc;
t1(k) = toc;
tic;
[Q2,R2] = qr(B2);
toc;
t2(k) = toc;
end
mean(t1)
mean(t2)
j = 1:100;
figure(1);
plot(j,(t1))
xlabel('# of trial')
ylabel('Elapsed time')
title('Elapsed time for the qr operator (m<n)')
axis([0 100 0 0.05])
figure(2)
plot(j,(t2))
xlabel('# of trial')
ylabel('Elapsed time')
title('Elapsed time for the qr operator (m>n)')
axis([0 100 0 0.05])

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2019년 5월 3일
%% Computational time for qr.
clear all; clc; close all;
m = 700;
n = 500;
N = 100 ;
t11 = zeros(N,1) ;
t21 = zeros(N,1) ;
for k = 1:N
B1 = randn(m,n); % m>n
B2 = randn(n,m); % m<n
t10 = tic;
[Q1,R1] = qr(B1);
t11(k) = toc(t10);
t20 = tic;
[Q2,R2] = qr(B2);
t21(k) = toc(t20);
end
mean(t11)
mean(t21)
j = 1:N;
figure(1);
plot(j,t11,'r',j,t21,'b')
xlabel('# of trial')
ylabel('Elapsed time')
legend('qr for m<n','qr for m>n')
axis([0 100 0 0.05])
  댓글 수: 1
Duc Anh Le
Duc Anh Le 2019년 5월 3일
편집: Duc Anh Le 2019년 5월 3일
Thanks for the correction, is there an explanation to why the elapsed time for m < n is less than for m > n?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by