strtri.c
Go to the documentation of this file.
00001 /* strtri.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 real c_b18 = 1.f;
00022 static real c_b22 = -1.f;
00023 
00024 /* Subroutine */ int strtri_(char *uplo, char *diag, integer *n, real *a, 
00025         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     logical upper;
00039     extern /* Subroutine */ int strmm_(char *, char *, char *, char *, 
00040             integer *, integer *, real *, real *, integer *, real *, integer *
00041 ), strsm_(char *, char *, char *, 
00042             char *, integer *, integer *, real *, real *, integer *, real *, 
00043             integer *), strti2_(char *, char *
00044 , integer *, real *, integer *, integer *), 
00045             xerbla_(char *, integer *);
00046     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00047             integer *, integer *);
00048     logical nounit;
00049 
00050 
00051 /*  -- LAPACK routine (version 3.2) -- */
00052 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00053 /*     November 2006 */
00054 
00055 /*     .. Scalar Arguments .. */
00056 /*     .. */
00057 /*     .. Array Arguments .. */
00058 /*     .. */
00059 
00060 /*  Purpose */
00061 /*  ======= */
00062 
00063 /*  STRTRI computes the inverse of a real upper or lower triangular */
00064 /*  matrix A. */
00065 
00066 /*  This is the Level 3 BLAS version of the algorithm. */
00067 
00068 /*  Arguments */
00069 /*  ========= */
00070 
00071 /*  UPLO    (input) CHARACTER*1 */
00072 /*          = 'U':  A is upper triangular; */
00073 /*          = 'L':  A is lower triangular. */
00074 
00075 /*  DIAG    (input) CHARACTER*1 */
00076 /*          = 'N':  A is non-unit triangular; */
00077 /*          = 'U':  A is unit triangular. */
00078 
00079 /*  N       (input) INTEGER */
00080 /*          The order of the matrix A.  N >= 0. */
00081 
00082 /*  A       (input/output) REAL array, dimension (LDA,N) */
00083 /*          On entry, the triangular matrix A.  If UPLO = 'U', the */
00084 /*          leading N-by-N upper triangular part of the array A contains */
00085 /*          the upper triangular matrix, and the strictly lower */
00086 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00087 /*          leading N-by-N lower triangular part of the array A contains */
00088 /*          the lower triangular matrix, and the strictly upper */
00089 /*          triangular part of A is not referenced.  If DIAG = 'U', the */
00090 /*          diagonal elements of A are also not referenced and are */
00091 /*          assumed to be 1. */
00092 /*          On exit, the (triangular) inverse of the original matrix, in */
00093 /*          the same storage format. */
00094 
00095 /*  LDA     (input) INTEGER */
00096 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00097 
00098 /*  INFO    (output) INTEGER */
00099 /*          = 0: successful exit */
00100 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00101 /*          > 0: if INFO = i, A(i,i) is exactly zero.  The triangular */
00102 /*               matrix is singular and its inverse can not be computed. */
00103 
00104 /*  ===================================================================== */
00105 
00106 /*     .. Parameters .. */
00107 /*     .. */
00108 /*     .. Local Scalars .. */
00109 /*     .. */
00110 /*     .. External Functions .. */
00111 /*     .. */
00112 /*     .. External Subroutines .. */
00113 /*     .. */
00114 /*     .. Intrinsic Functions .. */
00115 /*     .. */
00116 /*     .. Executable Statements .. */
00117 
00118 /*     Test the input parameters. */
00119 
00120     /* Parameter adjustments */
00121     a_dim1 = *lda;
00122     a_offset = 1 + a_dim1;
00123     a -= a_offset;
00124 
00125     /* Function Body */
00126     *info = 0;
00127     upper = lsame_(uplo, "U");
00128     nounit = lsame_(diag, "N");
00129     if (! upper && ! lsame_(uplo, "L")) {
00130         *info = -1;
00131     } else if (! nounit && ! lsame_(diag, "U")) {
00132         *info = -2;
00133     } else if (*n < 0) {
00134         *info = -3;
00135     } else if (*lda < max(1,*n)) {
00136         *info = -5;
00137     }
00138     if (*info != 0) {
00139         i__1 = -(*info);
00140         xerbla_("STRTRI", &i__1);
00141         return 0;
00142     }
00143 
00144 /*     Quick return if possible */
00145 
00146     if (*n == 0) {
00147         return 0;
00148     }
00149 
00150 /*     Check for singularity if non-unit. */
00151 
00152     if (nounit) {
00153         i__1 = *n;
00154         for (*info = 1; *info <= i__1; ++(*info)) {
00155             if (a[*info + *info * a_dim1] == 0.f) {
00156                 return 0;
00157             }
00158 /* L10: */
00159         }
00160         *info = 0;
00161     }
00162 
00163 /*     Determine the block size for this environment. */
00164 
00165 /* Writing concatenation */
00166     i__2[0] = 1, a__1[0] = uplo;
00167     i__2[1] = 1, a__1[1] = diag;
00168     s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
00169     nb = ilaenv_(&c__1, "STRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
00170     if (nb <= 1 || nb >= *n) {
00171 
00172 /*        Use unblocked code */
00173 
00174         strti2_(uplo, diag, n, &a[a_offset], lda, info);
00175     } else {
00176 
00177 /*        Use blocked code */
00178 
00179         if (upper) {
00180 
00181 /*           Compute inverse of upper triangular matrix */
00182 
00183             i__1 = *n;
00184             i__3 = nb;
00185             for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
00186 /* Computing MIN */
00187                 i__4 = nb, i__5 = *n - j + 1;
00188                 jb = min(i__4,i__5);
00189 
00190 /*              Compute rows 1:j-1 of current block column */
00191 
00192                 i__4 = j - 1;
00193                 strmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
00194                         c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
00195                 i__4 = j - 1;
00196                 strsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
00197                         c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1], 
00198                         lda);
00199 
00200 /*              Compute inverse of current diagonal block */
00201 
00202                 strti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
00203 /* L20: */
00204             }
00205         } else {
00206 
00207 /*           Compute inverse of lower triangular matrix */
00208 
00209             nn = (*n - 1) / nb * nb + 1;
00210             i__3 = -nb;
00211             for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
00212 /* Computing MIN */
00213                 i__1 = nb, i__4 = *n - j + 1;
00214                 jb = min(i__1,i__4);
00215                 if (j + jb <= *n) {
00216 
00217 /*                 Compute rows j+jb:n of current block column */
00218 
00219                     i__1 = *n - j - jb + 1;
00220                     strmm_("Left", "Lower", "No transpose", diag, &i__1, &jb, 
00221                             &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j 
00222                             + jb + j * a_dim1], lda);
00223                     i__1 = *n - j - jb + 1;
00224                     strsm_("Right", "Lower", "No transpose", diag, &i__1, &jb, 
00225                              &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j * 
00226                             a_dim1], lda);
00227                 }
00228 
00229 /*              Compute inverse of current diagonal block */
00230 
00231                 strti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
00232 /* L30: */
00233             }
00234         }
00235     }
00236 
00237     return 0;
00238 
00239 /*     End of STRTRI */
00240 
00241 } /* strtri_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:15