c@427: /* dtrti2.f -- translated by f2c (version 20061008). c@427: You must link the resulting object file with libf2c: c@427: on Microsoft Windows system, link with libf2c.lib; c@427: on Linux or Unix systems, link with .../path/to/libf2c.a -lm c@427: or, if you install libf2c.a in a standard place, with -lf2c -lm c@427: -- in that order, at the end of the command line, as in c@427: cc *.o -lf2c -lm c@427: Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., c@427: c@427: http://www.netlib.org/f2c/libf2c.zip c@427: */ c@427: c@427: #include "f2c.h" c@427: #include "blaswrap.h" c@427: c@427: /* Table of constant values */ c@427: c@427: static integer c__1 = 1; c@427: c@427: /* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal * c@427: a, integer *lda, integer *info) c@427: { c@427: /* System generated locals */ c@427: integer a_dim1, a_offset, i__1, i__2; c@427: c@427: /* Local variables */ c@427: integer j; c@427: doublereal ajj; c@427: extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, c@427: integer *); c@427: extern logical lsame_(char *, char *); c@427: logical upper; c@427: extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, c@427: doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *); c@427: logical nounit; c@427: c@427: c@427: /* -- LAPACK routine (version 3.2) -- */ c@427: /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ c@427: /* November 2006 */ c@427: c@427: /* .. Scalar Arguments .. */ c@427: /* .. */ c@427: /* .. Array Arguments .. */ c@427: /* .. */ c@427: c@427: /* Purpose */ c@427: /* ======= */ c@427: c@427: /* DTRTI2 computes the inverse of a real upper or lower triangular */ c@427: /* matrix. */ c@427: c@427: /* This is the Level 2 BLAS version of the algorithm. */ c@427: c@427: /* Arguments */ c@427: /* ========= */ c@427: c@427: /* UPLO (input) CHARACTER*1 */ c@427: /* Specifies whether the matrix A is upper or lower triangular. */ c@427: /* = 'U': Upper triangular */ c@427: /* = 'L': Lower triangular */ c@427: c@427: /* DIAG (input) CHARACTER*1 */ c@427: /* Specifies whether or not the matrix A is unit triangular. */ c@427: /* = 'N': Non-unit triangular */ c@427: /* = 'U': Unit triangular */ c@427: c@427: /* N (input) INTEGER */ c@427: /* The order of the matrix A. N >= 0. */ c@427: c@427: /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ c@427: /* On entry, the triangular matrix A. If UPLO = 'U', the */ c@427: /* leading n by n upper triangular part of the array A contains */ c@427: /* the upper triangular matrix, and the strictly lower */ c@427: /* triangular part of A is not referenced. If UPLO = 'L', the */ c@427: /* leading n by n lower triangular part of the array A contains */ c@427: /* the lower triangular matrix, and the strictly upper */ c@427: /* triangular part of A is not referenced. If DIAG = 'U', the */ c@427: /* diagonal elements of A are also not referenced and are */ c@427: /* assumed to be 1. */ c@427: c@427: /* On exit, the (triangular) inverse of the original matrix, in */ c@427: /* the same storage format. */ c@427: c@427: /* LDA (input) INTEGER */ c@427: /* The leading dimension of the array A. LDA >= max(1,N). */ c@427: c@427: /* INFO (output) INTEGER */ c@427: /* = 0: successful exit */ c@427: /* < 0: if INFO = -k, the k-th argument had an illegal value */ c@427: c@427: /* ===================================================================== */ c@427: c@427: /* .. Parameters .. */ c@427: /* .. */ c@427: /* .. Local Scalars .. */ c@427: /* .. */ c@427: /* .. External Functions .. */ c@427: /* .. */ c@427: /* .. External Subroutines .. */ c@427: /* .. */ c@427: /* .. Intrinsic Functions .. */ c@427: /* .. */ c@427: /* .. Executable Statements .. */ c@427: c@427: /* Test the input parameters. */ c@427: c@427: /* Parameter adjustments */ c@427: a_dim1 = *lda; c@427: a_offset = 1 + a_dim1; c@427: a -= a_offset; c@427: c@427: /* Function Body */ c@427: *info = 0; c@427: upper = lsame_(uplo, "U"); c@427: nounit = lsame_(diag, "N"); c@427: if (! upper && ! lsame_(uplo, "L")) { c@427: *info = -1; c@427: } else if (! nounit && ! lsame_(diag, "U")) { c@427: *info = -2; c@427: } else if (*n < 0) { c@427: *info = -3; c@427: } else if (*lda < max(1,*n)) { c@427: *info = -5; c@427: } c@427: if (*info != 0) { c@427: i__1 = -(*info); c@427: xerbla_("DTRTI2", &i__1); c@427: return 0; c@427: } c@427: c@427: if (upper) { c@427: c@427: /* Compute inverse of upper triangular matrix. */ c@427: c@427: i__1 = *n; c@427: for (j = 1; j <= i__1; ++j) { c@427: if (nounit) { c@427: a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; c@427: ajj = -a[j + j * a_dim1]; c@427: } else { c@427: ajj = -1.; c@427: } c@427: c@427: /* Compute elements 1:j-1 of j-th column. */ c@427: c@427: i__2 = j - 1; c@427: dtrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, & c@427: a[j * a_dim1 + 1], &c__1); c@427: i__2 = j - 1; c@427: dscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1); c@427: /* L10: */ c@427: } c@427: } else { c@427: c@427: /* Compute inverse of lower triangular matrix. */ c@427: c@427: for (j = *n; j >= 1; --j) { c@427: if (nounit) { c@427: a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; c@427: ajj = -a[j + j * a_dim1]; c@427: } else { c@427: ajj = -1.; c@427: } c@427: if (j < *n) { c@427: c@427: /* Compute elements j+1:n of j-th column. */ c@427: c@427: i__1 = *n - j; c@427: dtrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j + c@427: 1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1); c@427: i__1 = *n - j; c@427: dscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1); c@427: } c@427: /* L20: */ c@427: } c@427: } c@427: c@427: return 0; c@427: c@427: /* End of DTRTI2 */ c@427: c@427: } /* dtrti2_ */