ztptri.c
Go to the documentation of this file.
00001 /* ztptri.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 ztptri_(char *uplo, char *diag, integer *n, 
00022         doublecomplex *ap, integer *info)
00023 {
00024     /* System generated locals */
00025     integer 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, jc, jj;
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 ztpmv_(char *, char *, char *, integer *, 
00039             doublecomplex *, doublecomplex *, integer *), xerbla_(char *, integer *);
00040     integer jclast;
00041     logical nounit;
00042 
00043 
00044 /*  -- LAPACK routine (version 3.2) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  ZTPTRI computes the inverse of a complex upper or lower triangular */
00057 /*  matrix A stored in packed format. */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*  UPLO    (input) CHARACTER*1 */
00063 /*          = 'U':  A is upper triangular; */
00064 /*          = 'L':  A is lower triangular. */
00065 
00066 /*  DIAG    (input) CHARACTER*1 */
00067 /*          = 'N':  A is non-unit triangular; */
00068 /*          = 'U':  A is unit triangular. */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The order of the matrix A.  N >= 0. */
00072 
00073 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00074 /*          On entry, the upper or lower triangular matrix A, stored */
00075 /*          columnwise in a linear array.  The j-th column of A is stored */
00076 /*          in the array AP as follows: */
00077 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00078 /*          if UPLO = 'L', AP(i + (j-1)*((2*n-j)/2) = A(i,j) for j<=i<=n. */
00079 /*          See below for further details. */
00080 /*          On exit, the (triangular) inverse of the original matrix, in */
00081 /*          the same packed storage format. */
00082 
00083 /*  INFO    (output) INTEGER */
00084 /*          = 0:  successful exit */
00085 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00086 /*          > 0:  if INFO = i, A(i,i) is exactly zero.  The triangular */
00087 /*                matrix is singular and its inverse can not be computed. */
00088 
00089 /*  Further Details */
00090 /*  =============== */
00091 
00092 /*  A triangular matrix A can be transferred to packed storage using one */
00093 /*  of the following program segments: */
00094 
00095 /*  UPLO = 'U':                      UPLO = 'L': */
00096 
00097 /*        JC = 1                           JC = 1 */
00098 /*        DO 2 J = 1, N                    DO 2 J = 1, N */
00099 /*           DO 1 I = 1, J                    DO 1 I = J, N */
00100 /*              AP(JC+I-1) = A(I,J)              AP(JC+I-J) = A(I,J) */
00101 /*      1    CONTINUE                    1    CONTINUE */
00102 /*           JC = JC + J                      JC = JC + N - J + 1 */
00103 /*      2 CONTINUE                       2 CONTINUE */
00104 
00105 /*  ===================================================================== */
00106 
00107 /*     .. Parameters .. */
00108 /*     .. */
00109 /*     .. Local Scalars .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. External Subroutines .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Test the input parameters. */
00118 
00119     /* Parameter adjustments */
00120     --ap;
00121 
00122     /* Function Body */
00123     *info = 0;
00124     upper = lsame_(uplo, "U");
00125     nounit = lsame_(diag, "N");
00126     if (! upper && ! lsame_(uplo, "L")) {
00127         *info = -1;
00128     } else if (! nounit && ! lsame_(diag, "U")) {
00129         *info = -2;
00130     } else if (*n < 0) {
00131         *info = -3;
00132     }
00133     if (*info != 0) {
00134         i__1 = -(*info);
00135         xerbla_("ZTPTRI", &i__1);
00136         return 0;
00137     }
00138 
00139 /*     Check for singularity if non-unit. */
00140 
00141     if (nounit) {
00142         if (upper) {
00143             jj = 0;
00144             i__1 = *n;
00145             for (*info = 1; *info <= i__1; ++(*info)) {
00146                 jj += *info;
00147                 i__2 = jj;
00148                 if (ap[i__2].r == 0. && ap[i__2].i == 0.) {
00149                     return 0;
00150                 }
00151 /* L10: */
00152             }
00153         } else {
00154             jj = 1;
00155             i__1 = *n;
00156             for (*info = 1; *info <= i__1; ++(*info)) {
00157                 i__2 = jj;
00158                 if (ap[i__2].r == 0. && ap[i__2].i == 0.) {
00159                     return 0;
00160                 }
00161                 jj = jj + *n - *info + 1;
00162 /* L20: */
00163             }
00164         }
00165         *info = 0;
00166     }
00167 
00168     if (upper) {
00169 
00170 /*        Compute inverse of upper triangular matrix. */
00171 
00172         jc = 1;
00173         i__1 = *n;
00174         for (j = 1; j <= i__1; ++j) {
00175             if (nounit) {
00176                 i__2 = jc + j - 1;
00177                 z_div(&z__1, &c_b1, &ap[jc + j - 1]);
00178                 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00179                 i__2 = jc + j - 1;
00180                 z__1.r = -ap[i__2].r, z__1.i = -ap[i__2].i;
00181                 ajj.r = z__1.r, ajj.i = z__1.i;
00182             } else {
00183                 z__1.r = -1., z__1.i = -0.;
00184                 ajj.r = z__1.r, ajj.i = z__1.i;
00185             }
00186 
00187 /*           Compute elements 1:j-1 of j-th column. */
00188 
00189             i__2 = j - 1;
00190             ztpmv_("Upper", "No transpose", diag, &i__2, &ap[1], &ap[jc], &
00191                     c__1);
00192             i__2 = j - 1;
00193             zscal_(&i__2, &ajj, &ap[jc], &c__1);
00194             jc += j;
00195 /* L30: */
00196         }
00197 
00198     } else {
00199 
00200 /*        Compute inverse of lower triangular matrix. */
00201 
00202         jc = *n * (*n + 1) / 2;
00203         for (j = *n; j >= 1; --j) {
00204             if (nounit) {
00205                 i__1 = jc;
00206                 z_div(&z__1, &c_b1, &ap[jc]);
00207                 ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
00208                 i__1 = jc;
00209                 z__1.r = -ap[i__1].r, z__1.i = -ap[i__1].i;
00210                 ajj.r = z__1.r, ajj.i = z__1.i;
00211             } else {
00212                 z__1.r = -1., z__1.i = -0.;
00213                 ajj.r = z__1.r, ajj.i = z__1.i;
00214             }
00215             if (j < *n) {
00216 
00217 /*              Compute elements j+1:n of j-th column. */
00218 
00219                 i__1 = *n - j;
00220                 ztpmv_("Lower", "No transpose", diag, &i__1, &ap[jclast], &ap[
00221                         jc + 1], &c__1);
00222                 i__1 = *n - j;
00223                 zscal_(&i__1, &ajj, &ap[jc + 1], &c__1);
00224             }
00225             jclast = jc;
00226             jc = jc - *n + j - 2;
00227 /* L40: */
00228         }
00229     }
00230 
00231     return 0;
00232 
00233 /*     End of ZTPTRI */
00234 
00235 } /* ztptri_ */


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