LAPACK  3.9.1
LAPACK: Linear Algebra PACKage
dlarhs.f
Go to the documentation of this file.
1 *> \brief \b DLARHS
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE DLARHS( PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS,
12 * A, LDA, X, LDX, B, LDB, ISEED, INFO )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER TRANS, UPLO, XTYPE
16 * CHARACTER*3 PATH
17 * INTEGER INFO, KL, KU, LDA, LDB, LDX, M, N, NRHS
18 * ..
19 * .. Array Arguments ..
20 * INTEGER ISEED( 4 )
21 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), X( LDX, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> DLARHS chooses a set of NRHS random solution vectors and sets
31 *> up the right hand sides for the linear system
32 *> op( A ) * X = B,
33 *> where op( A ) may be A or A' (transpose of A).
34 *> \endverbatim
35 *
36 * Arguments:
37 * ==========
38 *
39 *> \param[in] PATH
40 *> \verbatim
41 *> PATH is CHARACTER*3
42 *> The type of the real matrix A. PATH may be given in any
43 *> combination of upper and lower case. Valid types include
44 *> xGE: General m x n matrix
45 *> xGB: General banded matrix
46 *> xPO: Symmetric positive definite, 2-D storage
47 *> xPP: Symmetric positive definite packed
48 *> xPB: Symmetric positive definite banded
49 *> xSY: Symmetric indefinite, 2-D storage
50 *> xSP: Symmetric indefinite packed
51 *> xSB: Symmetric indefinite banded
52 *> xTR: Triangular
53 *> xTP: Triangular packed
54 *> xTB: Triangular banded
55 *> xQR: General m x n matrix
56 *> xLQ: General m x n matrix
57 *> xQL: General m x n matrix
58 *> xRQ: General m x n matrix
59 *> where the leading character indicates the precision.
60 *> \endverbatim
61 *>
62 *> \param[in] XTYPE
63 *> \verbatim
64 *> XTYPE is CHARACTER*1
65 *> Specifies how the exact solution X will be determined:
66 *> = 'N': New solution; generate a random X.
67 *> = 'C': Computed; use value of X on entry.
68 *> \endverbatim
69 *>
70 *> \param[in] UPLO
71 *> \verbatim
72 *> UPLO is CHARACTER*1
73 *> Specifies whether the upper or lower triangular part of the
74 *> matrix A is stored, if A is symmetric.
75 *> = 'U': Upper triangular
76 *> = 'L': Lower triangular
77 *> \endverbatim
78 *>
79 *> \param[in] TRANS
80 *> \verbatim
81 *> TRANS is CHARACTER*1
82 *> Specifies the operation applied to the matrix A.
83 *> = 'N': System is A * x = b
84 *> = 'T': System is A'* x = b
85 *> = 'C': System is A'* x = b
86 *> \endverbatim
87 *>
88 *> \param[in] M
89 *> \verbatim
90 *> M is INTEGER
91 *> The number or rows of the matrix A. M >= 0.
92 *> \endverbatim
93 *>
94 *> \param[in] N
95 *> \verbatim
96 *> N is INTEGER
97 *> The number of columns of the matrix A. N >= 0.
98 *> \endverbatim
99 *>
100 *> \param[in] KL
101 *> \verbatim
102 *> KL is INTEGER
103 *> Used only if A is a band matrix; specifies the number of
104 *> subdiagonals of A if A is a general band matrix or if A is
105 *> symmetric or triangular and UPLO = 'L'; specifies the number
106 *> of superdiagonals of A if A is symmetric or triangular and
107 *> UPLO = 'U'. 0 <= KL <= M-1.
108 *> \endverbatim
109 *>
110 *> \param[in] KU
111 *> \verbatim
112 *> KU is INTEGER
113 *> Used only if A is a general band matrix or if A is
114 *> triangular.
115 *>
116 *> If PATH = xGB, specifies the number of superdiagonals of A,
117 *> and 0 <= KU <= N-1.
118 *>
119 *> If PATH = xTR, xTP, or xTB, specifies whether or not the
120 *> matrix has unit diagonal:
121 *> = 1: matrix has non-unit diagonal (default)
122 *> = 2: matrix has unit diagonal
123 *> \endverbatim
124 *>
125 *> \param[in] NRHS
126 *> \verbatim
127 *> NRHS is INTEGER
128 *> The number of right hand side vectors in the system A*X = B.
129 *> \endverbatim
130 *>
131 *> \param[in] A
132 *> \verbatim
133 *> A is DOUBLE PRECISION array, dimension (LDA,N)
134 *> The test matrix whose type is given by PATH.
135 *> \endverbatim
136 *>
137 *> \param[in] LDA
138 *> \verbatim
139 *> LDA is INTEGER
140 *> The leading dimension of the array A.
141 *> If PATH = xGB, LDA >= KL+KU+1.
142 *> If PATH = xPB, xSB, xHB, or xTB, LDA >= KL+1.
143 *> Otherwise, LDA >= max(1,M).
144 *> \endverbatim
145 *>
146 *> \param[in,out] X
147 *> \verbatim
148 *> X is or output) DOUBLE PRECISION array, dimension(LDX,NRHS)
149 *> On entry, if XTYPE = 'C' (for 'Computed'), then X contains
150 *> the exact solution to the system of linear equations.
151 *> On exit, if XTYPE = 'N' (for 'New'), then X is initialized
152 *> with random values.
153 *> \endverbatim
154 *>
155 *> \param[in] LDX
156 *> \verbatim
157 *> LDX is INTEGER
158 *> The leading dimension of the array X. If TRANS = 'N',
159 *> LDX >= max(1,N); if TRANS = 'T', LDX >= max(1,M).
160 *> \endverbatim
161 *>
162 *> \param[out] B
163 *> \verbatim
164 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
165 *> The right hand side vector(s) for the system of equations,
166 *> computed from B = op(A) * X, where op(A) is determined by
167 *> TRANS.
168 *> \endverbatim
169 *>
170 *> \param[in] LDB
171 *> \verbatim
172 *> LDB is INTEGER
173 *> The leading dimension of the array B. If TRANS = 'N',
174 *> LDB >= max(1,M); if TRANS = 'T', LDB >= max(1,N).
175 *> \endverbatim
176 *>
177 *> \param[in,out] ISEED
178 *> \verbatim
179 *> ISEED is INTEGER array, dimension (4)
180 *> The seed vector for the random number generator (used in
181 *> DLATMS). Modified on exit.
182 *> \endverbatim
183 *>
184 *> \param[out] INFO
185 *> \verbatim
186 *> INFO is INTEGER
187 *> = 0: successful exit
188 *> < 0: if INFO = -i, the i-th argument had an illegal value
189 *> \endverbatim
190 *
191 * Authors:
192 * ========
193 *
194 *> \author Univ. of Tennessee
195 *> \author Univ. of California Berkeley
196 *> \author Univ. of Colorado Denver
197 *> \author NAG Ltd.
198 *
199 *> \ingroup double_eig
200 *
201 * =====================================================================
202  SUBROUTINE dlarhs( PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS,
203  $ A, LDA, X, LDX, B, LDB, ISEED, INFO )
204 *
205 * -- LAPACK test routine --
206 * -- LAPACK is a software package provided by Univ. of Tennessee, --
207 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
208 *
209 * .. Scalar Arguments ..
210  CHARACTER TRANS, UPLO, XTYPE
211  CHARACTER*3 PATH
212  INTEGER INFO, KL, KU, LDA, LDB, LDX, M, N, NRHS
213 * ..
214 * .. Array Arguments ..
215  INTEGER ISEED( 4 )
216  DOUBLE PRECISION A( LDA, * ), B( LDB, * ), X( LDX, * )
217 * ..
218 *
219 * =====================================================================
220 *
221 * .. Parameters ..
222  DOUBLE PRECISION ONE, ZERO
223  parameter( one = 1.0d+0, zero = 0.0d+0 )
224 * ..
225 * .. Local Scalars ..
226  LOGICAL BAND, GEN, NOTRAN, QRS, SYM, TRAN, TRI
227  CHARACTER C1, DIAG
228  CHARACTER*2 C2
229  INTEGER J, MB, NX
230 * ..
231 * .. External Functions ..
232  LOGICAL LSAME, LSAMEN
233  EXTERNAL lsame, lsamen
234 * ..
235 * .. External Subroutines ..
236  EXTERNAL dgbmv, dgemm, dlacpy, dlarnv, dsbmv, dspmv,
238 * ..
239 * .. Intrinsic Functions ..
240  INTRINSIC max
241 * ..
242 * .. Executable Statements ..
243 *
244 * Test the input parameters.
245 *
246  info = 0
247  c1 = path( 1: 1 )
248  c2 = path( 2: 3 )
249  tran = lsame( trans, 'T' ) .OR. lsame( trans, 'C' )
250  notran = .NOT.tran
251  gen = lsame( path( 2: 2 ), 'G' )
252  qrs = lsame( path( 2: 2 ), 'Q' ) .OR. lsame( path( 3: 3 ), 'Q' )
253  sym = lsame( path( 2: 2 ), 'P' ) .OR. lsame( path( 2: 2 ), 'S' )
254  tri = lsame( path( 2: 2 ), 'T' )
255  band = lsame( path( 3: 3 ), 'B' )
256  IF( .NOT.lsame( c1, 'Double precision' ) ) THEN
257  info = -1
258  ELSE IF( .NOT.( lsame( xtype, 'N' ) .OR. lsame( xtype, 'C' ) ) )
259  $ THEN
260  info = -2
261  ELSE IF( ( sym .OR. tri ) .AND. .NOT.
262  $ ( lsame( uplo, 'U' ) .OR. lsame( uplo, 'L' ) ) ) THEN
263  info = -3
264  ELSE IF( ( gen .OR. qrs ) .AND. .NOT.
265  $ ( tran .OR. lsame( trans, 'N' ) ) ) THEN
266  info = -4
267  ELSE IF( m.LT.0 ) THEN
268  info = -5
269  ELSE IF( n.LT.0 ) THEN
270  info = -6
271  ELSE IF( band .AND. kl.LT.0 ) THEN
272  info = -7
273  ELSE IF( band .AND. ku.LT.0 ) THEN
274  info = -8
275  ELSE IF( nrhs.LT.0 ) THEN
276  info = -9
277  ELSE IF( ( .NOT.band .AND. lda.LT.max( 1, m ) ) .OR.
278  $ ( band .AND. ( sym .OR. tri ) .AND. lda.LT.kl+1 ) .OR.
279  $ ( band .AND. gen .AND. lda.LT.kl+ku+1 ) ) THEN
280  info = -11
281  ELSE IF( ( notran .AND. ldx.LT.max( 1, n ) ) .OR.
282  $ ( tran .AND. ldx.LT.max( 1, m ) ) ) THEN
283  info = -13
284  ELSE IF( ( notran .AND. ldb.LT.max( 1, m ) ) .OR.
285  $ ( tran .AND. ldb.LT.max( 1, n ) ) ) THEN
286  info = -15
287  END IF
288  IF( info.NE.0 ) THEN
289  CALL xerbla( 'DLARHS', -info )
290  RETURN
291  END IF
292 *
293 * Initialize X to NRHS random vectors unless XTYPE = 'C'.
294 *
295  IF( tran ) THEN
296  nx = m
297  mb = n
298  ELSE
299  nx = n
300  mb = m
301  END IF
302  IF( .NOT.lsame( xtype, 'C' ) ) THEN
303  DO 10 j = 1, nrhs
304  CALL dlarnv( 2, iseed, n, x( 1, j ) )
305  10 CONTINUE
306  END IF
307 *
308 * Multiply X by op( A ) using an appropriate
309 * matrix multiply routine.
310 *
311  IF( lsamen( 2, c2, 'GE' ) .OR. lsamen( 2, c2, 'QR' ) .OR.
312  $ lsamen( 2, c2, 'LQ' ) .OR. lsamen( 2, c2, 'QL' ) .OR.
313  $ lsamen( 2, c2, 'RQ' ) ) THEN
314 *
315 * General matrix
316 *
317  CALL dgemm( trans, 'N', mb, nrhs, nx, one, a, lda, x, ldx,
318  $ zero, b, ldb )
319 *
320  ELSE IF( lsamen( 2, c2, 'PO' ) .OR. lsamen( 2, c2, 'SY' ) ) THEN
321 *
322 * Symmetric matrix, 2-D storage
323 *
324  CALL dsymm( 'Left', uplo, n, nrhs, one, a, lda, x, ldx, zero,
325  $ b, ldb )
326 *
327  ELSE IF( lsamen( 2, c2, 'GB' ) ) THEN
328 *
329 * General matrix, band storage
330 *
331  DO 20 j = 1, nrhs
332  CALL dgbmv( trans, mb, nx, kl, ku, one, a, lda, x( 1, j ),
333  $ 1, zero, b( 1, j ), 1 )
334  20 CONTINUE
335 *
336  ELSE IF( lsamen( 2, c2, 'PB' ) ) THEN
337 *
338 * Symmetric matrix, band storage
339 *
340  DO 30 j = 1, nrhs
341  CALL dsbmv( uplo, n, kl, one, a, lda, x( 1, j ), 1, zero,
342  $ b( 1, j ), 1 )
343  30 CONTINUE
344 *
345  ELSE IF( lsamen( 2, c2, 'PP' ) .OR. lsamen( 2, c2, 'SP' ) ) THEN
346 *
347 * Symmetric matrix, packed storage
348 *
349  DO 40 j = 1, nrhs
350  CALL dspmv( uplo, n, one, a, x( 1, j ), 1, zero, b( 1, j ),
351  $ 1 )
352  40 CONTINUE
353 *
354  ELSE IF( lsamen( 2, c2, 'TR' ) ) THEN
355 *
356 * Triangular matrix. Note that for triangular matrices,
357 * KU = 1 => non-unit triangular
358 * KU = 2 => unit triangular
359 *
360  CALL dlacpy( 'Full', n, nrhs, x, ldx, b, ldb )
361  IF( ku.EQ.2 ) THEN
362  diag = 'U'
363  ELSE
364  diag = 'N'
365  END IF
366  CALL dtrmm( 'Left', uplo, trans, diag, n, nrhs, one, a, lda, b,
367  $ ldb )
368 *
369  ELSE IF( lsamen( 2, c2, 'TP' ) ) THEN
370 *
371 * Triangular matrix, packed storage
372 *
373  CALL dlacpy( 'Full', n, nrhs, x, ldx, b, ldb )
374  IF( ku.EQ.2 ) THEN
375  diag = 'U'
376  ELSE
377  diag = 'N'
378  END IF
379  DO 50 j = 1, nrhs
380  CALL dtpmv( uplo, trans, diag, n, a, b( 1, j ), 1 )
381  50 CONTINUE
382 *
383  ELSE IF( lsamen( 2, c2, 'TB' ) ) THEN
384 *
385 * Triangular matrix, banded storage
386 *
387  CALL dlacpy( 'Full', n, nrhs, x, ldx, b, ldb )
388  IF( ku.EQ.2 ) THEN
389  diag = 'U'
390  ELSE
391  diag = 'N'
392  END IF
393  DO 60 j = 1, nrhs
394  CALL dtbmv( uplo, trans, diag, n, kl, a, lda, b( 1, j ), 1 )
395  60 CONTINUE
396 *
397  ELSE
398 *
399 * If PATH is none of the above, return with an error code.
400 *
401  info = -1
402  CALL xerbla( 'DLARHS', -info )
403  END IF
404 *
405  RETURN
406 *
407 * End of DLARHS
408 *
409  END
subroutine dlarnv(IDIST, ISEED, N, X)
DLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: dlarnv.f:97
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:103
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine dgbmv(TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
DGBMV
Definition: dgbmv.f:185
subroutine dtpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
DTPMV
Definition: dtpmv.f:142
subroutine dsbmv(UPLO, N, K, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
DSBMV
Definition: dsbmv.f:184
subroutine dtbmv(UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX)
DTBMV
Definition: dtbmv.f:186
subroutine dspmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
DSPMV
Definition: dspmv.f:147
subroutine dsymm(SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DSYMM
Definition: dsymm.f:189
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:187
subroutine dtrmm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
DTRMM
Definition: dtrmm.f:177
subroutine dlarhs(PATH, XTYPE, UPLO, TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B, LDB, ISEED, INFO)
DLARHS
Definition: dlarhs.f:204