LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE ZLARHS( PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS, 00002 $ A, LDA, X, LDX, B, LDB, ISEED, INFO ) 00003 * 00004 * -- LAPACK test routine (version 3.1) -- 00005 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 CHARACTER TRANS, UPLO, XTYPE 00010 CHARACTER*3 PATH 00011 INTEGER INFO, KL, KU, LDA, LDB, LDX, M, N, NRHS 00012 * .. 00013 * .. Array Arguments .. 00014 INTEGER ISEED( 4 ) 00015 COMPLEX*16 A( LDA, * ), B( LDB, * ), X( LDX, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * ZLARHS chooses a set of NRHS random solution vectors and sets 00022 * up the right hand sides for the linear system 00023 * op( A ) * X = B, 00024 * where op( A ) may be A, A**T (transpose of A), or A**H (conjugate 00025 * transpose of A). 00026 * 00027 * Arguments 00028 * ========= 00029 * 00030 * PATH (input) CHARACTER*3 00031 * The type of the complex matrix A. PATH may be given in any 00032 * combination of upper and lower case. Valid paths include 00033 * xGE: General m x n matrix 00034 * xGB: General banded matrix 00035 * xPO: Hermitian positive definite, 2-D storage 00036 * xPP: Hermitian positive definite packed 00037 * xPB: Hermitian positive definite banded 00038 * xHE: Hermitian indefinite, 2-D storage 00039 * xHP: Hermitian indefinite packed 00040 * xHB: Hermitian indefinite banded 00041 * xSY: Symmetric indefinite, 2-D storage 00042 * xSP: Symmetric indefinite packed 00043 * xSB: Symmetric indefinite banded 00044 * xTR: Triangular 00045 * xTP: Triangular packed 00046 * xTB: Triangular banded 00047 * xQR: General m x n matrix 00048 * xLQ: General m x n matrix 00049 * xQL: General m x n matrix 00050 * xRQ: General m x n matrix 00051 * where the leading character indicates the precision. 00052 * 00053 * XTYPE (input) CHARACTER*1 00054 * Specifies how the exact solution X will be determined: 00055 * = 'N': New solution; generate a random X. 00056 * = 'C': Computed; use value of X on entry. 00057 * 00058 * UPLO (input) CHARACTER*1 00059 * Used only if A is symmetric or triangular; specifies whether 00060 * the upper or lower triangular part of the matrix A is stored. 00061 * = 'U': Upper triangular 00062 * = 'L': Lower triangular 00063 * 00064 * TRANS (input) CHARACTER*1 00065 * Used only if A is nonsymmetric; specifies the operation 00066 * applied to the matrix A. 00067 * = 'N': B := A * X 00068 * = 'T': B := A**T * X 00069 * = 'C': B := A**H * X 00070 * 00071 * M (input) INTEGER 00072 * The number of rows of the matrix A. M >= 0. 00073 * 00074 * N (input) INTEGER 00075 * The number of columns of the matrix A. N >= 0. 00076 * 00077 * KL (input) INTEGER 00078 * Used only if A is a band matrix; specifies the number of 00079 * subdiagonals of A if A is a general band matrix or if A is 00080 * symmetric or triangular and UPLO = 'L'; specifies the number 00081 * of superdiagonals of A if A is symmetric or triangular and 00082 * UPLO = 'U'. 0 <= KL <= M-1. 00083 * 00084 * KU (input) INTEGER 00085 * Used only if A is a general band matrix or if A is 00086 * triangular. 00087 * 00088 * If PATH = xGB, specifies the number of superdiagonals of A, 00089 * and 0 <= KU <= N-1. 00090 * 00091 * If PATH = xTR, xTP, or xTB, specifies whether or not the 00092 * matrix has unit diagonal: 00093 * = 1: matrix has non-unit diagonal (default) 00094 * = 2: matrix has unit diagonal 00095 * 00096 * NRHS (input) INTEGER 00097 * The number of right hand side vectors in the system A*X = B. 00098 * 00099 * A (input) COMPLEX*16 array, dimension (LDA,N) 00100 * The test matrix whose type is given by PATH. 00101 * 00102 * LDA (input) INTEGER 00103 * The leading dimension of the array A. 00104 * If PATH = xGB, LDA >= KL+KU+1. 00105 * If PATH = xPB, xSB, xHB, or xTB, LDA >= KL+1. 00106 * Otherwise, LDA >= max(1,M). 00107 * 00108 * X (input or output) COMPLEX*16 array, dimension (LDX,NRHS) 00109 * On entry, if XTYPE = 'C' (for 'Computed'), then X contains 00110 * the exact solution to the system of linear equations. 00111 * On exit, if XTYPE = 'N' (for 'New'), then X is initialized 00112 * with random values. 00113 * 00114 * LDX (input) INTEGER 00115 * The leading dimension of the array X. If TRANS = 'N', 00116 * LDX >= max(1,N); if TRANS = 'T', LDX >= max(1,M). 00117 * 00118 * B (output) COMPLEX*16 array, dimension (LDB,NRHS) 00119 * The right hand side vector(s) for the system of equations, 00120 * computed from B = op(A) * X, where op(A) is determined by 00121 * TRANS. 00122 * 00123 * LDB (input) INTEGER 00124 * The leading dimension of the array B. If TRANS = 'N', 00125 * LDB >= max(1,M); if TRANS = 'T', LDB >= max(1,N). 00126 * 00127 * ISEED (input/output) INTEGER array, dimension (4) 00128 * The seed vector for the random number generator (used in 00129 * ZLATMS). Modified on exit. 00130 * 00131 * INFO (output) INTEGER 00132 * = 0: successful exit 00133 * < 0: if INFO = -i, the i-th argument had an illegal value 00134 * 00135 * ===================================================================== 00136 * 00137 * .. Parameters .. 00138 COMPLEX*16 ONE, ZERO 00139 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ), 00140 $ ZERO = ( 0.0D+0, 0.0D+0 ) ) 00141 * .. 00142 * .. Local Scalars .. 00143 LOGICAL BAND, GEN, NOTRAN, QRS, SYM, TRAN, TRI 00144 CHARACTER C1, DIAG 00145 CHARACTER*2 C2 00146 INTEGER J, MB, NX 00147 * .. 00148 * .. External Functions .. 00149 LOGICAL LSAME, LSAMEN 00150 EXTERNAL LSAME, LSAMEN 00151 * .. 00152 * .. External Subroutines .. 00153 EXTERNAL XERBLA, ZGBMV, ZGEMM, ZHBMV, ZHEMM, ZHPMV, 00154 $ ZLACPY, ZLARNV, ZSBMV, ZSPMV, ZSYMM, ZTBMV, 00155 $ ZTPMV, ZTRMM 00156 * .. 00157 * .. Intrinsic Functions .. 00158 INTRINSIC MAX 00159 * .. 00160 * .. Executable Statements .. 00161 * 00162 * Test the input parameters. 00163 * 00164 INFO = 0 00165 C1 = PATH( 1: 1 ) 00166 C2 = PATH( 2: 3 ) 00167 TRAN = LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) 00168 NOTRAN = .NOT.TRAN 00169 GEN = LSAME( PATH( 2: 2 ), 'G' ) 00170 QRS = LSAME( PATH( 2: 2 ), 'Q' ) .OR. LSAME( PATH( 3: 3 ), 'Q' ) 00171 SYM = LSAME( PATH( 2: 2 ), 'P' ) .OR. 00172 $ LSAME( PATH( 2: 2 ), 'S' ) .OR. LSAME( PATH( 2: 2 ), 'H' ) 00173 TRI = LSAME( PATH( 2: 2 ), 'T' ) 00174 BAND = LSAME( PATH( 3: 3 ), 'B' ) 00175 IF( .NOT.LSAME( C1, 'Zomplex precision' ) ) THEN 00176 INFO = -1 00177 ELSE IF( .NOT.( LSAME( XTYPE, 'N' ) .OR. LSAME( XTYPE, 'C' ) ) ) 00178 $ THEN 00179 INFO = -2 00180 ELSE IF( ( SYM .OR. TRI ) .AND. .NOT. 00181 $ ( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) THEN 00182 INFO = -3 00183 ELSE IF( ( GEN .OR. QRS ) .AND. .NOT. 00184 $ ( TRAN .OR. LSAME( TRANS, 'N' ) ) ) THEN 00185 INFO = -4 00186 ELSE IF( M.LT.0 ) THEN 00187 INFO = -5 00188 ELSE IF( N.LT.0 ) THEN 00189 INFO = -6 00190 ELSE IF( BAND .AND. KL.LT.0 ) THEN 00191 INFO = -7 00192 ELSE IF( BAND .AND. KU.LT.0 ) THEN 00193 INFO = -8 00194 ELSE IF( NRHS.LT.0 ) THEN 00195 INFO = -9 00196 ELSE IF( ( .NOT.BAND .AND. LDA.LT.MAX( 1, M ) ) .OR. 00197 $ ( BAND .AND. ( SYM .OR. TRI ) .AND. LDA.LT.KL+1 ) .OR. 00198 $ ( BAND .AND. GEN .AND. LDA.LT.KL+KU+1 ) ) THEN 00199 INFO = -11 00200 ELSE IF( ( NOTRAN .AND. LDX.LT.MAX( 1, N ) ) .OR. 00201 $ ( TRAN .AND. LDX.LT.MAX( 1, M ) ) ) THEN 00202 INFO = -13 00203 ELSE IF( ( NOTRAN .AND. LDB.LT.MAX( 1, M ) ) .OR. 00204 $ ( TRAN .AND. LDB.LT.MAX( 1, N ) ) ) THEN 00205 INFO = -15 00206 END IF 00207 IF( INFO.NE.0 ) THEN 00208 CALL XERBLA( 'ZLARHS', -INFO ) 00209 RETURN 00210 END IF 00211 * 00212 * Initialize X to NRHS random vectors unless XTYPE = 'C'. 00213 * 00214 IF( TRAN ) THEN 00215 NX = M 00216 MB = N 00217 ELSE 00218 NX = N 00219 MB = M 00220 END IF 00221 IF( .NOT.LSAME( XTYPE, 'C' ) ) THEN 00222 DO 10 J = 1, NRHS 00223 CALL ZLARNV( 2, ISEED, N, X( 1, J ) ) 00224 10 CONTINUE 00225 END IF 00226 * 00227 * Multiply X by op( A ) using an appropriate 00228 * matrix multiply routine. 00229 * 00230 IF( LSAMEN( 2, C2, 'GE' ) .OR. LSAMEN( 2, C2, 'QR' ) .OR. 00231 $ LSAMEN( 2, C2, 'LQ' ) .OR. LSAMEN( 2, C2, 'QL' ) .OR. 00232 $ LSAMEN( 2, C2, 'RQ' ) ) THEN 00233 * 00234 * General matrix 00235 * 00236 CALL ZGEMM( TRANS, 'N', MB, NRHS, NX, ONE, A, LDA, X, LDX, 00237 $ ZERO, B, LDB ) 00238 * 00239 ELSE IF( LSAMEN( 2, C2, 'PO' ) .OR. LSAMEN( 2, C2, 'HE' ) ) THEN 00240 * 00241 * Hermitian matrix, 2-D storage 00242 * 00243 CALL ZHEMM( 'Left', UPLO, N, NRHS, ONE, A, LDA, X, LDX, ZERO, 00244 $ B, LDB ) 00245 * 00246 ELSE IF( LSAMEN( 2, C2, 'SY' ) ) THEN 00247 * 00248 * Symmetric matrix, 2-D storage 00249 * 00250 CALL ZSYMM( 'Left', UPLO, N, NRHS, ONE, A, LDA, X, LDX, ZERO, 00251 $ B, LDB ) 00252 * 00253 ELSE IF( LSAMEN( 2, C2, 'GB' ) ) THEN 00254 * 00255 * General matrix, band storage 00256 * 00257 DO 20 J = 1, NRHS 00258 CALL ZGBMV( TRANS, M, N, KL, KU, ONE, A, LDA, X( 1, J ), 1, 00259 $ ZERO, B( 1, J ), 1 ) 00260 20 CONTINUE 00261 * 00262 ELSE IF( LSAMEN( 2, C2, 'PB' ) .OR. LSAMEN( 2, C2, 'HB' ) ) THEN 00263 * 00264 * Hermitian matrix, band storage 00265 * 00266 DO 30 J = 1, NRHS 00267 CALL ZHBMV( UPLO, N, KL, ONE, A, LDA, X( 1, J ), 1, ZERO, 00268 $ B( 1, J ), 1 ) 00269 30 CONTINUE 00270 * 00271 ELSE IF( LSAMEN( 2, C2, 'SB' ) ) THEN 00272 * 00273 * Symmetric matrix, band storage 00274 * 00275 DO 40 J = 1, NRHS 00276 CALL ZSBMV( UPLO, N, KL, ONE, A, LDA, X( 1, J ), 1, ZERO, 00277 $ B( 1, J ), 1 ) 00278 40 CONTINUE 00279 * 00280 ELSE IF( LSAMEN( 2, C2, 'PP' ) .OR. LSAMEN( 2, C2, 'HP' ) ) THEN 00281 * 00282 * Hermitian matrix, packed storage 00283 * 00284 DO 50 J = 1, NRHS 00285 CALL ZHPMV( UPLO, N, ONE, A, X( 1, J ), 1, ZERO, B( 1, J ), 00286 $ 1 ) 00287 50 CONTINUE 00288 * 00289 ELSE IF( LSAMEN( 2, C2, 'SP' ) ) THEN 00290 * 00291 * Symmetric matrix, packed storage 00292 * 00293 DO 60 J = 1, NRHS 00294 CALL ZSPMV( UPLO, N, ONE, A, X( 1, J ), 1, ZERO, B( 1, J ), 00295 $ 1 ) 00296 60 CONTINUE 00297 * 00298 ELSE IF( LSAMEN( 2, C2, 'TR' ) ) THEN 00299 * 00300 * Triangular matrix. Note that for triangular matrices, 00301 * KU = 1 => non-unit triangular 00302 * KU = 2 => unit triangular 00303 * 00304 CALL ZLACPY( 'Full', N, NRHS, X, LDX, B, LDB ) 00305 IF( KU.EQ.2 ) THEN 00306 DIAG = 'U' 00307 ELSE 00308 DIAG = 'N' 00309 END IF 00310 CALL ZTRMM( 'Left', UPLO, TRANS, DIAG, N, NRHS, ONE, A, LDA, B, 00311 $ LDB ) 00312 * 00313 ELSE IF( LSAMEN( 2, C2, 'TP' ) ) THEN 00314 * 00315 * Triangular matrix, packed storage 00316 * 00317 CALL ZLACPY( 'Full', N, NRHS, X, LDX, B, LDB ) 00318 IF( KU.EQ.2 ) THEN 00319 DIAG = 'U' 00320 ELSE 00321 DIAG = 'N' 00322 END IF 00323 DO 70 J = 1, NRHS 00324 CALL ZTPMV( UPLO, TRANS, DIAG, N, A, B( 1, J ), 1 ) 00325 70 CONTINUE 00326 * 00327 ELSE IF( LSAMEN( 2, C2, 'TB' ) ) THEN 00328 * 00329 * Triangular matrix, banded storage 00330 * 00331 CALL ZLACPY( 'Full', N, NRHS, X, LDX, B, LDB ) 00332 IF( KU.EQ.2 ) THEN 00333 DIAG = 'U' 00334 ELSE 00335 DIAG = 'N' 00336 END IF 00337 DO 80 J = 1, NRHS 00338 CALL ZTBMV( UPLO, TRANS, DIAG, N, KL, A, LDA, B( 1, J ), 1 ) 00339 80 CONTINUE 00340 * 00341 ELSE 00342 * 00343 * If none of the above, set INFO = -1 and return 00344 * 00345 INFO = -1 00346 CALL XERBLA( 'ZLARHS', -INFO ) 00347 END IF 00348 * 00349 RETURN 00350 * 00351 * End of ZLARHS 00352 * 00353 END