ztrti2.c
Go to the documentation of this file.
00001 /* ztrti2.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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int ztrti2_(char *uplo, char *diag, integer *n, 
00022         doublecomplex *a, integer *lda, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2;
00026     doublecomplex z__1;
00027 
00028     /* Builtin functions */
00029     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00030 
00031     /* Local variables */
00032     integer j;
00033     doublecomplex ajj;
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00036             doublecomplex *, integer *);
00037     logical upper;
00038     extern /* Subroutine */ int ztrmv_(char *, char *, char *, integer *, 
00039             doublecomplex *, integer *, doublecomplex *, integer *), xerbla_(char *, integer *);
00040     logical nounit;
00041 
00042 
00043 /*  -- LAPACK routine (version 3.2) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  ZTRTI2 computes the inverse of a complex upper or lower triangular */
00056 /*  matrix. */
00057 
00058 /*  This is the Level 2 BLAS version of the algorithm. */
00059 
00060 /*  Arguments */
00061 /*  ========= */
00062 
00063 /*  UPLO    (input) CHARACTER*1 */
00064 /*          Specifies whether the matrix A is upper or lower triangular. */
00065 /*          = 'U':  Upper triangular */
00066 /*          = 'L':  Lower triangular */
00067 
00068 /*  DIAG    (input) CHARACTER*1 */
00069 /*          Specifies whether or not the matrix A is unit triangular. */
00070 /*          = 'N':  Non-unit triangular */
00071 /*          = 'U':  Unit triangular */
00072 
00073 /*  N       (input) INTEGER */
00074 /*          The order of the matrix A.  N >= 0. */
00075 
00076 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00077 /*          On entry, the triangular matrix A.  If UPLO = 'U', the */
00078 /*          leading n by n upper triangular part of the array A contains */
00079 /*          the upper triangular matrix, and the strictly lower */
00080 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00081 /*          leading n by n lower triangular part of the array A contains */
00082 /*          the lower triangular matrix, and the strictly upper */
00083 /*          triangular part of A is not referenced.  If DIAG = 'U', the */
00084 /*          diagonal elements of A are also not referenced and are */
00085 /*          assumed to be 1. */
00086 
00087 /*          On exit, the (triangular) inverse of the original matrix, in */
00088 /*          the same storage format. */
00089 
00090 /*  LDA     (input) INTEGER */
00091 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00092 
00093 /*  INFO    (output) INTEGER */
00094 /*          = 0: successful exit */
00095 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00096 
00097 /*  ===================================================================== */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. External Functions .. */
00104 /*     .. */
00105 /*     .. External Subroutines .. */
00106 /*     .. */
00107 /*     .. Intrinsic Functions .. */
00108 /*     .. */
00109 /*     .. Executable Statements .. */
00110 
00111 /*     Test the input parameters. */
00112 
00113     /* Parameter adjustments */
00114     a_dim1 = *lda;
00115     a_offset = 1 + a_dim1;
00116     a -= a_offset;
00117 
00118     /* Function Body */
00119     *info = 0;
00120     upper = lsame_(uplo, "U");
00121     nounit = lsame_(diag, "N");
00122     if (! upper && ! lsame_(uplo, "L")) {
00123         *info = -1;
00124     } else if (! nounit && ! lsame_(diag, "U")) {
00125         *info = -2;
00126     } else if (*n < 0) {
00127         *info = -3;
00128     } else if (*lda < max(1,*n)) {
00129         *info = -5;
00130     }
00131     if (*info != 0) {
00132         i__1 = -(*info);
00133         xerbla_("ZTRTI2", &i__1);
00134         return 0;
00135     }
00136 
00137     if (upper) {
00138 
00139 /*        Compute inverse of upper triangular matrix. */
00140 
00141         i__1 = *n;
00142         for (j = 1; j <= i__1; ++j) {
00143             if (nounit) {
00144                 i__2 = j + j * a_dim1;
00145                 z_div(&z__1, &c_b1, &a[j + j * a_dim1]);
00146                 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00147                 i__2 = j + j * a_dim1;
00148                 z__1.r = -a[i__2].r, z__1.i = -a[i__2].i;
00149                 ajj.r = z__1.r, ajj.i = z__1.i;
00150             } else {
00151                 z__1.r = -1., z__1.i = -0.;
00152                 ajj.r = z__1.r, ajj.i = z__1.i;
00153             }
00154 
00155 /*           Compute elements 1:j-1 of j-th column. */
00156 
00157             i__2 = j - 1;
00158             ztrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, &
00159                     a[j * a_dim1 + 1], &c__1);
00160             i__2 = j - 1;
00161             zscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1);
00162 /* L10: */
00163         }
00164     } else {
00165 
00166 /*        Compute inverse of lower triangular matrix. */
00167 
00168         for (j = *n; j >= 1; --j) {
00169             if (nounit) {
00170                 i__1 = j + j * a_dim1;
00171                 z_div(&z__1, &c_b1, &a[j + j * a_dim1]);
00172                 a[i__1].r = z__1.r, a[i__1].i = z__1.i;
00173                 i__1 = j + j * a_dim1;
00174                 z__1.r = -a[i__1].r, z__1.i = -a[i__1].i;
00175                 ajj.r = z__1.r, ajj.i = z__1.i;
00176             } else {
00177                 z__1.r = -1., z__1.i = -0.;
00178                 ajj.r = z__1.r, ajj.i = z__1.i;
00179             }
00180             if (j < *n) {
00181 
00182 /*              Compute elements j+1:n of j-th column. */
00183 
00184                 i__1 = *n - j;
00185                 ztrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j + 
00186                         1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1);
00187                 i__1 = *n - j;
00188                 zscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1);
00189             }
00190 /* L20: */
00191         }
00192     }
00193 
00194     return 0;
00195 
00196 /*     End of ZTRTI2 */
00197 
00198 } /* ztrti2_ */


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