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 // =============================================================================
7 // <-- CLI SHELL MODE -->
9 // Case where A is given as a function computing the right-hand side
10 mymatrix=[ 94 0 0 0 0 28 0 0 32 0
11 0 59 13 5 0 0 0 10 0 0
12 0 13 72 34 2 0 0 0 0 65
13 0 5 34 114 0 0 0 0 0 55
14 0 0 2 0 70 0 28 32 12 0
15 28 0 0 0 0 87 20 0 33 0
16 0 0 0 0 28 20 71 39 0 0
17 0 10 0 0 32 0 39 46 8 0
18 32 0 0 0 12 33 0 8 82 11
19 0 0 65 55 0 0 0 0 11 100];
30 function y=Atimesx(x,mymatrix)
33 // With the default 10 iterations, the algorithm performs well
34 Alist = list(Atimesx,mymatrix);
35 [xcomputed, fail, err, iter, res]=pcg(Alist,b);
37 if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
38 if fail<>0 then bugmes();quit;end
39 if iter<>10 then bugmes();quit;end
40 if err > 10**3*%eps then bugmes();quit;end