LAPACK  3.9.1
LAPACK: Linear Algebra PACKage

◆ clarhs()

subroutine clarhs ( character*3  PATH,
character  XTYPE,
character  UPLO,
character  TRANS,
integer  M,
integer  N,
integer  KL,
integer  KU,
integer  NRHS,
complex, dimension( lda, * )  A,
integer  LDA,
complex, dimension( ldx, * )  X,
integer  LDX,
complex, dimension( ldb, * )  B,
integer  LDB,
integer, dimension( 4 )  ISEED,
integer  INFO 
)

CLARHS

Purpose:
 CLARHS chooses a set of NRHS random solution vectors and sets
 up the right hand sides for the linear system
    op( A ) * X = B,
 where op( A ) may be A, A**T (transpose of A), or A**H (conjugate
 transpose of A).
Parameters
[in]PATH
          PATH is CHARACTER*3
          The type of the complex matrix A.  PATH may be given in any
          combination of upper and lower case.  Valid paths include
             xGE:  General m x n matrix
             xGB:  General banded matrix
             xPO:  Hermitian positive definite, 2-D storage
             xPP:  Hermitian positive definite packed
             xPB:  Hermitian positive definite banded
             xHE:  Hermitian indefinite, 2-D storage
             xHP:  Hermitian indefinite packed
             xHB:  Hermitian indefinite banded
             xSY:  Symmetric indefinite, 2-D storage
             xSP:  Symmetric indefinite packed
             xSB:  Symmetric indefinite banded
             xTR:  Triangular
             xTP:  Triangular packed
             xTB:  Triangular banded
             xQR:  General m x n matrix
             xLQ:  General m x n matrix
             xQL:  General m x n matrix
             xRQ:  General m x n matrix
          where the leading character indicates the precision.
[in]XTYPE
          XTYPE is CHARACTER*1
          Specifies how the exact solution X will be determined:
          = 'N':  New solution; generate a random X.
          = 'C':  Computed; use value of X on entry.
[in]UPLO
          UPLO is CHARACTER*1
          Used only if A is symmetric or triangular; specifies whether
          the upper or lower triangular part of the matrix A is stored.
          = 'U':  Upper triangular
          = 'L':  Lower triangular
[in]TRANS
          TRANS is CHARACTER*1
          Used only if A is nonsymmetric; specifies the operation
          applied to the matrix A.
          = 'N':  B := A    * X
          = 'T':  B := A**T * X
          = 'C':  B := A**H * X
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0.
[in]KL
          KL is INTEGER
          Used only if A is a band matrix; specifies the number of
          subdiagonals of A if A is a general band matrix or if A is
          symmetric or triangular and UPLO = 'L'; specifies the number
          of superdiagonals of A if A is symmetric or triangular and
          UPLO = 'U'.  0 <= KL <= M-1.
[in]KU
          KU is INTEGER
          Used only if A is a general band matrix or if A is
          triangular.

          If PATH = xGB, specifies the number of superdiagonals of A,
          and 0 <= KU <= N-1.

          If PATH = xTR, xTP, or xTB, specifies whether or not the
          matrix has unit diagonal:
          = 1:  matrix has non-unit diagonal (default)
          = 2:  matrix has unit diagonal
[in]NRHS
          NRHS is INTEGER
          The number of right hand side vectors in the system A*X = B.
[in]A
          A is COMPLEX array, dimension (LDA,N)
          The test matrix whose type is given by PATH.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.
          If PATH = xGB, LDA >= KL+KU+1.
          If PATH = xPB, xSB, xHB, or xTB, LDA >= KL+1.
          Otherwise, LDA >= max(1,M).
[in,out]X
          X is or output) COMPLEX array, dimension (LDX,NRHS)
          On entry, if XTYPE = 'C' (for 'Computed'), then X contains
          the exact solution to the system of linear equations.
          On exit, if XTYPE = 'N' (for 'New'), then X is initialized
          with random values.
