zpptri.c
Go to the documentation of this file.
00001 /* zpptri.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 doublereal c_b8 = 1.;
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int zpptri_(char *uplo, integer *n, doublecomplex *ap, 
00022         integer *info)
00023 {
00024     /* System generated locals */
00025     integer i__1, i__2, i__3;
00026     doublereal d__1;
00027     doublecomplex z__1;
00028 
00029     /* Local variables */
00030     integer j, jc, jj;
00031     doublereal ajj;
00032     integer jjn;
00033     extern /* Subroutine */ int zhpr_(char *, integer *, doublereal *, 
00034             doublecomplex *, integer *, doublecomplex *);
00035     extern logical lsame_(char *, char *);
00036     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00037             doublecomplex *, integer *, doublecomplex *, integer *);
00038     logical upper;
00039     extern /* Subroutine */ int ztpmv_(char *, char *, char *, integer *, 
00040             doublecomplex *, doublecomplex *, integer *), xerbla_(char *, integer *), zdscal_(integer *, 
00041             doublereal *, doublecomplex *, integer *), ztptri_(char *, char *, 
00042              integer *, doublecomplex *, integer *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZPPTRI computes the inverse of a complex Hermitian positive definite */
00058 /*  matrix A using the Cholesky factorization A = U**H*U or A = L*L**H */
00059 /*  computed by ZPPTRF. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  UPLO    (input) CHARACTER*1 */
00065 /*          = 'U':  Upper triangular factor is stored in AP; */
00066 /*          = 'L':  Lower triangular factor is stored in AP. */
00067 
00068 /*  N       (input) INTEGER */
00069 /*          The order of the matrix A.  N >= 0. */
00070 
00071 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00072 /*          On entry, the triangular factor U or L from the Cholesky */
00073 /*          factorization A = U**H*U or A = L*L**H, packed columnwise as */
00074 /*          a linear array.  The j-th column of U or L is stored in the */
00075 /*          array AP as follows: */
00076 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
00077 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
00078 
00079 /*          On exit, the upper or lower triangle of the (Hermitian) */
00080 /*          inverse of A, overwriting the input factor U or L. */
00081 
00082 /*  INFO    (output) INTEGER */
00083 /*          = 0:  successful exit */
00084 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00085 /*          > 0:  if INFO = i, the (i,i) element of the factor U or L is */
00086 /*                zero, and the inverse could not be computed. */
00087 
00088 /*  ===================================================================== */
00089 
00090 /*     .. Parameters .. */
00091 /*     .. */
00092 /*     .. Local Scalars .. */
00093 /*     .. */
00094 /*     .. External Functions .. */
00095 /*     .. */
00096 /*     .. External Subroutines .. */
00097 /*     .. */
00098 /*     .. Intrinsic Functions .. */
00099 /*     .. */
00100 /*     .. Executable Statements .. */
00101 
00102 /*     Test the input parameters. */
00103 
00104     /* Parameter adjustments */
00105     --ap;
00106 
00107     /* Function Body */
00108     *info = 0;
00109     upper = lsame_(uplo, "U");
00110     if (! upper && ! lsame_(uplo, "L")) {
00111         *info = -1;
00112     } else if (*n < 0) {
00113         *info = -2;
00114     }
00115     if (*info != 0) {
00116         i__1 = -(*info);
00117         xerbla_("ZPPTRI", &i__1);
00118         return 0;
00119     }
00120 
00121 /*     Quick return if possible */
00122 
00123     if (*n == 0) {
00124         return 0;
00125     }
00126 
00127 /*     Invert the triangular Cholesky factor U or L. */
00128 
00129     ztptri_(uplo, "Non-unit", n, &ap[1], info);
00130     if (*info > 0) {
00131         return 0;
00132     }
00133     if (upper) {
00134 
00135 /*        Compute the product inv(U) * inv(U)'. */
00136 
00137         jj = 0;
00138         i__1 = *n;
00139         for (j = 1; j <= i__1; ++j) {
00140             jc = jj + 1;
00141             jj += j;
00142             if (j > 1) {
00143                 i__2 = j - 1;
00144                 zhpr_("Upper", &i__2, &c_b8, &ap[jc], &c__1, &ap[1]);
00145             }
00146             i__2 = jj;
00147             ajj = ap[i__2].r;
00148             zdscal_(&j, &ajj, &ap[jc], &c__1);
00149 /* L10: */
00150         }
00151 
00152     } else {
00153 
00154 /*        Compute the product inv(L)' * inv(L). */
00155 
00156         jj = 1;
00157         i__1 = *n;
00158         for (j = 1; j <= i__1; ++j) {
00159             jjn = jj + *n - j + 1;
00160             i__2 = jj;
00161             i__3 = *n - j + 1;
00162             zdotc_(&z__1, &i__3, &ap[jj], &c__1, &ap[jj], &c__1);
00163             d__1 = z__1.r;
00164             ap[i__2].r = d__1, ap[i__2].i = 0.;
00165             if (j < *n) {
00166                 i__2 = *n - j;
00167                 ztpmv_("Lower", "Conjugate transpose", "Non-unit", &i__2, &ap[
00168                         jjn], &ap[jj + 1], &c__1);
00169             }
00170             jj = jjn;
00171 /* L20: */
00172         }
00173     }
00174 
00175     return 0;
00176 
00177 /*     End of ZPPTRI */
00178 
00179 } /* zpptri_ */


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