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


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