subroutine dgbco(abd,lda,n,ml,mu,ipvt,rcond,z) integer lda,n,ml,mu,ipvt(1) double precision abd(lda,1),z(1) double precision rcond c c dgbco factors a double precision band matrix by gaussian c elimination and estimates the condition of the matrix. c c if rcond is not needed, dgbfa is slightly faster. c to solve a*x = b , follow dgbco by dgbsl. c to compute inverse(a)*c , follow dgbco by dgbsl. c to compute determinant(a) , follow dgbco by dgbdi. c c on entry c c abd double precision(lda, n) c contains the matrix in band storage. the columns c of the matrix are stored in the columns of abd and c the diagonals of the matrix are stored in rows c ml+1 through 2*ml+mu+1 of abd . c see the comments below for details. c c lda integer c the leading dimension of the array abd . c lda must be .ge. 2*ml + mu + 1 . c c n integer c the order of the original matrix. c c ml integer c number of diagonals below the main diagonal. c 0 .le. ml .lt. n . c c mu integer c number of diagonals above the main diagonal. c 0 .le. mu .lt. n . c more efficient if ml .le. mu . c c on return c c abd an upper triangular matrix in band storage and c the multipliers which were used to obtain it. c the factorization can be written a = l*u where c l is a product of permutation and unit lower c triangular matrices and u is upper triangular. c c ipvt integer(n) c an integer vector of pivot indices. c c rcond double precision c an estimate of the reciprocal condition of a . c for the system a*x = b , relative perturbations c in a and b of size epsilon may cause c relative perturbations in x of size epsilon/rcond . c if rcond is so small that the logical expression c 1.0 + rcond .eq. 1.0 c is true, then a may be singular to working c precision. in particular, rcond is zero if c exact singularity is detected or the estimate c underflows. c c z double precision(n) c a work vector whose contents are usually unimportant. c if a is close to a singular matrix, then z is c an approximate null vector in the sense that c norm(a*z) = rcond*norm(a)*norm(z) . c c band storage c c if a is a band matrix, the following program segment c will set up the input. c c ml = (band width below the diagonal) c mu = (band width above the diagonal) c m = ml + mu + 1 c do 20 j = 1, n c i1 = max0(1, j-mu) c i2 = min0(n, j+ml) c do 10 i = i1, i2 c k = i - j + m c abd(k,j) = a(i,j) c 10 continue c 20 continue c c this uses rows ml+1 through 2*ml+mu+1 of abd . c in addition, the first ml rows in abd are used for c elements generated during the triangularization. c the total number of rows needed in abd is 2*ml+mu+1 . c the ml+mu by ml+mu upper left triangle and the c ml by ml lower right triangle are not referenced. c c example.. if the original matrix is c c 11 12 13 0 0 0 c 21 22 23 24 0 0 c 0 32 33 34 35 0 c 0 0 43 44 45 46 c 0 0 0 54 55 56 c 0 0 0 0 65 66 c c then n = 6, ml = 1, mu = 2, lda .ge. 5 and abd should contain c c * * * + + + , * = not used c * * 13 24 35 46 , + = used for pivoting c * 12 23 34 45 56 c 11 22 33 44 55 66 c 21 32 43 54 65 * c c linpack. this version dated 08/14/78 . c cleve moler, university of new mexico, argonne national lab. c c subroutines and functions c c linpack dgbfa c blas daxpy,ddot,dscal,dasum c fortran dabs,dmax1,max0,min0,dsign c c internal variables c double precision ddot,ek,t,wk,wkm double precision anorm,s,dasum,sm,ynorm integer is,info,j,ju,k,kb,kp1,l,la,lm,lz,m,mm c c c compute 1-norm of a c anorm = 0.0d0 l = ml + 1 is = l + mu do 10 j = 1, n anorm = dmax1(anorm,dasum(l,abd(is,j),1)) if (is .gt. ml + 1) is = is - 1 if (j .le. mu) l = l + 1 if (j .ge. n - ml) l = l - 1 10 continue c c factor c call dgbfa(abd,lda,n,ml,mu,ipvt,info) c c rcond = 1/(norm(a)*(estimate of norm(inverse(a)))) . c estimate = norm(z)/norm(y) where a*z = y and trans(a)*y = e . c trans(a) is the transpose of a . the components of e are c chosen to cause maximum local growth in the elements of w where c trans(u)*w = e . the vectors are frequently rescaled to avoid c overflow. c c solve trans(u)*w = e c ek = 1.0d0 do 20 j = 1, n z(j) = 0.0d0 20 continue m = ml + mu + 1 ju = 0 do 100 k = 1, n if (z(k) .ne. 0.0d0) ek = dsign(ek,-z(k)) if (dabs(ek-z(k)) .le. dabs(abd(m,k))) go to 30 s = dabs(abd(m,k))/dabs(ek-z(k)) call dscal(n,s,z,1) ek = s*ek 30 continue wk = ek - z(k) wkm = -ek - z(k) s = dabs(wk) sm = dabs(wkm) if (abd(m,k) .eq. 0.0d0) go to 40 wk = wk/abd(m,k) wkm = wkm/abd(m,k) go to 50 40 continue wk = 1.0d0 wkm = 1.0d0 50 continue kp1 = k + 1 ju = min0(max0(ju,mu+ipvt(k)),n) mm = m if (kp1 .gt. ju) go to 90 do 60 j = kp1, ju mm = mm - 1 sm = sm + dabs(z(j)+wkm*abd(mm,j)) z(j) = z(j) + wk*abd(mm,j) s = s + dabs(z(j)) 60 continue if (s .ge. sm) go to 80 t = wkm - wk wk = wkm mm = m do 70 j = kp1, ju mm = mm - 1 z(j) = z(j) + t*abd(mm,j) 70 continue 80 continue 90 continue z(k) = wk 100 continue s = 1.0d0/dasum(n,z,1) call dscal(n,s,z,1) c c solve trans(l)*y = w c do 120 kb = 1, n k = n + 1 - kb lm = min0(ml,n-k) if (k .lt. n) z(k) = z(k) + ddot(lm,abd(m+1,k),1,z(k+1),1) if (dabs(z(k)) .le. 1.0d0) go to 110 s = 1.0d0/dabs(z(k)) call dscal(n,s,z,1) 110 continue l = ipvt(k) t = z(l) z(l) = z(k) z(k) = t 120 continue s = 1.0d0/dasum(n,z,1) call dscal(n,s,z,1) c ynorm = 1.0d0 c c solve l*v = y c do 140 k = 1, n l = ipvt(k) t = z(l) z(l) = z(k) z(k) = t lm = min0(ml,n-k) if (k .lt. n) call daxpy(lm,t,abd(m+1,k),1,z(k+1),1) if (dabs(z(k)) .le. 1.0d0) go to 130 s = 1.0d0/dabs(z(k)) call dscal(n,s,z,1) ynorm = s*ynorm 130 continue 140 continue s = 1.0d0/dasum(n,z,1) call dscal(n,s,z,1) ynorm = s*ynorm c c solve u*z = w c do 160 kb = 1, n k = n + 1 - kb if (dabs(z(k)) .le. dabs(abd(m,k))) go to 150 s = dabs(abd(m,k))/dabs(z(k)) call dscal(n,s,z,1) ynorm = s*ynorm 150 continue if (abd(m,k) .ne. 0.0d0) z(k) = z(k)/abd(m,k) if (abd(m,k) .eq. 0.0d0) z(k) = 1.0d0 lm = min0(k,m) - 1 la = m - lm lz = k - lm t = -z(k) call daxpy(lm,t,abd(la,k),1,z(lz),1) 160 continue c make znorm = 1.0 s = 1.0d0/dasum(n,z,1) call dscal(n,s,z,1) ynorm = s*ynorm c if (anorm .ne. 0.0d0) rcond = ynorm/anorm if (anorm .eq. 0.0d0) rcond = 0.0d0 return end