EpetraExt Development
Loading...
Searching...
No Matches
main.f
Go to the documentation of this file.
1c
2c
3c Purpose: Fortran driver of genbtf, generate block triangular
4c form. A structurally nonsingular matrix is permuted
5c
6c (A(rowperm(i), (colperm(j)), 1 <= i,j, <=n)
7c
8c to block upper triangular with sqcmpn blocks.
9c If matsng != 0, then the matrix is structurally singular
10c (for example has a zero row), and has a complex
11c block triangular form.
12c
13
14
15c
16c rcmstr ccmstr
17c
18c If matsng != 0, then the matrix is structurally singular
19c (for example has a zero row), and has a complex
20c block triangular form.
21c
22c
23c test input
24 parameter(n=3, nnz= 3)
25c and C-style indexing.
26c
27c
28c
29c
30c
31c Start with an n by n matrix in sparse row format
32c ja, ia: column indices and row pointers
33c
34c integer input scalars
35c integer msglvl = 0, output = 6
36 integer msglvl, output
37c
38c integer input arrays
39 integer ia(n+1) , ja(nnz), iat(n+1), jat(nnz)
40c
41c local work space
42 integer w(10*n), i, j
43c
44c integer output scalars
45c
46 integer matsng
47c horizontal block: rows, columns, connected components
48 integer nhrows, nhcols, hrzcmp
49c square block: rows=columns, connected components
50 integer nsrows, sqcmpn
51c vertical block: rows, columns, connected components
52 integer nvrows, nvcols, vrtcmp
53c
54c integer output arrays
55c rowperm: row permutation,
56c cotn: column permutation, old to new
57 integer colperm(n), rowperm(n), rcmstr(n+1), ccmstr(n+1)
58 matsng = 0
59 msglvl = 0
60 output = 6
61c
62c More test input
63 ia(1) = 0
64 ia(2) = 1
65 ia(3) = 2
66 ia(4) = 3
67c
68 ja(1) = 1
69 ja(2) = 2
70 ja(3) = 0
71c
72c
73c Convert from C indexing to Fortran
74c if( nnz != ia(n+1) )then
75c stop I can not remember Fortran syntax.
76c endif
77 do 100 i=1,n+1
78 ia(i) = ia(i) + 1
79 100 continue
80 do 101 i=1,nnz
81 ja(i) = ja(i) + 1
82 101 continue
83 call mattrans(n,n,ja,ia,jat,iat)
84c
85c
86 print*,'Input (row, column)'
87 do 200 i=1,n
88 do 201 j= ia(i),ia(i+1)-1
89 print*,' ',i,ja(j)
90 201 continue
91 200 continue
92c
93c
94 call genbtf( n, n,
95 $ iat , jat, ia, ja, w ,
96 $ rowperm , colperm , nhrows,
97 $ nhcols, hrzcmp, nsrows, sqcmpn, nvrows,
98 $ nvcols, vrtcmp, rcmstr, ccmstr, msglvl, output )
99c
100c
101 if( nhrows .gt. 0) then
102 print*, "horizontal block:", nhrows, nhcols, hrzcmp
103 endif
104 print*, sqcmpn, " blocks"
105 if( nvrows .gt. 0) then
106 print*, "vertical block:", nvrows, nvcols, vrtcmp
107 endif
108 matsng = nhrows + nvrows + hrzcmp + vrtcmp
109 if( matsng .eq. 0) then
110 do 401 i=1, sqcmpn
111 print*,' ', rcmstr(hrzcmp+i), ccmstr(hrzcmp+i)
112 401 continue
113 else
114 print*, 'Structurally singular matrix'
115 endif
116c
117 print*,'Permuted (row, column)'
118 do 300 i=1,n
119 k = rowperm(i)
120 do 301 j= ia(k),ia(k+1)-1
121 print*,' ', i,ja(colperm(j))
122 301 continue
123 300 continue
124c
125c rowperm --, colperm --
126c rcmstr --, ccmstr --
127c
128c
129c
130c
131 end
subroutine genbtf(nrows, ncols, colstr, rowidx, rowstr, colidx, w, rnto, cnto, nhrows, nhcols, hrzcmp, nsrows, sqcmpn, nvrows, nvcols, vrtcmp, rcmstr, ccmstr, msglvl, output)
Definition: genbtf.f:6
subroutine mattrans(m, n, ja, ia, jao, iao)
Definition: mattrans.f:2