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


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