|
EpetraExt Development
|
00001 c 00002 c 00003 c Purpose: Fortran driver of genbtf, generate block triangular 00004 c form. A structurally nonsingular matrix is permuted 00005 c 00006 c (A(rowperm(i), (colperm(j)), 1 <= i,j, <=n) 00007 c 00008 c to block upper triangular with sqcmpn blocks. 00009 c If matsng != 0, then the matrix is structurally singular 00010 c (for example has a zero row), and has a complex 00011 c block triangular form. 00012 c 00013 00014 00015 c 00016 c rcmstr ccmstr 00017 c 00018 c If matsng != 0, then the matrix is structurally singular 00019 c (for example has a zero row), and has a complex 00020 c block triangular form. 00021 c 00022 c 00023 c test input 00024 parameter (n=3, nnz= 3) 00025 c and C-style indexing. 00026 c 00027 c 00028 c 00029 c 00030 c 00031 c Start with an n by n matrix in sparse row format 00032 c ja, ia: column indices and row pointers 00033 c 00034 c integer input scalars 00035 c integer msglvl = 0, output = 6 00036 integer msglvl, output 00037 c 00038 c integer input arrays 00039 integer ia(n+1) , ja(nnz), iat(n+1), jat(nnz) 00040 c 00041 c local work space 00042 integer w(10*n), i, j 00043 c 00044 c integer output scalars 00045 c 00046 integer matsng 00047 c horizontal block: rows, columns, connected components 00048 integer nhrows, nhcols, hrzcmp 00049 c square block: rows=columns, connected components 00050 integer nsrows, sqcmpn 00051 c vertical block: rows, columns, connected components 00052 integer nvrows, nvcols, vrtcmp 00053 c 00054 c integer output arrays 00055 c rowperm: row permutation, 00056 c cotn: column permutation, old to new 00057 integer colperm(n), rowperm(n), rcmstr(n+1), ccmstr(n+1) 00058 matsng = 0 00059 msglvl = 0 00060 output = 6 00061 c 00062 c More test input 00063 ia(1) = 0 00064 ia(2) = 1 00065 ia(3) = 2 00066 ia(4) = 3 00067 c 00068 ja(1) = 1 00069 ja(2) = 2 00070 ja(3) = 0 00071 c 00072 c 00073 c Convert from C indexing to Fortran 00074 c if( nnz != ia(n+1) )then 00075 c stop I can not remember Fortran syntax. 00076 c endif 00077 do 100 i=1,n+1 00078 ia(i) = ia(i) + 1 00079 100 continue 00080 do 101 i=1,nnz 00081 ja(i) = ja(i) + 1 00082 101 continue 00083 call mattrans(n,n,ja,ia,jat,iat) 00084 c 00085 c 00086 print*,'Input (row, column)' 00087 do 200 i=1,n 00088 do 201 j= ia(i),ia(i+1)-1 00089 print*,' ',i,ja(j) 00090 201 continue 00091 200 continue 00092 c 00093 c 00094 call genbtf( n, n, 00095 $ iat , jat, ia, ja, w , 00096 $ rowperm , colperm , nhrows, 00097 $ nhcols, hrzcmp, nsrows, sqcmpn, nvrows, 00098 $ nvcols, vrtcmp, rcmstr, ccmstr, msglvl, output ) 00099 c 00100 c 00101 if( nhrows .gt. 0) then 00102 print*, "horizontal block:", nhrows, nhcols, hrzcmp 00103 endif 00104 print*, sqcmpn, " blocks" 00105 if( nvrows .gt. 0) then 00106 print*, "vertical block:", nvrows, nvcols, vrtcmp 00107 endif 00108 matsng = nhrows + nvrows + hrzcmp + vrtcmp 00109 if( matsng .eq. 0) then 00110 do 401 i=1, sqcmpn 00111 print*,' ', rcmstr(hrzcmp+i), ccmstr(hrzcmp+i) 00112 401 continue 00113 else 00114 print*, 'Structurally singular matrix' 00115 endif 00116 c 00117 print*,'Permuted (row, column)' 00118 do 300 i=1,n 00119 k = rowperm(i) 00120 do 301 j= ia(k),ia(k+1)-1 00121 print*,' ', i,ja(colperm(j)) 00122 301 continue 00123 300 continue 00124 c 00125 c rowperm --, colperm -- 00126 c rcmstr --, ccmstr -- 00127 c 00128 c 00129 c 00130 c 00131 end
1.7.4