dtrtri.c
Go to the documentation of this file.
00001 /* dtrtri.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static integer c_n1 = -1;
00020 static integer c__2 = 2;
00021 static doublereal c_b18 = 1.;
00022 static doublereal c_b22 = -1.;
00023 
00024 /* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *
00025         a, integer *lda, integer *info)
00026 {
00027     /* System generated locals */
00028     address a__1[2];
00029     integer a_dim1, a_offset, i__1, i__2[2], i__3, i__4, i__5;
00030     char ch__1[2];
00031 
00032     /* Builtin functions */
00033     /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
00034 
00035     /* Local variables */
00036     integer j, jb, nb, nn;
00037     extern logical lsame_(char *, char *);
00038     extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *, 
00039             integer *, integer *, doublereal *, doublereal *, integer *, 
00040             doublereal *, integer *), dtrsm_(
00041             char *, char *, char *, char *, integer *, integer *, doublereal *
00042 , doublereal *, integer *, doublereal *, integer *);
00043     logical upper;
00044     extern /* Subroutine */ int dtrti2_(char *, char *, integer *, doublereal 
00045             *, integer *, integer *), xerbla_(char *, integer 
00046             *);
00047     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00048             integer *, integer *);
00049     logical nounit;
00050 
00051 
00052 /*  -- LAPACK routine (version 3.2) -- */
00053 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00054 /*     November 2006 */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  DTRTRI computes the inverse of a real upper or lower triangular */
00065 /*  matrix A. */
00066 
00067 /*  This is the Level 3 BLAS version of the algorithm. */
00068 
00069 /*  Arguments */
00070 /*  ========= */
00071 
00072 /*  UPLO    (input) CHARACTER*1 */
00073 /*          = 'U':  A is upper triangular; */
00074 /*          = 'L':  A is lower triangular. */
00075 
00076 /*  DIAG    (input) CHARACTER*1 */
00077 /*          = 'N':  A is non-unit triangular; */
00078 /*          = 'U':  A is unit triangular. */
00079 
00080 /*  N       (input) INTEGER */
00081 /*          The order of the matrix A.  N >= 0. */
00082 
00083 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00084 /*          On entry, the triangular matrix A.  If UPLO = 'U', the */
00085 /*          leading N-by-N upper triangular part of the array A contains */
00086 /*          the upper triangular matrix, and the strictly lower */
00087 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00088 /*          leading N-by-N lower triangular part of the array A contains */
00089 /*          the lower triangular matrix, and the strictly upper */
00090 /*          triangular part of A is not referenced.  If DIAG = 'U', the */
00091 /*          diagonal elements of A are also not referenced and are */
00092 /*          assumed to be 1. */
00093 /*          On exit, the (triangular) inverse of the original matrix, in */
00094 /*          the same storage format. */
00095 
00096 /*  LDA     (input) INTEGER */
00097 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00098 
00099 /*  INFO    (output) INTEGER */
00100 /*          = 0: successful exit */
00101 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00102 /*          > 0: if INFO = i, A(i,i) is exactly zero.  The triangular */
00103 /*               matrix is singular and its inverse can not be computed. */
00104 
00105 /*  ===================================================================== */
00106 
00107 /*     .. Parameters .. */
00108 /*     .. */
00109 /*     .. Local Scalars .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. External Subroutines .. */
00114 /*     .. */
00115 /*     .. Intrinsic Functions .. */
00116 /*     .. */
00117 /*     .. Executable Statements .. */
00118 
00119 /*     Test the input parameters. */
00120 
00121     /* Parameter adjustments */
00122     a_dim1 = *lda;
00123     a_offset = 1 + a_dim1;
00124     a -= a_offset;
00125 
00126     /* Function Body */
00127     *info = 0;
00128     upper = lsame_(uplo, "U");
00129     nounit = lsame_(diag, "N");
00130     if (! upper && ! lsame_(uplo, "L")) {
00131         *info = -1;
00132     } else if (! nounit && ! lsame_(diag, "U")) {
00133         *info = -2;
00134     } else if (*n < 0) {
00135         *info = -3;
00136     } else if (*lda < max(1,*n)) {
00137         *info = -5;
00138     }
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("DTRTRI", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     if (*n == 0) {
00148         return 0;
00149     }
00150 
00151 /*     Check for singularity if non-unit. */
00152 
00153     if (nounit) {
00154         i__1 = *n;
00155         for (*info = 1; *info <= i__1; ++(*info)) {
00156             if (a[*info + *info * a_dim1] == 0.) {
00157                 return 0;
00158             }
00159 /* L10: */
00160         }
00161         *info = 0;
00162     }
00163 
00164 /*     Determine the block size for this environment. */
00165 
00166 /* Writing concatenation */
00167     i__2[0] = 1, a__1[0] = uplo;
00168     i__2[1] = 1, a__1[1] = diag;
00169     s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
00170     nb = ilaenv_(&c__1, "DTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
00171     if (nb <= 1 || nb >= *n) {
00172 
00173 /*        Use unblocked code */
00174 
00175         dtrti2_(uplo, diag, n, &a[a_offset], lda, info);
00176     } else {
00177 
00178 /*        Use blocked code */
00179 
00180         if (upper) {
00181 
00182 /*           Compute inverse of upper triangular matrix */
00183 
00184             i__1 = *n;
00185             i__3 = nb;
00186             for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
00187 /* Computing MIN */
00188                 i__4 = nb, i__5 = *n - j + 1;
00189                 jb = min(i__4,i__5);
00190 
00191 /*              Compute rows 1:j-1 of current block column */
00192 
00193                 i__4 = j - 1;
00194                 dtrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
00195                         c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
00196                 i__4 = j - 1;
00197                 dtrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
00198                         c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1], 
00199                         lda);
00200 
00201 /*              Compute inverse of current diagonal block */
00202 
00203                 dtrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
00204 /* L20: */
00205             }
00206         } else {
00207 
00208 /*           Compute inverse of lower triangular matrix */
00209 
00210             nn = (*n - 1) / nb * nb + 1;
00211             i__3 = -nb;
00212             for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
00213 /* Computing MIN */
00214                 i__1 = nb, i__4 = *n - j + 1;
00215                 jb = min(i__1,i__4);
00216                 if (j + jb <= *n) {
00217 
00218 /*                 Compute rows j+jb:n of current block column */
00219 
00220                     i__1 = *n - j - jb + 1;
00221                     dtrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb, 
00222                             &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j 
00223                             + jb + j * a_dim1], lda);
00224                     i__1 = *n - j - jb + 1;
00225                     dtrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb, 
00226                              &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j * 
00227                             a_dim1], lda);
00228                 }
00229 
00230 /*              Compute inverse of current diagonal block */
00231 
00232                 dtrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
00233 /* L30: */
00234             }
00235         }
00236     }
00237 
00238     return 0;
00239 
00240 /*     End of DTRTRI */
00241 
00242 } /* dtrtri_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:50