ctrtri.c
Go to the documentation of this file.
00001 /* ctrtri.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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020 static integer c_n1 = -1;
00021 static integer c__2 = 2;
00022 
00023 /* Subroutine */ int ctrtri_(char *uplo, char *diag, integer *n, complex *a, 
00024         integer *lda, integer *info)
00025 {
00026     /* System generated locals */
00027     address a__1[2];
00028     integer a_dim1, a_offset, i__1, i__2, i__3[2], i__4, i__5;
00029     complex q__1;
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 ctrmm_(char *, char *, char *, char *, 
00039             integer *, integer *, complex *, complex *, integer *, complex *, 
00040             integer *), ctrsm_(char *, char *, 
00041              char *, char *, integer *, integer *, complex *, complex *, 
00042             integer *, complex *, integer *);
00043     logical upper;
00044     extern /* Subroutine */ int ctrti2_(char *, char *, integer *, complex *, 
00045             integer *, integer *), 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 /*  CTRTRI computes the inverse of a complex 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) COMPLEX 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_("CTRTRI", &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             i__2 = *info + *info * a_dim1;
00156             if (a[i__2].r == 0.f && a[i__2].i == 0.f) {
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__3[0] = 1, a__1[0] = uplo;
00168     i__3[1] = 1, a__1[1] = diag;
00169     s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00170     nb = ilaenv_(&c__1, "CTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
00171     if (nb <= 1 || nb >= *n) {
00172 
00173 /*        Use unblocked code */
00174 
00175         ctrti2_(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__2 = nb;
00186             for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
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                 ctrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
00195                         c_b1, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
00196                 i__4 = j - 1;
00197                 q__1.r = -1.f, q__1.i = -0.f;
00198                 ctrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
00199                         q__1, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1], 
00200                         lda);
00201 
00202 /*              Compute inverse of current diagonal block */
00203 
00204                 ctrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
00205 /* L20: */
00206             }
00207         } else {
00208 
00209 /*           Compute inverse of lower triangular matrix */
00210 
00211             nn = (*n - 1) / nb * nb + 1;
00212             i__2 = -nb;
00213             for (j = nn; i__2 < 0 ? j >= 1 : j <= 1; j += i__2) {
00214 /* Computing MIN */
00215                 i__1 = nb, i__4 = *n - j + 1;
00216                 jb = min(i__1,i__4);
00217                 if (j + jb <= *n) {
00218 
00219 /*                 Compute rows j+jb:n of current block column */
00220 
00221                     i__1 = *n - j - jb + 1;
00222                     ctrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb, 
00223                             &c_b1, &a[j + jb + (j + jb) * a_dim1], lda, &a[j 
00224                             + jb + j * a_dim1], lda);
00225                     i__1 = *n - j - jb + 1;
00226                     q__1.r = -1.f, q__1.i = -0.f;
00227                     ctrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb, 
00228                              &q__1, &a[j + j * a_dim1], lda, &a[j + jb + j * 
00229                             a_dim1], lda);
00230                 }
00231 
00232 /*              Compute inverse of current diagonal block */
00233 
00234                 ctrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
00235 /* L30: */
00236             }
00237         }
00238     }
00239 
00240     return 0;
00241 
00242 /*     End of CTRTRI */
00243 
00244 } /* ctrtri_ */


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