dtptrs.c
Go to the documentation of this file.
00001 /* dtptrs.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 dtptrs_(char *uplo, char *trans, char *diag, integer *n, 
00021         integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, integer *
00022         info)
00023 {
00024     /* System generated locals */
00025     integer b_dim1, b_offset, i__1;
00026 
00027     /* Local variables */
00028     integer j, jc;
00029     extern logical lsame_(char *, char *);
00030     logical upper;
00031     extern /* Subroutine */ int dtpsv_(char *, char *, char *, integer *, 
00032             doublereal *, doublereal *, integer *), 
00033             xerbla_(char *, integer *);
00034     logical nounit;
00035 
00036 
00037 /*  -- LAPACK routine (version 3.2) -- */
00038 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00039 /*     November 2006 */
00040 
00041 /*     .. Scalar Arguments .. */
00042 /*     .. */
00043 /*     .. Array Arguments .. */
00044 /*     .. */
00045 
00046 /*  Purpose */
00047 /*  ======= */
00048 
00049 /*  DTPTRS solves a triangular system of the form */
00050 
00051 /*     A * X = B  or  A**T * X = B, */
00052 
00053 /*  where A is a triangular matrix of order N stored in packed format, */
00054 /*  and B is an N-by-NRHS matrix.  A check is made to verify that A is */
00055 /*  nonsingular. */
00056 
00057 /*  Arguments */
00058 /*  ========= */
00059 
00060 /*  UPLO    (input) CHARACTER*1 */
00061 /*          = 'U':  A is upper triangular; */
00062 /*          = 'L':  A is lower triangular. */
00063 
00064 /*  TRANS   (input) CHARACTER*1 */
00065 /*          Specifies the form of the system of equations: */
00066 /*          = 'N':  A * X = B  (No transpose) */
00067 /*          = 'T':  A**T * X = B  (Transpose) */
00068 /*          = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00069 
00070 /*  DIAG    (input) CHARACTER*1 */
00071 /*          = 'N':  A is non-unit triangular; */
00072 /*          = 'U':  A is unit triangular. */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The order of the matrix A.  N >= 0. */
00076 
00077 /*  NRHS    (input) INTEGER */
00078 /*          The number of right hand sides, i.e., the number of columns */
00079 /*          of the matrix B.  NRHS >= 0. */
00080 
00081 /*  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00082 /*          The upper or lower triangular matrix A, packed columnwise in */
00083 /*          a linear array.  The j-th column of A is stored in the array */
00084 /*          AP as follows: */
00085 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00086 /*          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
00087 
00088 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00089 /*          On entry, the right hand side matrix B. */
00090 /*          On exit, if INFO = 0, the solution matrix X. */
00091 
00092 /*  LDB     (input) INTEGER */
00093 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00094 
00095 /*  INFO    (output) INTEGER */
00096 /*          = 0:  successful exit */
00097 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00098 /*          > 0:  if INFO = i, the i-th diagonal element of A is zero, */
00099 /*                indicating that the matrix is singular and the */
00100 /*                solutions X have not been computed. */
00101 
00102 /*  ===================================================================== */
00103 
00104 /*     .. Parameters .. */
00105 /*     .. */
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. External Functions .. */
00109 /*     .. */
00110 /*     .. External Subroutines .. */
00111 /*     .. */
00112 /*     .. Intrinsic Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Test the input parameters. */
00117 
00118     /* Parameter adjustments */
00119     --ap;
00120     b_dim1 = *ldb;
00121     b_offset = 1 + b_dim1;
00122     b -= b_offset;
00123 
00124     /* Function Body */
00125     *info = 0;
00126     upper = lsame_(uplo, "U");
00127     nounit = lsame_(diag, "N");
00128     if (! upper && ! lsame_(uplo, "L")) {
00129         *info = -1;
00130     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00131             "T") && ! lsame_(trans, "C")) {
00132         *info = -2;
00133     } else if (! nounit && ! lsame_(diag, "U")) {
00134         *info = -3;
00135     } else if (*n < 0) {
00136         *info = -4;
00137     } else if (*nrhs < 0) {
00138         *info = -5;
00139     } else if (*ldb < max(1,*n)) {
00140         *info = -8;
00141     }
00142     if (*info != 0) {
00143         i__1 = -(*info);
00144         xerbla_("DTPTRS", &i__1);
00145         return 0;
00146     }
00147 
00148 /*     Quick return if possible */
00149 
00150     if (*n == 0) {
00151         return 0;
00152     }
00153 
00154 /*     Check for singularity. */
00155 
00156     if (nounit) {
00157         if (upper) {
00158             jc = 1;
00159             i__1 = *n;
00160             for (*info = 1; *info <= i__1; ++(*info)) {
00161                 if (ap[jc + *info - 1] == 0.) {
00162                     return 0;
00163                 }
00164                 jc += *info;
00165 /* L10: */
00166             }
00167         } else {
00168             jc = 1;
00169             i__1 = *n;
00170             for (*info = 1; *info <= i__1; ++(*info)) {
00171                 if (ap[jc] == 0.) {
00172                     return 0;
00173                 }
00174                 jc = jc + *n - *info + 1;
00175 /* L20: */
00176             }
00177         }
00178     }
00179     *info = 0;
00180 
00181 /*     Solve A * x = b  or  A' * x = b. */
00182 
00183     i__1 = *nrhs;
00184     for (j = 1; j <= i__1; ++j) {
00185         dtpsv_(uplo, trans, diag, n, &ap[1], &b[j * b_dim1 + 1], &c__1);
00186 /* L30: */
00187     }
00188 
00189     return 0;
00190 
00191 /*     End of DTPTRS */
00192 
00193 } /* dtptrs_ */


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