ctbtrs.c
Go to the documentation of this file.
00001 /* ctbtrs.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 ctbtrs_(char *uplo, char *trans, char *diag, integer *n, 
00021         integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b, 
00022         integer *ldb, integer *info)
00023 {
00024     /* System generated locals */
00025     integer ab_dim1, ab_offset, b_dim1, b_offset, i__1, i__2;
00026 
00027     /* Local variables */
00028     integer j;
00029     extern logical lsame_(char *, char *);
00030     extern /* Subroutine */ int ctbsv_(char *, char *, char *, integer *, 
00031             integer *, complex *, integer *, complex *, integer *);
00032     logical upper;
00033     extern /* Subroutine */ int 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 /*  CTBTRS solves a triangular system of the form */
00050 
00051 /*     A * X = B,  A**T * X = B,  or  A**H * X = B, */
00052 
00053 /*  where A is a triangular band matrix of order N, and B is an */
00054 /*  N-by-NRHS matrix.  A check is made to verify that A is nonsingular. */
00055 
00056 /*  Arguments */
00057 /*  ========= */
00058 
00059 /*  UPLO    (input) CHARACTER*1 */
00060 /*          = 'U':  A is upper triangular; */
00061 /*          = 'L':  A is lower triangular. */
00062 
00063 /*  TRANS   (input) CHARACTER*1 */
00064 /*          Specifies the form of the system of equations: */
00065 /*          = 'N':  A * X = B     (No transpose) */
00066 /*          = 'T':  A**T * X = B  (Transpose) */
00067 /*          = 'C':  A**H * X = B  (Conjugate transpose) */
00068 
00069 /*  DIAG    (input) CHARACTER*1 */
00070 /*          = 'N':  A is non-unit triangular; */
00071 /*          = 'U':  A is unit triangular. */
00072 
00073 /*  N       (input) INTEGER */
00074 /*          The order of the matrix A.  N >= 0. */
00075 
00076 /*  KD      (input) INTEGER */
00077 /*          The number of superdiagonals or subdiagonals of the */
00078 /*          triangular band matrix A.  KD >= 0. */
00079 
00080 /*  NRHS    (input) INTEGER */
00081 /*          The number of right hand sides, i.e., the number of columns */
00082 /*          of the matrix B.  NRHS >= 0. */
00083 
00084 /*  AB      (input) COMPLEX array, dimension (LDAB,N) */
00085 /*          The upper or lower triangular band matrix A, stored in the */
00086 /*          first kd+1 rows of AB.  The j-th column of A is stored */
00087 /*          in the j-th column of the array AB as follows: */
00088 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00089 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00090 /*          If DIAG = 'U', the diagonal elements of A are not referenced */
00091 /*          and are assumed to be 1. */
00092 
00093 /*  LDAB    (input) INTEGER */
00094 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00095 
00096 /*  B       (input/output) COMPLEX array, dimension (LDB,NRHS) */
00097 /*          On entry, the right hand side matrix B. */
00098 /*          On exit, if INFO = 0, the solution matrix X. */
00099 
00100 /*  LDB     (input) INTEGER */
00101 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00102 
00103 /*  INFO    (output) INTEGER */
00104 /*          = 0:  successful exit */
00105 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00106 /*          > 0:  if INFO = i, the i-th diagonal element of A is zero, */
00107 /*                indicating that the matrix is singular and the */
00108 /*                solutions X have not been computed. */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124 /*     Test the input parameters. */
00125 
00126     /* Parameter adjustments */
00127     ab_dim1 = *ldab;
00128     ab_offset = 1 + ab_dim1;
00129     ab -= ab_offset;
00130     b_dim1 = *ldb;
00131     b_offset = 1 + b_dim1;
00132     b -= b_offset;
00133 
00134     /* Function Body */
00135     *info = 0;
00136     nounit = lsame_(diag, "N");
00137     upper = lsame_(uplo, "U");
00138     if (! upper && ! lsame_(uplo, "L")) {
00139         *info = -1;
00140     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00141             "T") && ! lsame_(trans, "C")) {
00142         *info = -2;
00143     } else if (! nounit && ! lsame_(diag, "U")) {
00144         *info = -3;
00145     } else if (*n < 0) {
00146         *info = -4;
00147     } else if (*kd < 0) {
00148         *info = -5;
00149     } else if (*nrhs < 0) {
00150         *info = -6;
00151     } else if (*ldab < *kd + 1) {
00152         *info = -8;
00153     } else if (*ldb < max(1,*n)) {
00154         *info = -10;
00155     }
00156     if (*info != 0) {
00157         i__1 = -(*info);
00158         xerbla_("CTBTRS", &i__1);
00159         return 0;
00160     }
00161 
00162 /*     Quick return if possible */
00163 
00164     if (*n == 0) {
00165         return 0;
00166     }
00167 
00168 /*     Check for singularity. */
00169 
00170     if (nounit) {
00171         if (upper) {
00172             i__1 = *n;
00173             for (*info = 1; *info <= i__1; ++(*info)) {
00174                 i__2 = *kd + 1 + *info * ab_dim1;
00175                 if (ab[i__2].r == 0.f && ab[i__2].i == 0.f) {
00176                     return 0;
00177                 }
00178 /* L10: */
00179             }
00180         } else {
00181             i__1 = *n;
00182             for (*info = 1; *info <= i__1; ++(*info)) {
00183                 i__2 = *info * ab_dim1 + 1;
00184                 if (ab[i__2].r == 0.f && ab[i__2].i == 0.f) {
00185                     return 0;
00186                 }
00187 /* L20: */
00188             }
00189         }
00190     }
00191     *info = 0;
00192 
00193 /*     Solve A * X = B,  A**T * X = B,  or  A**H * X = B. */
00194 
00195     i__1 = *nrhs;
00196     for (j = 1; j <= i__1; ++j) {
00197         ctbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &b[j * b_dim1 
00198                 + 1], &c__1);
00199 /* L30: */
00200     }
00201 
00202     return 0;
00203 
00204 /*     End of CTBTRS */
00205 
00206 } /* ctbtrs_ */


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