001: SUBROUTINE CTRTRS( UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, 002: $ INFO ) 003: * 004: * -- LAPACK routine (version 3.2) -- 005: * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 006: * November 2006 007: * 008: * .. Scalar Arguments .. 009: CHARACTER DIAG, TRANS, UPLO 010: INTEGER INFO, LDA, LDB, N, NRHS 011: * .. 012: * .. Array Arguments .. 013: COMPLEX A( LDA, * ), B( LDB, * ) 014: * .. 015: * 016: * Purpose 017: * ======= 018: * 019: * CTRTRS solves a triangular system of the form 020: * 021: * A * X = B, A**T * X = B, or A**H * X = B, 022: * 023: * where A is a triangular matrix of order N, and B is an N-by-NRHS 024: * matrix. A check is made to verify that A is nonsingular. 025: * 026: * Arguments 027: * ========= 028: * 029: * UPLO (input) CHARACTER*1 030: * = 'U': A is upper triangular; 031: * = 'L': A is lower triangular. 032: * 033: * TRANS (input) CHARACTER*1 034: * Specifies the form of the system of equations: 035: * = 'N': A * X = B (No transpose) 036: * = 'T': A**T * X = B (Transpose) 037: * = 'C': A**H * X = B (Conjugate transpose) 038: * 039: * DIAG (input) CHARACTER*1 040: * = 'N': A is non-unit triangular; 041: * = 'U': A is unit triangular. 042: * 043: * N (input) INTEGER 044: * The order of the matrix A. N >= 0. 045: * 046: * NRHS (input) INTEGER 047: * The number of right hand sides, i.e., the number of columns 048: * of the matrix B. NRHS >= 0. 049: * 050: * A (input) COMPLEX array, dimension (LDA,N) 051: * The triangular matrix A. If UPLO = 'U', the leading N-by-N 052: * upper triangular part of the array A contains the upper 053: * triangular matrix, and the strictly lower triangular part of 054: * A is not referenced. If UPLO = 'L', the leading N-by-N lower 055: * triangular part of the array A contains the lower triangular 056: * matrix, and the strictly upper triangular part of A is not 057: * referenced. If DIAG = 'U', the diagonal elements of A are 058: * also not referenced and are assumed to be 1. 059: * 060: * LDA (input) INTEGER 061: * The leading dimension of the array A. LDA >= max(1,N). 062: * 063: * B (input/output) COMPLEX array, dimension (LDB,NRHS) 064: * On entry, the right hand side matrix B. 065: * On exit, if INFO = 0, the solution matrix X. 066: * 067: * LDB (input) INTEGER 068: * The leading dimension of the array B. LDB >= max(1,N). 069: * 070: * INFO (output) INTEGER 071: * = 0: successful exit 072: * < 0: if INFO = -i, the i-th argument had an illegal value 073: * > 0: if INFO = i, the i-th diagonal element of A is zero, 074: * indicating that the matrix is singular and the solutions 075: * X have not been computed. 076: * 077: * ===================================================================== 078: * 079: * .. Parameters .. 080: COMPLEX ZERO, ONE 081: PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ), 082: $ ONE = ( 1.0E+0, 0.0E+0 ) ) 083: * .. 084: * .. Local Scalars .. 085: LOGICAL NOUNIT 086: * .. 087: * .. External Functions .. 088: LOGICAL LSAME 089: EXTERNAL LSAME 090: * .. 091: * .. External Subroutines .. 092: EXTERNAL CTRSM, XERBLA 093: * .. 094: * .. Intrinsic Functions .. 095: INTRINSIC MAX 096: * .. 097: * .. Executable Statements .. 098: * 099: * Test the input parameters. 100: * 101: INFO = 0 102: NOUNIT = LSAME( DIAG, 'N' ) 103: IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 104: INFO = -1 105: ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT. 106: $ LSAME( TRANS, 'T' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN 107: INFO = -2 108: ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN 109: INFO = -3 110: ELSE IF( N.LT.0 ) THEN 111: INFO = -4 112: ELSE IF( NRHS.LT.0 ) THEN 113: INFO = -5 114: ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 115: INFO = -7 116: ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 117: INFO = -9 118: END IF 119: IF( INFO.NE.0 ) THEN 120: CALL XERBLA( 'CTRTRS', -INFO ) 121: RETURN 122: END IF 123: * 124: * Quick return if possible 125: * 126: IF( N.EQ.0 ) 127: $ RETURN 128: * 129: * Check for singularity. 130: * 131: IF( NOUNIT ) THEN 132: DO 10 INFO = 1, N 133: IF( A( INFO, INFO ).EQ.ZERO ) 134: $ RETURN 135: 10 CONTINUE 136: END IF 137: INFO = 0 138: * 139: * Solve A * x = b, A**T * x = b, or A**H * x = b. 140: * 141: CALL CTRSM( 'Left', UPLO, TRANS, DIAG, N, NRHS, ONE, A, LDA, B, 142: $ LDB ) 143: * 144: RETURN 145: * 146: * End of CTRTRS 147: * 148: END 149: