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


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