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


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