gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
factrb.f
Go to the documentation of this file.
1  subroutine factrb ( w, ipivot, d, nrow, ncol, last, iflag )
2 
3 c*********************************************************************72
4 c
5 cc FACTRB constructs a partial PLU factorization.
6 c
7 c adapted from p.132 of 'element.numer.analysis' by conte-de boor
8 c
9 c constructs a partial plu factorization, corresponding to steps 1,...,
10 c l a s t in gauss elimination, for the matrix w of order
11 c ( n r o w , n c o l ), using pivoting of scaled rows.
12 c
13 c parameters
14 c w contains the (nrow,ncol) matrix to be partially factored
15 c on input, and the partial factorization on output.
16 c ipivot an integer array of length nrow containing a record of the
17 c pivoting strategy used; row ipivot(i) is used during the
18 c i-th elimination step, i=1,...,last.
19 c d a work array of length nrow used to store row sizes
20 c temporarily.
21 c nrow number of rows of w.
22 c ncol number of columns of w.
23 c last number of elimination steps to be carried out.
24 c iflag on output, equals iflag on input times (-1)**(number of
25 c row interchanges during the factorization process), in
26 c case no zero pivot was encountered.
27 c otherwise, iflag = 0 on output.
28 c
29  implicit none
30 
31  integer nrow
32 
33  integer ipivot(nrow),ncol,last,iflag, i,ipivi,ipivk,j,k,kp1
34  double precision w(nrow,ncol),d(nrow),
35  & awikdi,colmax,ratio,rowmax
36 c initialize ipivot, d
37  do 10 i=1,nrow
38  ipivot(i) = i
39  rowmax = 0.0d+00
40  do 9 j=1,ncol
41  9 rowmax = dmax1(rowmax, dabs(w(i,j)))
42  if (rowmax .eq. 0.0d+00) go to 999
43  10 d(i) = rowmax
44 c gauss elimination with pivoting of scaled rows, loop over k=1,.,last
45  k = 1
46 c as pivot row for k-th step, pick among the rows not yet used,
47 c i.e., from rows ipivot(k),...,ipivot(nrow), the one whose k-th
48 c entry (compared to the row size) is largest. then, if this row
49 c does not turn out to be row ipivot(k), redefine ipivot(k) ap-
50 c propriately and record this interchange by changing the sign
51 c of i f l a g .
52  11 ipivk = ipivot(k)
53  if (k .eq. nrow) go to 21
54  j = k
55  kp1 = k+1
56  colmax = dabs(w(ipivk,k))/d(ipivk)
57 c find the (relatively) largest pivot
58  do 15 i=kp1,nrow
59  ipivi = ipivot(i)
60  awikdi = dabs(w(ipivi,k))/d(ipivi)
61  if (awikdi .le. colmax) go to 15
62  colmax = awikdi
63  j = i
64  15 continue
65  if (j .eq. k) go to 16
66  ipivk = ipivot(j)
67  ipivot(j) = ipivot(k)
68  ipivot(k) = ipivk
69  iflag = -iflag
70  16 continue
71 c if pivot element is too small in absolute value, declare
72 c matrix to be noninvertible and quit.
73  if (dabs(w(ipivk,k))+d(ipivk) .le. d(ipivk))
74  & go to 999
75 c otherwise, subtract the appropriate multiple of the pivot
76 c row from remaining rows, i.e., the rows ipivot(k+1),...,
77 c ipivot(nrow), to make k-th entry zero. save the multiplier in
78 c its place.
79  do 20 i=kp1,nrow
80  ipivi = ipivot(i)
81  w(ipivi,k) = w(ipivi,k)/w(ipivk,k)
82  ratio = -w(ipivi,k)
83  do 20 j=kp1,ncol
84  20 w(ipivi,j) = ratio*w(ipivk,j) + w(ipivi,j)
85  k = kp1
86 c check for having reached the next block.
87  if (k .le. last) go to 11
88  return
89 c if last .eq. nrow , check now that pivot element in last row
90 c is nonzero.
91  21 if( dabs(w(ipivk,nrow))+d(ipivk) .gt. d(ipivk) )
92  * return
93 c singularity flag set
94  999 iflag = 0
95  return
96  end
subroutine factrb(w, ipivot, d, nrow, ncol, last, iflag)
Definition: factrb.f:2
gtkIOStream: /tmp/gtkiostream/src/deBoor/factrb.f Source File
GTK+ IOStream  Beta