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