gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
banfac.f
Go to the documentation of this file.
1  subroutine banfac ( w, nroww, nrow, nbandl, nbandu, iflag )
2 
3 c*********************************************************************72
4 c
5 cc BANFAC factors a banded matrix without pivoting.
6 c
7 c from * a practical guide to splines * by c. de boor
8 c returns in w the lu-factorization (without pivoting) of the banded
9 c matrix a of order nrow with (nbandl + 1 + nbandu) bands or diag-
10 c onals in the work array w .
11 c
12 c****** i n p u t ******
13 c w.....work array of size (nroww,nrow) containing the interesting
14 c part of a banded matrix a , with the diagonals or bands of a
15 c stored in the rows of w , while columns of a correspond to
16 c columns of w . this is the storage mode used in linpack and
17 c results in efficient innermost loops.
18 c explicitly, a has nbandl bands below the diagonal
19 c + 1 (main) diagonal
20 c + nbandu bands above the diagonal
21 c and thus, with middle = nbandu + 1,
22 c a(i+j,j) is in w(i+middle,j) for i=-nbandu,...,nbandl
23 c j=1,...,nrow .
24 c for example, the interesting entries of a (1,2)-banded matrix
25 c of order 9 would appear in the first 1+1+2 = 4 rows of w
26 c as follows.
27 c
28 c
29 c
30 c
31 c
32 c all other entries of w not identified in this way with an en-
33 c try of a are never referenced .
34 c nroww.....row dimension of the work array w .
35 c must be .ge. nbandl + 1 + nbandu .
36 c nbandl.....number of bands of a below the main diagonal
37 c nbandu.....number of bands of a above the main diagonal .
38 c
39 c****** o u t p u t ******
40 c iflag.....integer indicating success( = 1) or failure ( = 2) .
41 c if iflag = 1, then
42 c w.....contains the lu-factorization of a into a unit lower triangu-
43 c lar matrix l and an upper triangular matrix u (both banded)
44 c and stored in customary fashion over the corresponding entries
45 c of a . this makes it possible to solve any particular linear
46 c system a*x = b for x by a
47 c call banslv ( w, nroww, nrow, nbandl, nbandu, b )
48 c with the solution x contained in b on return .
49 c if iflag = 2, then
50 c one of nrow-1, nbandl,nbandu failed to be nonnegative, or else
51 c one of the potential pivots was found to be zero indicating
52 c that a does not have an lu-factorization. this implies that
53 c a is singular in case it is totally positive .
54 c
55 c****** m e t h o d ******
56 c gauss elimination w i t h o u t pivoting is used. the routine is
57 c intended for use with matrices a which do not require row inter-
58 c changes during factorization, especially for the t o t a l l y
59 c p o s i t i v e matrices which occur in spline calculations.
60 c the routine should not be used for an arbitrary banded matrix.
61 c
62  implicit none
63 
64  integer iflag,nbandl,nbandu,nrow,nroww, i,ipk,j,jmax,k,kmax
65  & ,middle,midmk,nrowm1
66  double precision w(nroww,nrow), factor,pivot
67 c
68  iflag = 1
69  middle = nbandu + 1
70 c w(middle,.) contains the main diagonal of a .
71  nrowm1 = nrow - 1
72  if (nrowm1) 999,900,1
73  1 if (nbandl .gt. 0) go to 10
74 c a is upper triangular. check that diagonal is nonzero .
75  do 5 i=1,nrowm1
76  if (w(middle,i) .eq. 0.0d+00) go to 999
77  5 continue
78  go to 900
79  10 if (nbandu .gt. 0) go to 20
80 c a is lower triangular. check that diagonal is nonzero and
81 c divide each column by its diagonal .
82  do 15 i=1,nrowm1
83  pivot = w(middle,i)
84  if(pivot .eq. 0.0d+00) go to 999
85  jmax = min0(nbandl, nrow - i)
86  do 15 j=1,jmax
87  15 w(middle+j,i) = w(middle+j,i)/pivot
88  return
89 c
90 c a is not just a triangular matrix. construct lu factorization
91  20 do 50 i=1,nrowm1
92 c w(middle,i) is pivot for i-th step .
93  pivot = w(middle,i)
94  if (pivot .eq. 0.0d+00) go to 999
95 c jmax is the number of (nonzero) entries in column i
96 c below the diagonal .
97  jmax = min0(nbandl,nrow - i)
98 c divide each entry in column i below diagonal by pivot .
99  do 32 j=1,jmax
100  32 w(middle+j,i) = w(middle+j,i)/pivot
101 c kmax is the number of (nonzero) entries in row i to
102 c the right of the diagonal .
103  kmax = min0(nbandu,nrow - i)
104 c subtract a(i,i+k)*(i-th column) from (i+k)-th column
105 c (below row i ) .
106  do 40 k=1,kmax
107  ipk = i + k
108  midmk = middle - k
109  factor = w(midmk,ipk)
110  do 40 j=1,jmax
111  40 w(midmk+j,ipk) = w(midmk+j,ipk) - w(middle+j,i)*factor
112  50 continue
113 c check the last diagonal entry .
114  900 if (w(middle,nrow) .ne. 0.0d+00) return
115  999 iflag = 2
116  return
117  end
subroutine banfac(w, nroww, nrow, nbandl, nbandu, iflag)
Definition: banfac.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/banfac.f Source File
GTK+ IOStream  Beta