• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jul 15th, 2019 321 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. for N=[10, 100, 1000, 2500, 5000, 7500, 10000]
2.     if N<100
3.         N_mult = 1000;
4.     elseif N<5001
5.         N_mult = 100;
6.     else
7.         N_mult = 10;
8.     end
9.     fprintf('N = %d: ', N);
10.
11.     rng(1);
12.     A = rand(N);
13.     B = rand(N);
14.     A_pd = A*A';
15.
16.     tic;
17.     svd(A);
18.     t_svd = toc;
19.     fprintf('SVD ');
20.
21.     tic;
22.     chol(A_pd);
23.     t_chol = toc;
24.     fprintf('Chol ');
25.
26.     tic;
27.     qr(A);
28.     t_qr = toc;
29.     fprintf('QR ');
30.
31.     tic;
32.     for k=1:N_mult
33.         A*B;
34.     end
35.     t_mult = toc;
36.     fprintf('%d mult ', N_mult);
37.
38.     tic;
39.     inv(A);
40.     t_inv = toc;
41.     fprintf('Inv ');
42.
43.     tic;
44.     pinv(A);
45.     t_pinv = toc;
46.     fprintf('Pinv\n\n');
47.
48.     fprintf('TIME IN SECONDS (SIZE: %d):\n', N);
49.     fprintf('SVD: %f\n', t_svd);
50.     fprintf('Cholesky: %f\n', t_chol);
51.     fprintf('QR: %f\n', t_qr);
52.     fprintf('%d matrix products: %f\n', N_mult, t_mult);
53.     fprintf('Inverse: %f\n', t_inv);
54.     fprintf('Pseudo-inverse: %f\n\n', t_pinv);
55. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top