5164
|
1 >> umfpack_demo |
|
2 |
|
3 Enter the printing level for UMFPACK's output statistics: |
|
4 0: none, 1: errors only, 2: statistics, 4: print some of outputs |
|
5 5: print all output [default is 1]: |
|
6 |
|
7 -------------------------------------------------------------- |
|
8 Factor and solve a small system, Ax=b, using default parameters |
|
9 Solving Ax=b via UMFPACK: |
|
10 Solving Ax=b via MATLAB: |
|
11 Difference between UMFPACK and MATLAB solution: 0 |
|
12 |
|
13 -------------------------------------------------------------- |
|
14 |
|
15 Factorizing [L, U, P, Q, R] = umfpack (A) |
|
16 |
|
17 P * (R\A) * Q - L*U should be zero: |
|
18 norm (P*(R\A)*Q - L*U, 1) = 6.80012e-16 (exact) 6.80012e-16 (estimated) |
|
19 |
|
20 Solution to Ax=b via UMFPACK factorization: |
|
21 x = Q * (U \ (L \ (P * (R \ b)))) |
|
22 |
|
23 UMFPACK flop count: 2354 |
|
24 |
|
25 Factorizing [L, U, P] = lu (A (:, q)) |
|
26 If you are using a version of MATLAB prior to V6.0, then the |
|
27 following statement (q = colamd (A)) may fail. Either download |
|
28 colamd from http://www.cise.ufl.edu/research/sparse, upgrade to |
|
29 MATLAB V6.0 or later, or replace the statement with |
|
30 q = colmmd (A) ; |
|
31 |
|
32 Solution to Ax=b via MATLAB factorization: |
|
33 x = U \ (L \ (P * b)) ; x (q) = x ; |
|
34 Difference between UMFPACK and MATLAB solution: 7.10543e-15 |
|
35 |
|
36 MATLAB LU flop count: 3164 |
|
37 |
|
38 -------------------------------------------------------------- |
|
39 Solve A'x=b: |
|
40 Solving A'x=b via UMFPACK: |
|
41 Solving A'x=b via MATLAB: |
|
42 Difference between UMFPACK and MATLAB solution: 2.66454e-15 |
|
43 |
|
44 -------------------------------------------------------------- |
|
45 Compute C = A', and compute the LU factorization of C. |
|
46 Factorizing A' can sometimes be better than factorizing A itself |
|
47 (less work and memory usage). Solve C'x=b; the solution is the |
|
48 same as the solution to Ax=b for the original A. |
|
49 |
|
50 P * (R\C) * Q - L*U should be zero: |
|
51 norm (P*(R\C)*Q - L*U, 1) = 1.94289e-16 (exact) 5.55112e-17 (estimated) |
|
52 |
|
53 Solution to Ax=b via UMFPACK, using the factors of C: |
|
54 x = R \ (P' * (L' \ (U' \ (Q' * b)))) ; |
|
55 Solution to Ax=b via MATLAB: |
|
56 Difference between UMFPACK and MATLAB solution: 7.10543e-15 |
|
57 |
|
58 -------------------------------------------------------------- |
|
59 |
|
60 Solve AX=B, where B is n-by-10, and sparse |
|
61 Difference between UMFPACK and MATLAB solution: 6.72949e-14 |
|
62 |
|
63 -------------------------------------------------------------- |
|
64 |
|
65 Solve AX=B, where B is n-by-10, and sparse, using umfpack_btf |
|
66 Difference between UMFPACK and MATLAB solution: 8.51541e-14 |
|
67 |
|
68 -------------------------------------------------------------- |
|
69 |
|
70 Solve A'X=B, where B is n-by-10, and sparse |
|
71 Difference between UMFPACK and MATLAB solution: 7.99291e-14 |
|
72 |
|
73 -------------------------------------------------------------- |
|
74 det(A): -4.07453e-05 UMFPACK determinant: -4.07453e-05 |
|
75 >> |
|
76 >> diary off |