[in]LDX
          LDX is INTEGER
          The leading dimension of the array X.  If TRANS = 'N',
          LDX >= max(1,N); if TRANS = 'T', LDX >= max(1,M).
[out]B
          B is COMPLEX array, dimension (LDB,NRHS)
          The right hand side vector(s) for the system of equations,
          computed from B = op(A) * X, where op(A) is determined by
          TRANS.
[in]LDB
          LDB is INTEGER
          The leading dimension of the array B.  If TRANS = 'N',
          LDB >= max(1,M); if TRANS = 'T', LDB >= max(1,N).
[in,out]ISEED
          ISEED is INTEGER array, dimension (4)
          The seed vector for the random number generator (used in
          CLATMS).  Modified on exit.
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 207 of file clarhs.f.

209 *
210 * -- LAPACK test routine --
211 * -- LAPACK is a software package provided by Univ. of Tennessee, --
212 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
213 *
214 * .. Scalar Arguments ..
215  CHARACTER TRANS, UPLO, XTYPE
216  CHARACTER*3 PATH
217  INTEGER INFO, KL, KU, LDA, LDB, LDX, M, N, NRHS
218 * ..
219 * .. Array Arguments ..
220  INTEGER ISEED( 4 )
221  COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
222 * ..
223 *
224 * =====================================================================
225 *
226 * .. Parameters ..
227  COMPLEX ONE, ZERO
228  parameter( one = ( 1.0e+0, 0.0e+0 ),
229  $ zero = ( 0.0e+0, 0.0e+0 ) )
230 * ..
231 * .. Local Scalars ..
232  LOGICAL BAND, GEN, NOTRAN, QRS, SYM, TRAN, TRI
233  CHARACTER C1, DIAG
234  CHARACTER*2 C2
235  INTEGER J, MB, NX
236 * ..
237 * .. External Functions ..
238  LOGICAL LSAME, LSAMEN
239  EXTERNAL lsame, lsamen
240 * ..
241 * .. External Subroutines ..
242  EXTERNAL cgbmv, cgemm, chbmv, chemm, chpmv, clacpy,
244  $ ctrmm, xerbla
245 * ..
246 * .. Intrinsic Functions ..
247  INTRINSIC max
248 * ..
249 * .. Executable Statements ..
250 *
251 * Test the input parameters.
252 *
253  info = 0
254  c1 = path( 1: 1 )
255  c2 = path( 2: 3 )
256  tran = lsame( trans, 'T' ) .OR. lsame( trans, 'C' )
257  notran = .NOT.tran
258  gen = lsame( path( 2: 2 ), 'G' )
259  qrs = lsame( path( 2: 2 ), 'Q' ) .OR. lsame( path( 3: 3 ), 'Q' )
260  sym = lsame( path( 2: 2 ), 'P' ) .OR.
261  $ lsame( path( 2: 2 ), 'S' ) .OR. lsame( path( 2: 2 ), 'H' )
262  tri = lsame( path( 2: 2 ), 'T' )
263  band = lsame( path( 3: 3 ), 'B' )
264  IF( .NOT.lsame( c1, 'Complex precision' ) ) THEN
265  info = -1
266  ELSE IF( .NOT.( lsame( xtype, 'N' ) .OR. lsame( xtype, 'C' ) ) )
267  $ THEN
268  info = -2
269  ELSE IF( ( sym .OR. tri ) .AND. .NOT.
270  $ ( lsame( uplo, 'U' ) .OR. lsame( uplo, 'L' ) ) ) THEN
271  info = -3
272  ELSE IF( ( gen.OR.qrs ) .AND.
273  $ .NOT.( tran .OR. lsame( trans, 'N' ) ) ) THEN
274  info = -4
275  ELSE IF( m.LT.0 ) THEN
276  info = -5
277  ELSE IF( n.LT.0 ) THEN
278  info = -6
279  ELSE IF( band .AND. kl.LT.0 ) THEN
280  info = -7
281  ELSE IF( band .AND. ku.LT.0 ) THEN
282  info = -8
283  ELSE IF( nrhs.LT.0 ) THEN
284  info = -9
285  ELSE IF( ( .NOT.band .AND. lda.LT.max( 1, m ) ) .OR.
286  $ ( band .AND. ( sym .OR. tri ) .AND. lda.LT.kl+1 ) .OR.
287  $ ( band .AND. gen .AND. lda.LT.kl+ku+1 ) ) THEN
288  info = -11
289  ELSE IF( ( notran .AND. ldx.LT.max( 1, n ) ) .OR.
290  $ ( tran .AND. ldx.LT.max( 1, m ) ) ) THEN
291  info = -13
292  ELSE IF( ( notran .AND. ldb.LT.max( 1, m ) ) .OR.
293  $ ( tran .AND. ldb.LT.max( 1, n ) ) ) THEN
294  info = -15
295  END IF
296  IF( info.NE.0 ) THEN
297  CALL xerbla( 'CLARHS', -info )
298  RETURN
299  END IF
300 *
301 * Initialize X to NRHS random vectors unless XTYPE = 'C'.
302 *
303  IF( tran ) THEN
304  nx = m
305  mb = n
306  ELSE
307  nx = n
308  mb = m
309  END IF
310  IF( .NOT.lsame( xtype, 'C' ) ) THEN
311  DO 10 j = 1, nrhs
312  CALL clarnv( 2, iseed, n, x( 1, j ) )
313  10 CONTINUE
314  END IF
315 *
316 * Multiply X by op( A ) using an appropriate
317 * matrix multiply routine.
318 *
319  IF( lsamen( 2, c2, 'GE' ) .OR. lsamen( 2, c2, 'QR' ) .OR.
320  $ lsamen( 2, c2, 'LQ' ) .OR. lsamen( 2, c2, 'QL' ) .OR.
321  $ lsamen( 2, c2, 'RQ' ) ) THEN
322 *
323 * General matrix
324 *
325  CALL cgemm( trans, 'N', mb, nrhs, nx, one, a, lda, x, ldx,
326  $ zero, b, ldb )
327 *
328  ELSE IF( lsamen( 2, c2, 'PO' ) .OR. lsamen( 2, c2, 'HE' ) ) THEN
329 *
330 * Hermitian matrix, 2-D storage
331 *
332  CALL chemm( 'Left', uplo, n, nrhs, one, a, lda, x, ldx, zero,
333  $ b, ldb )
334 *
335  ELSE IF( lsamen( 2, c2, 'SY' ) ) THEN
336 *
337 * Symmetric matrix, 2-D storage
338 *
339  CALL csymm( 'Left', uplo, n, nrhs, one, a, lda, x, ldx, zero,
340  $ b, ldb )
341 *
342  ELSE IF( lsamen( 2, c2, 'GB' ) ) THEN
343 *
344 * General matrix, band storage
345 *
346  DO 20 j = 1, nrhs
347  CALL cgbmv( trans, m, n, kl, ku, one, a, lda, x( 1, j ), 1,
348  $ zero, b( 1, j ), 1 )
349  20 CONTINUE
350 *
351  ELSE IF( lsamen( 2, c2, 'PB' ) .OR. lsamen( 2, c2, 'HB' ) ) THEN
352 *
353 * Hermitian matrix, band storage
354 *
355  DO 30 j = 1, nrhs
356  CALL chbmv( uplo, n, kl, one, a, lda, x( 1, j ), 1, zero,
357  $ b( 1, j ), 1 )
358  30 CONTINUE
359 *
360  ELSE IF( lsamen( 2, c2, 'SB' ) ) THEN
361 *
362 * Symmetric matrix, band storage
363 *
364  DO 40 j = 1, nrhs
365  CALL csbmv( uplo, n, kl, one, a, lda, x( 1, j ), 1, zero,
366  $ b( 1, j ), 1 )
367  40 CONTINUE
368 *
369  ELSE IF( lsamen( 2, c2, 'PP' ) .OR. lsamen( 2, c2, 'HP' ) ) THEN
370 *
371 * Hermitian matrix, packed storage
372 *
373  DO 50 j = 1, nrhs
374  CALL chpmv( uplo, n, one, a, x( 1, j ), 1, zero, b( 1, j ),
375  $ 1 )
376  50 CONTINUE
377 *
378  ELSE IF( lsamen( 2, c2, 'SP' ) ) THEN
379 *
380 * Symmetric matrix, packed storage
381 *
382  DO 60 j = 1, nrhs
383  CALL cspmv( uplo, n, one, a, x( 1, j ), 1, zero, b( 1, j ),
384  $ 1 )
385  60 CONTINUE
386 *
387  ELSE IF( lsamen( 2, c2, 'TR' ) ) THEN
388 *
389 * Triangular matrix. Note that for triangular matrices,
390 * KU = 1 => non-unit triangular
391 * KU = 2 => unit triangular
392 *
393  CALL clacpy( 'Full', n, nrhs, x, ldx, b, ldb )
394  IF( ku.EQ.2 ) THEN
395  diag = 'U'
396  ELSE
397  diag = 'N'
398  END IF
399  CALL ctrmm( 'Left', uplo, trans, diag, n, nrhs, one, a, lda, b,
400  $ ldb )
401 *
402  ELSE IF( lsamen( 2, c2, 'TP' ) ) THEN
403 *
404 * Triangular matrix, packed storage
405 *
406  CALL clacpy( 'Full', n, nrhs, x, ldx, b, ldb )
407  IF( ku.EQ.2 ) THEN
408  diag = 'U'
409  ELSE
410  diag = 'N'
411  END IF
412  DO 70 j = 1, nrhs
413  CALL ctpmv( uplo, trans, diag, n, a, b( 1, j ), 1 )
414  70 CONTINUE
415 *
416  ELSE IF( lsamen( 2, c2, 'TB' ) ) THEN
417 *
418 * Triangular matrix, banded storage
419 *
420  CALL clacpy( 'Full', n, nrhs, x, ldx, b, ldb )
421  IF( ku.EQ.2 ) THEN
422  diag = 'U'
423  ELSE
424  diag = 'N'
425  END IF
426  DO 80 j = 1, nrhs
427  CALL ctbmv( uplo, trans, diag, n, kl, a, lda, b( 1, j ), 1 )
428  80 CONTINUE
429 *
430  ELSE
431 *
432 * If none of the above, set INFO = -1 and return
433 *
434  info = -1
435  CALL xerbla( 'CLARHS', -info )
436  END IF
437 *
438  RETURN
439 *
440 * End of CLARHS
441 *
logical function lsamen(N, CA, CB)
LSAMEN
Definition: lsamen.f:74
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine ctbmv(UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX)
CTBMV
Definition: ctbmv.f:186
subroutine chbmv(UPLO, N, K, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CHBMV
Definition: chbmv.f:187
subroutine cgbmv(TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CGBMV
Definition: cgbmv.f:187
subroutine chpmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
CHPMV
Definition: chpmv.f:149
subroutine ctpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
CTPMV
Definition: ctpmv.f:142
subroutine csymm(SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CSYMM
Definition: csymm.f:189
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
Definition: cgemm.f:187
subroutine chemm(SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CHEMM
Definition: chemm.f:191
subroutine ctrmm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
CTRMM
Definition: ctrmm.f:177
subroutine csbmv(UPLO, N, K, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CSBMV
Definition: csbmv.f:152
subroutine clarnv(IDIST, ISEED, N, X)
CLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: clarnv.f:99
subroutine cspmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
CSPMV computes a matrix-vector product for complex vectors using a complex symmetric packed matrix
Definition: cspmv.f:151
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:103
Here is the call graph for this function:
Here is the caller graph for this function: