LAPACK 3.3.1
Linear Algebra PACKage

cgerqs.f

Go to the documentation of this file.
00001       SUBROUTINE CGERQS( 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 *  Compute a minimum-norm solution
00020 *      min || A*X - B ||
00021 *  using the RQ factorization
00022 *      A = R*Q
00023 *  computed by CGERQF.
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.  N >= M >= 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 RQ factorization of the original matrix A as
00039 *          returned by CGERQF.
00040 *
00041 *  LDA     (input) INTEGER
00042 *          The leading dimension of the array A.  LDA >= M.
00043 *
00044 *  TAU     (input) COMPLEX array, dimension (M)
00045 *          Details of the orthogonal matrix Q.
00046 *
00047 *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
00048 *          On entry, the right hand side vectors for the linear system.
00049 *          On exit, the solution vectors X.  Each solution vector
00050 *          is contained in rows 1:N of a column of B.
00051 *
00052 *  LDB     (input) INTEGER
00053 *          The leading dimension of the array B. LDB >= max(1,N).
00054 *
00055 *  WORK    (workspace) COMPLEX array, dimension (LWORK)
00056 *
00057 *  LWORK   (input) INTEGER
00058 *          The length of the array WORK.  LWORK must be at least NRHS,
00059 *          and should be at least NRHS*NB, where NB is the block size
00060 *          for this environment.
00061 *
00062 *  INFO    (output) INTEGER
00063 *          = 0: successful exit
00064 *          < 0: if INFO = -i, the i-th argument had an illegal value
00065 *
00066 *  =====================================================================
00067 *
00068 *     .. Parameters ..
00069       COMPLEX            CZERO, CONE
00070       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00071      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00072 *     ..
00073 *     .. External Subroutines ..
00074       EXTERNAL           CLASET, CTRSM, CUNMRQ, XERBLA
00075 *     ..
00076 *     .. Intrinsic Functions ..
00077       INTRINSIC          MAX
00078 *     ..
00079 *     .. Executable Statements ..
00080 *
00081 *     Test the input parameters.
00082 *
00083       INFO = 0
00084       IF( M.LT.0 ) THEN
00085          INFO = -1
00086       ELSE IF( N.LT.0 .OR. M.GT.N ) THEN
00087          INFO = -2
00088       ELSE IF( NRHS.LT.0 ) THEN
00089          INFO = -3
00090       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00091          INFO = -5
00092       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00093          INFO = -8
00094       ELSE IF( LWORK.LT.1 .OR. LWORK.LT.NRHS .AND. M.GT.0 .AND. N.GT.0 )
00095      $          THEN
00096          INFO = -10
00097       END IF
00098       IF( INFO.NE.0 ) THEN
00099          CALL XERBLA( 'CGERQS', -INFO )
00100          RETURN
00101       END IF
00102 *
00103 *     Quick return if possible
00104 *
00105       IF( N.EQ.0 .OR. NRHS.EQ.0 .OR. M.EQ.0 )
00106      $   RETURN
00107 *
00108 *     Solve R*X = B(n-m+1:n,:)
00109 *
00110       CALL CTRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', M, NRHS,
00111      $            CONE, A( 1, N-M+1 ), LDA, B( N-M+1, 1 ), LDB )
00112 *
00113 *     Set B(1:n-m,:) to zero
00114 *
00115       CALL CLASET( 'Full', N-M, NRHS, CZERO, CZERO, B, LDB )
00116 *
00117 *     B := Q' * B
00118 *
00119       CALL CUNMRQ( 'Left', 'Conjugate transpose', N, NRHS, M, A, LDA,
00120      $             TAU, B, LDB, WORK, LWORK, INFO )
00121 *
00122       RETURN
00123 *
00124 *     End of CGERQS
00125 *
00126       END
 All Files Functions