File: test6.m

package info (click to toggle)
ufsparse 1.2-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,536 kB
  • ctags: 5,848
  • sloc: ansic: 89,328; makefile: 4,721; fortran: 1,991; csh: 207; sed: 162; awk: 33; java: 30; sh: 8
file content (45 lines) | stat: -rw-r--r-- 699 bytes parent folder | download
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
rand ('state', 0)
maxerr = 0 ;
clf
for trial = 1:201
    n = fix (100 * rand (1)) ;
    d = 0.1 * rand (1) ;
    L = tril (sprandn (n,n,d),-1) + speye (n) ;
    b = sprandn (n,1,d) ;

    x = L\b ;
    sr = 1 + cs_reachr (L,b) ;
    sz = 1 + cs_reachr (L,b) ;

    same (sr,sz) ;

    s2 = 1 + cs_reach (L,b) ;
    x2 = cs_splsolve (L,b) ;

    spy ([L b x x2])

    s = sort (sr) ;
    [i j xx] = find (x) ;

    if (isempty (i))
	if (~isempty (s))
	    error ('!') ;
	end
    elseif (any (s ~= i))
	error ('!') ;
    end

    if (any (s2 ~= sr))
	error ('!') ;
    end

    err = norm (x-x2,1) ;
    if (err > 1e-12)
	error ('!') 
    end

    maxerr = max (maxerr, err) ;

    drawnow
end
maxerr