1
function x = kludemo (A, b)
4
% Writes out the matrix A as a file, calls the
5
% stand-alone kludemo program, and reads the
6
% solution back in. If b is not provided, it
7
% is constructed as b = A*xtrue where
8
% xtrue = 1 + (0:n-1) / n.
12
error ('A must be square') ;
15
% create the files for the matrix A
16
[Ai j Ax] = find (A) ;
17
Ap = cumsum ([1 (sum (spones (A)))]) ;
21
f = fopen ('tmp/Asize', 'w') ;
22
fprintf (f, '%d %d %d\n', n, n, nnz (A)) ;
25
f = fopen ('tmp/Ap', 'w') ;
26
fprintf (f, '%d\n', Ap) ;
29
f = fopen ('tmp/Ai', 'w') ;
30
fprintf (f, '%d\n', Ai) ;
33
f = fopen ('tmp/Ax', 'w') ;
34
fprintf (f, '%24.16e\n', Ax) ;
38
f = fopen ('tmp/b', 'w') ;
39
fprintf (f, '%24.16e\n', b) ;
42
if (exist ('tmp/b', 'file'))