c@427: /* dtrtri.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: static integer c_n1 = -1; c@427: static integer c__2 = 2; c@427: static doublereal c_b18 = 1.; c@427: static doublereal c_b22 = -1.; c@427: c@427: /* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal * c@427: a, integer *lda, integer *info) c@427: { c@427: /* System generated locals */ c@427: address a__1[2]; c@427: integer a_dim1, a_offset, i__1, i__2[2], i__3, i__4, i__5; c@427: char ch__1[2]; c@427: c@427: /* Builtin functions */ c@427: /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen); c@427: c@427: /* Local variables */ c@427: integer j, jb, nb, nn; c@427: extern logical lsame_(char *, char *); c@427: extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *, c@427: integer *, integer *, doublereal *, doublereal *, integer *, c@427: doublereal *, integer *), dtrsm_( c@427: char *, char *, char *, char *, integer *, integer *, doublereal * c@427: , doublereal *, integer *, doublereal *, integer *); c@427: logical upper; c@427: extern /* Subroutine */ int dtrti2_(char *, char *, integer *, doublereal c@427: *, integer *, integer *), xerbla_(char *, integer c@427: *); c@427: extern integer ilaenv_(integer *, char *, char *, integer *, integer *, c@427: integer *, 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: /* DTRTRI computes the inverse of a real upper or lower triangular */ c@427: /* matrix A. */ c@427: c@427: /* This is the Level 3 BLAS version of the algorithm. */ c@427: c@427: /* Arguments */ c@427: /* ========= */ c@427: c@427: /* UPLO (input) CHARACTER*1 */ c@427: /* = 'U': A is upper triangular; */ c@427: /* = 'L': A is lower triangular. */ c@427: c@427: /* DIAG (input) CHARACTER*1 */ c@427: /* = 'N': A is non-unit triangular; */ c@427: /* = 'U': A is 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: /* 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 = -i, the i-th argument had an illegal value */ c@427: /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */ c@427: /* matrix is singular and its inverse can not be computed. */ 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_("DTRTRI", &i__1); c@427: return 0; c@427: } c@427: c@427: /* Quick return if possible */ c@427: c@427: if (*n == 0) { c@427: return 0; c@427: } c@427: c@427: /* Check for singularity if non-unit. */ c@427: c@427: if (nounit) { c@427: i__1 = *n; c@427: for (*info = 1; *info <= i__1; ++(*info)) { c@427: if (a[*info + *info * a_dim1] == 0.) { c@427: return 0; c@427: } c@427: /* L10: */ c@427: } c@427: *info = 0; c@427: } c@427: c@427: /* Determine the block size for this environment. */ c@427: c@427: /* Writing concatenation */ c@427: i__2[0] = 1, a__1[0] = uplo; c@427: i__2[1] = 1, a__1[1] = diag; c@427: s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2); c@427: nb = ilaenv_(&c__1, "DTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1); c@427: if (nb <= 1 || nb >= *n) { c@427: c@427: /* Use unblocked code */ c@427: c@427: dtrti2_(uplo, diag, n, &a[a_offset], lda, info); c@427: } else { c@427: c@427: /* Use blocked code */ 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: i__3 = nb; c@427: for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) { c@427: /* Computing MIN */ c@427: i__4 = nb, i__5 = *n - j + 1; c@427: jb = min(i__4,i__5); c@427: c@427: /* Compute rows 1:j-1 of current block column */ c@427: c@427: i__4 = j - 1; c@427: dtrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, & c@427: c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda); c@427: i__4 = j - 1; c@427: dtrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, & c@427: c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1], c@427: lda); c@427: c@427: /* Compute inverse of current diagonal block */ c@427: c@427: dtrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info); c@427: /* L20: */ c@427: } c@427: } else { c@427: c@427: /* Compute inverse of lower triangular matrix */ c@427: c@427: nn = (*n - 1) / nb * nb + 1; c@427: i__3 = -nb; c@427: for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) { c@427: /* Computing MIN */ c@427: i__1 = nb, i__4 = *n - j + 1; c@427: jb = min(i__1,i__4); c@427: if (j + jb <= *n) { c@427: c@427: /* Compute rows j+jb:n of current block column */ c@427: c@427: i__1 = *n - j - jb + 1; c@427: dtrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb, c@427: &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j c@427: + jb + j * a_dim1], lda); c@427: i__1 = *n - j - jb + 1; c@427: dtrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb, c@427: &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j * c@427: a_dim1], lda); c@427: } c@427: c@427: /* Compute inverse of current diagonal block */ c@427: c@427: dtrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info); c@427: /* L30: */ c@427: } c@427: } c@427: } c@427: c@427: return 0; c@427: c@427: /* End of DTRTRI */ c@427: c@427: } /* dtrtri_ */