1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2008 - INRIA - Michael Baudin
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
8 // <-- CLI SHELL MODE -->
11 // Case where A is given as a function computing the right-hand side
12 mymatrix=[ 94 0 0 0 0 28 0 0 32 0
13 0 59 13 5 0 0 0 10 0 0
14 0 13 72 34 2 0 0 0 0 65
15 0 5 34 114 0 0 0 0 0 55
16 0 0 2 0 70 0 28 32 12 0
17 28 0 0 0 0 87 20 0 33 0
18 0 0 0 0 28 20 71 39 0 0
19 0 10 0 0 32 0 39 46 8 0
20 32 0 0 0 12 33 0 8 82 11
21 0 0 65 55 0 0 0 0 11 100];
32 function y=Atimesx(x,mymatrix)
35 // With the default 10 iterations, the algorithm performs well
36 Alist = list(Atimesx,mymatrix)
37 [xcomputed, fail, err, iter, res]=pcg(Alist,b);
39 if norm(xcomputed-xexpected)>10**3*%eps then pause,end
40 if fail<>0 then pause,end
41 if iter<>10 then pause,end
42 if err > 10**3*%eps then pause,end