gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
bchfac.f
Go to the documentation of this file.
1  subroutine bchfac ( w, nbands, nrow, diag )
2 
3 c*********************************************************************72
4 c
5 cc BCHFAC constructs a Cholesky factorization of a matrix.
6 c
7 c from * a practical guide to splines * by c. de boor
8 constructs cholesky factorization
9 c c = l * d * l-transpose
10 c with l unit lower triangular and d diagonal, for given matrix c of
11 c order n r o w , in case c is (symmetric) positive semidefinite
12 c and b a n d e d , having n b a n d s diagonals at and below the
13 c main diagonal.
14 c
15 c****** i n p u t ******
16 c nrow.....is the order of the matrix c .
17 c nbands.....indicates its bandwidth, i.e.,
18 c c(i,j) = 0 for i-j .ge. nbands .
19 c w.....workarray of size (nbands,nrow) containing the nbands diago-
20 c nals in its rows, with the main diagonal in row 1 . precisely,
21 c w(i,j) contains c(i+j-1,j), i=1,...,nbands, j=1,...,nrow.
22 c for example, the interesting entries of a seven diagonal sym-
23 c metric matrix c of order 9 would be stored in w as
24 c
25 c
26 c
27 c
28 c
29 c
30 c all other entries of w not identified in this way with an en-
31 c try of c are never referenced .
32 c diag.....is a work array of length nrow .
33 c
34 c****** o u t p u t ******
35 c w.....contains the cholesky factorization c = l*d*l-transp, with
36 c w(1,i) containing 1/d(i,i)
37 c and w(i,j) containing l(i-1+j,j), i=2,...,nbands.
38 c
39 c****** m e t h o d ******
40 c gauss elimination, adapted to the symmetry and bandedness of c , is
41 c used .
42 c near zero pivots are handled in a special way. the diagonal ele-
43 c ment c(n,n) = w(1,n) is saved initially in diag(n), all n. at the n-
44 c th elimination step, the current pivot element, viz. w(1,n), is com-
45 c pared with its original value, diag(n). if, as the result of prior
46 c elimination steps, this element has been reduced by about a word
47 c length, (i.e., if w(1,n)+diag(n) .le. diag(n)), then the pivot is de-
48 c clared to be zero, and the entire n-th row is declared to be linearly
49 c dependent on the preceding rows. this has the effect of producing
50 c x(n) = 0 when solving c*x = b for x, regardless of b. justific-
51 c ation for this is as follows. in contemplated applications of this
52 c program, the given equations are the normal equations for some least-
53 c squares approximation problem, diag(n) = c(n,n) gives the norm-square
54 c of the n-th basis function, and, at this point, w(1,n) contains the
55 c norm-square of the error in the least-squares approximation to the n-
56 c th basis function by linear combinations of the first n-1 . having
57 c w(1,n)+diag(n) .le. diag(n) signifies that the n-th function is lin-
58 c early dependent to machine accuracy on the first n-1 functions, there
59 c fore can safely be left out from the basis of approximating functions
60 c the solution of a linear system
61 c c*x = b
62 c is effected by the succession of the following t w o calls:
63 c call bchfac ( w, nbands, nrow, diag ) , to get factorization
64 c call bchslv ( w, nbands, nrow, b ) , to solve for x.
65 c
66  implicit none
67 
68  integer nbands,nrow, i,imax,j,jmax,n
69  double precision w(nbands,nrow),diag(nrow), ratio
70  if (nrow .gt. 1) go to 9
71  if (w(1,1) .gt. 0.0d+00) w(1,1) = 1.0d+00/w(1,1)
72  return
73 c store diagonal of c in diag.
74  9 do 10 n=1,nrow
75  10 diag(n) = w(1,n)
76 c factorization .
77  do 20 n=1,nrow
78  if (w(1,n)+diag(n) .gt. diag(n)) go to 15
79  do 14 j=1,nbands
80  14 w(j,n) = 0.0d+00
81  go to 20
82  15 w(1,n) = 1./w(1,n)
83  imax = min0(nbands-1,nrow - n)
84  if (imax .lt. 1) go to 20
85  jmax = imax
86  do 18 i=1,imax
87  ratio = w(i+1,n)*w(1,n)
88  do 17 j=1,jmax
89  17 w(j,n+i) = w(j,n+i) - w(j+i,n)*ratio
90  jmax = jmax - 1
91  18 w(i+1,n) = ratio
92  20 continue
93  return
94  end
subroutine bchfac(w, nbands, nrow, diag)
Definition: bchfac.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/bchfac.f Source File
GTK+ IOStream  Beta