1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright Bruno Pinçon, ESIAL-IECN, Inria CORIDA project
3 // <bruno.pincon@iecn.u-nancy.fr>
5 // This file is released under the 3-clause BSD license. See COPYING-BSD.
7 // Using small matrices to test condestsp
9 function demo_condestsp()
13 K1 = zeros(nb_tests,3);
15 msg = _("A small test for the condestsp function: condestsp gives an estimate of\n the condition number K1 in 1-norm of a real sparse matrix A:")
17 mprintf(" K1 = ||A||_1 * ||A^(-1)||_1 ")
18 msg = _(" without explicitly computing the inverse of A. condestsp uses a factorization given by\n umf_lufact but if you have already computed this one it is recommended to give the pointer to the factorization.")
20 msg = _("The test consists in forming small sparse matrices (so as to compute K1 exactly with\nnorm(inv(full(A)),1)) whose values are chosen from the normal distribution.")
22 halt(_("\nPress Return to continue...\n"))
25 m = grand(1,1,"uin",1000,2000); // nnz
26 ij = grand(m,2,"uin",1,100);
27 v = grand(m,1,"nor",0,1);
28 A = sparse(ij,v,[n n]);
30 K1(k,1) = condestsp(A,Lup);
31 K1(k,2) = condestsp(A,Lup,5);
32 K1(k,3) = norm(A,1)*norm(inv(full(A)),1);
36 str2 = "------------";
41 mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)
42 mprintf(" | %s | %s | %s | \n",str3,str4,str5)
43 mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)
45 mprintf(" | %e | %e | %e | \n",K1(k,1:3))
47 mprintf(" +-%s-+-%s-+-%s-+ \n",str2,str2,str2)