LAPACK 3.3.1
Linear Algebra PACKage

cgeqrs.f

Go to the documentation of this file.
00001       SUBROUTINE CGEQRS( M, N, NRHS, A, LDA, TAU, B, LDB, WORK, LWORK,
00002      $                   INFO )
00003 *
00004 *  -- LAPACK routine (version 3.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS
00010 *     ..
00011 *     .. Array Arguments ..
00012       COMPLEX            A( LDA, * ), B( LDB, * ), TAU( * ),
00013      $                   WORK( LWORK )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  Solve the least squares problem
00020 *      min || A*X - B ||
00021 *  using the QR factorization
00022 *      A = Q*R
00023 *  computed by CGEQRF.
00024 *
00025 *  Arguments
00026 *  =========
00027 *
00028 *  M       (input) INTEGER
00029 *          The number of rows of the matrix A.  M >= 0.
00030 *
00031 *  N       (input) INTEGER
00032 *          The number of columns of the matrix A.  M >= N >= 0.
00033 *
00034 *  NRHS    (input) INTEGER
00035 *          The number of columns of B.  NRHS >= 0.
00036 *
00037 *  A       (input) COMPLEX array, dimension (LDA,N)
00038 *          Details of the QR factorization of the original matrix A as
00039 *          returned by CGEQRF.
00040 *
00041 *  LDA     (input) INTEGER
00042 *          The leading dimension of the array A.  LDA >= M.
00043 *
00044 *  TAU     (input) COMPLEX array, dimension (N)
00045 *          Details of the orthogonal matrix Q.
00046 *
00047 *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
00048 *          On entry, the m-by-nrhs right hand side matrix B.
00049 *          On exit, the n-by-nrhs solution matrix X.
00050 *
00051 *  LDB     (input) INTEGER
00052 *          The leading dimension of the array B. LDB >= M.
00053 *
00054 *  WORK    (workspace) COMPLEX array, dimension (LWORK)
00055 *
00056 *  LWORK   (input) INTEGER
00057 *          The length of the array WORK.  LWORK must be at least NRHS,
00058 *          and should be at least NRHS*NB, where NB is the block size
00059 *          for this environment.
00060 *
00061 *  INFO    (output) INTEGER
00062 *          = 0: successful exit
00063 *          < 0: if INFO = -i, the i-th argument had an illegal value
00064 *
00065 *  =====================================================================
00066 *
00067 *     .. Parameters ..
00068       COMPLEX            ONE
00069       PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ) )
00070 *     ..
00071 *     .. External Subroutines ..
00072       EXTERNAL           CTRSM, CUNMQR, XERBLA
00073 *     ..
00074 *     .. Intrinsic Functions ..
00075       INTRINSIC          MAX
00076 *     ..
00077 *     .. Executable Statements ..
00078 *
00079 *     Test the input arguments.
00080 *
00081       INFO = 0
00082       IF( M.LT.0 ) THEN
00083          INFO = -1
00084       ELSE IF( N.LT.0 .OR. N.GT.M ) THEN
00085          INFO = -2
00086       ELSE IF( NRHS.LT.0 ) THEN
00087          INFO = -3
00088       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00089          INFO = -5
00090       ELSE IF( LDB.LT.MAX( 1, M ) ) THEN
00091          INFO = -8
00092       ELSE IF( LWORK.LT.1 .OR. LWORK.LT.NRHS .AND. M.GT.0 .AND. N.GT.0 )
00093      $          THEN
00094          INFO = -10
00095       END IF
00096       IF( INFO.NE.0 ) THEN
00097          CALL XERBLA( 'CGEQRS', -INFO )
00098          RETURN
00099       END IF
00100 *
00101 *     Quick return if possible
00102 *
00103       IF( N.EQ.0 .OR. NRHS.EQ.0 .OR. M.EQ.0 )
00104      $   RETURN
00105 *
00106 *     B := Q' * B
00107 *
00108       CALL CUNMQR( 'Left', 'Conjugate transpose', M, NRHS, N, A, LDA,
00109      $             TAU, B, LDB, WORK, LWORK, INFO )
00110 *
00111 *     Solve R*X = B(1:n,:)
00112 *
00113       CALL CTRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N, NRHS,
00114      $            ONE, A, LDA, B, LDB )
00115 *
00116       RETURN
00117 *
00118 *     End of CGEQRS
00119 *
00120       END
 All Files Functions