summaryrefslogtreecommitdiff
path: root/modules/umfpack/examples/scisptdem3.dem
blob: 4e38ecf4a62c783b6287c8350c36b6e8283dd60a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// pour tester condestsp
//
// on utilise des petites matrices pour verifier

nb_tests = 20;
n = 100;
K1 = zeros(nb_tests,3);
 
messagebox(["A small test for the condestsp"     ;...
	   "function : condestsp gives an"      ;...
	   "estimate of the condition number K1";...
	   "in 1-norm of a real sparse matrix A:";...
	   "                                 "  ;...
	   "  K1 = || A ||_1 || A^(-1) ||_1  "  ;...
	   "                                 "  ;...
	   "without explicitly computing the"   ;...
	   "inverse of A. condestsp uses a"    ;...
	   "factorization given by umf_lufact"  ;...
	   "but if you have already computed"   ;...
	   "this one it is recommended to give" ;...
	   "the pointer onto the factorization.";...
	   "                                   ";...
	   "The test consists in forming small ";...
	   "sparse matrices (so as to compute  ";...
	   "exactly K1 with norm(inv(full(A)),1))";...
           "whose values are choosen from the"  ;...
           "normal distribution.               "],"modal","info");

for k = 1:nb_tests
   m = grand(1,1,"uin",1000,2000);  // nnz
   ij = grand(m,2,"uin",1,100);
   v = grand(m,1,"nor",0,1);
   A = sparse(ij,v,[n n]);
   Lup = umf_lufact(A);
   K1(k,1) = condestsp(A,Lup);
   K1(k,2) = condestsp(A,Lup,5);
   K1(k,3) = norm(A,1)*norm(inv(full(A)),1);
   umf_ludel(Lup)
end

str2 = "------------";
str3 = "condest  t=2";
str4 = "condest  t=5";
str5 = "  K1 exact  ";

mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)
mprintf(" | %s | %s | %s | \n",str3,str4,str5)
mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)	
for k=1:nb_tests
   mprintf(" | %e | %e | %e | \n",K1(k,1:3))
end
mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)