MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zgelqs.f
Go to the documentation of this file.
1  SUBROUTINE zgelqs( 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 * Compute a minimum-norm solution
20 * min || A*X - B ||
21 * using the LQ factorization
22 * A = L*Q
23 * computed by ZGELQF.
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. N >= M >= 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 LQ factorization of the original matrix A as
39 * returned by ZGELQF.
40 *
41 * LDA (input) INTEGER
42 * The leading dimension of the array A. LDA >= M.
43 *
44 * TAU (input) COMPLEX*16 array, dimension (M)
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 >= N.
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 czero, cone
69  parameter( czero = ( 0.0d+0, 0.0d+0 ),
70  $ cone = ( 1.0d+0, 0.0d+0 ) )
71 * ..
72 * .. External Subroutines ..
73  EXTERNAL xerbla, zlaset, ztrsm, zunmlq
74 * ..
75 * .. Intrinsic Functions ..
76  INTRINSIC max
77 * ..
78 * .. Executable Statements ..
79 *
80 * Test the input parameters.
81 *
82  info = 0
83  IF( m.LT.0 ) THEN
84  info = -1
85  ELSE IF( n.LT.0 .OR. m.GT.n ) THEN
86  info = -2
87  ELSE IF( nrhs.LT.0 ) THEN
88  info = -3
89  ELSE IF( lda.LT.max( 1, m ) ) THEN
90  info = -5
91  ELSE IF( ldb.LT.max( 1, n ) ) THEN
92  info = -8
93  ELSE IF( lwork.LT.1 .OR. lwork.LT.nrhs .AND. m.GT.0 .AND. n.GT.0 )
94  $ THEN
95  info = -10
96  END IF
97  IF( info.NE.0 ) THEN
98  CALL xerbla( 'ZGELQS', -info )
99  return
100  END IF
101 *
102 * Quick return if possible
103 *
104  IF( n.EQ.0 .OR. nrhs.EQ.0 .OR. m.EQ.0 )
105  $ return
106 *
107 * Solve L*X = B(1:m,:)
108 *
109  CALL ztrsm( 'Left', 'Lower', 'No transpose', 'Non-unit', m, nrhs,
110  $ cone, a, lda, b, ldb )
111 *
112 * Set B(m+1:n,:) to zero
113 *
114  IF( m.LT.n )
115  $ CALL zlaset( 'Full', n-m, nrhs, czero, czero, b( m+1, 1 ),
116  $ ldb )
117 *
118 * B := Q' * B
119 *
120  CALL zunmlq( 'Left', 'Conjugate transpose', n, nrhs, m, a, lda,
121  $ tau, b, ldb, work, lwork, info )
122 *
123  return
124 *
125 * End of ZGELQS
126 *
127  END