/* dgedi.f -- translated by f2c (version of 25 March 1992 12:58:56). You must link the resulting object file with the libraries: -lF77 -lI77 -lm -lc (in that order) */ #include /* Table of constant values */ static integer c__1 = 1; /* Subroutine */ int dgedi_(a, lda, n, ipvt, det, work, job) doublereal *a; integer *lda, *n, *ipvt; doublereal *det, *work; integer *job; { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2; /* Local variables */ static integer i, j, k, l; static doublereal t; extern /* Subroutine */ int dscal_(), dswap_(), daxpy_(); static integer kb, kp1, nm1; /* dgedi computes the determinant and inverse of a matrix */ /* using the factors computed by dgeco or dgefa. */ /* on entry */ /* a double precision(lda, n) */ /* the output from dgeco or dgefa. */ /* lda integer */ /* the leading dimension of the array a . */ /* n integer */ /* the order of the matrix a . */ /* ipvt integer(n) */ /* the pivot vector from dgeco or dgefa. */ /* work double precision(n) */ /* work vector. contents destroyed. */ /* job integer */ /* = 11 both determinant and inverse. */ /* = 01 inverse only. */ /* = 10 determinant only. */ /* on return */ /* a inverse of original matrix if requested. */ /* otherwise unchanged. */ /* det double precision(2) */ /* determinant of original matrix if requested. */ /* otherwise not referenced. */ /* determinant = det(1) * 10.0**det(2) */ /* with 1.0 .le. dabs(det(1)) .lt. 10.0 */ /* or det(1) .eq. 0.0 . */ /* error condition */ /* a division by zero will occur if the input factor contains */ /* a zero on the diagonal and the inverse is requested. */ /* it will not occur if the subroutines are called correctly */ /* and if dgeco has set rcond .gt. 0.0 or dgefa has set */ /* info .eq. 0 . */ /* linpack. this version dated 08/14/78 . */ /* cleve moler, university of new mexico, argonne national lab. */ /* subroutines and functions */ /* blas daxpy,dscal,dswap */ /* fortran dabs,mod */ /* internal variables */ /* compute inverse(u) */ /* Parameter adjustments */ --work; --det; --ipvt; a_dim1 = *lda; a_offset = a_dim1 + 1; a -= a_offset; /* Function Body */ if (*job % 10 == 0) { goto L150; } i__1 = *n; for (k = 1; k <= i__1; ++k) { a[k + k * a_dim1] = 1. / a[k + k * a_dim1]; t = -a[k + k * a_dim1]; i__2 = k - 1; dscal_(&i__2, &t, &a[k * a_dim1 + 1], &c__1); kp1 = k + 1; if (*n < kp1) { goto L90; } i__2 = *n; for (j = kp1; j <= i__2; ++j) { t = a[k + j * a_dim1]; a[k + j * a_dim1] = 0.; daxpy_(&k, &t, &a[k * a_dim1 + 1], &c__1, &a[j * a_dim1 + 1], & c__1); /* L80: */ } L90: /* L100: */ ; } /* form inverse(u)*inverse(l) */ nm1 = *n - 1; if (nm1 < 1) { goto L140; } i__1 = nm1; for (kb = 1; kb <= i__1; ++kb) { k = *n - kb; kp1 = k + 1; i__2 = *n; for (i = kp1; i <= i__2; ++i) { work[i] = a[i + k * a_dim1]; a[i + k * a_dim1] = 0.; /* L110: */ } i__2 = *n; for (j = kp1; j <= i__2; ++j) { t = work[j]; daxpy_(n, &t, &a[j * a_dim1 + 1], &c__1, &a[k * a_dim1 + 1], & c__1); /* L120: */ } l = ipvt[k]; if (l != k) { dswap_(n, &a[k * a_dim1 + 1], &c__1, &a[l * a_dim1 + 1], &c__1); } /* L130: */ } L140: L150: return 0; } /* dgedi_ */