PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zgeqrs.f
Go to the documentation of this file.
1  SUBROUTINE zgeqrs( M, N, NRHS, A, LDA, TAU, B, LDB, WORK, LWORK,
2  $ info )
3 *
4 * -- LAPACK routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  INTEGER info, lda, ldb, lwork, m, n, nrhs
10 * ..
11 * .. Array Arguments ..
12  COMPLEX*16 a( lda, * ), b( ldb, * ), tau( * ),
13  $ work( lwork )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * Solve the least squares problem
20 * min || A*X - B ||
21 * using the QR factorization
22 * A = Q*R
23 * computed by ZGEQRF.
24 *
25 * Arguments
26 * =========
27 *
28 * M (input) INTEGER
29 * The number of rows of the matrix A. M >= 0.
30 *
31 * N (input) INTEGER
32 * The number of columns of the matrix A. M >= N >= 0.
33 *
34 * NRHS (input) INTEGER
35 * The number of columns of B. NRHS >= 0.
36 *
37 * A (input) COMPLEX*16 array, dimension (LDA,N)
38 * Details of the QR factorization of the original matrix A as
39 * returned by ZGEQRF.
40 *
41 * LDA (input) INTEGER
42 * The leading dimension of the array A. LDA >= M.
43 *
44 * TAU (input) COMPLEX*16 array, dimension (N)
45 * Details of the orthogonal matrix Q.
46 *
47 * B (input/output) COMPLEX*16 array, dimension (LDB,NRHS)
48 * On entry, the m-by-nrhs right hand side matrix B.
49 * On exit, the n-by-nrhs solution matrix X.
50 *
51 * LDB (input) INTEGER
52 * The leading dimension of the array B. LDB >= M.
53 *
54 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
55 *
56 * LWORK (input) INTEGER
57 * The length of the array WORK. LWORK must be at least NRHS,
58 * and should be at least NRHS*NB, where NB is the block size
59 * for this environment.
60 *
61 * INFO (output) INTEGER
62 * = 0: successful exit
63 * < 0: if INFO = -i, the i-th argument had an illegal value
64 *
65 * =====================================================================
66 *
67 * .. Parameters ..
68  COMPLEX*16 one
69  parameter( one = ( 1.0d+0, 0.0d+0 ) )
70 * ..
71 * .. External Subroutines ..
72  EXTERNAL xerbla, ztrsm, zunmqr
73 * ..
74 * .. Intrinsic Functions ..
75  INTRINSIC max
76 * ..
77 * .. Executable Statements ..
78 *
79 * Test the input arguments.
80 *
81  info = 0
82  IF( m.LT.0 ) THEN
83  info = -1
84  ELSE IF( n.LT.0 .OR. n.GT.m ) THEN
85  info = -2
86  ELSE IF( nrhs.LT.0 ) THEN
87  info = -3
88  ELSE IF( lda.LT.max( 1, m ) ) THEN
89  info = -5
90  ELSE IF( ldb.LT.max( 1, m ) ) THEN
91  info = -8
92  ELSE IF( lwork.LT.1 .OR. lwork.LT.nrhs .AND. m.GT.0 .AND. n.GT.0 )
93  $ THEN
94  info = -10
95  END IF
96  IF( info.NE.0 ) THEN
97  CALL xerbla( 'ZGEQRS', -info )
98  return
99  END IF
100 *
101 * Quick return if possible
102 *
103  IF( n.EQ.0 .OR. nrhs.EQ.0 .OR. m.EQ.0 )
104  $ return
105 *
106 * B := Q' * B
107 *
108  CALL zunmqr( 'Left', 'Conjugate transpose', m, nrhs, n, a, lda,
109  $ tau, b, ldb, work, lwork, info )
110 *
111 * Solve R*X = B(1:n,:)
112 *
113  CALL ztrsm( 'Left', 'Upper', 'No transpose', 'Non-unit', n, nrhs,
114  $ one, a, lda, b, ldb )
115 *
116  return
117 *
118 * End of ZGEQRS
119 *
120  END