LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgerqs.f
Go to the documentation of this file.
00001 *> \brief \b SGERQS
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE SGERQS( M, N, NRHS, A, LDA, TAU, B, LDB, WORK, LWORK,
00012 *                          INFO )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       REAL               A( LDA, * ), B( LDB, * ), TAU( * ),
00019 *      $                   WORK( LWORK )
00020 *       ..
00021 *  
00022 *
00023 *> \par Purpose:
00024 *  =============
00025 *>
00026 *> \verbatim
00027 *>
00028 *> Compute a minimum-norm solution
00029 *>     min || A*X - B ||
00030 *> using the RQ factorization
00031 *>     A = R*Q
00032 *> computed by SGERQF.
00033 *> \endverbatim
00034 *
00035 *  Arguments:
00036 *  ==========
00037 *
00038 *> \param[in] M
00039 *> \verbatim
00040 *>          M is INTEGER
00041 *>          The number of rows of the matrix A.  M >= 0.
00042 *> \endverbatim
00043 *>
00044 *> \param[in] N
00045 *> \verbatim
00046 *>          N is INTEGER
00047 *>          The number of columns of the matrix A.  N >= M >= 0.
00048 *> \endverbatim
00049 *>
00050 *> \param[in] NRHS
00051 *> \verbatim
00052 *>          NRHS is INTEGER
00053 *>          The number of columns of B.  NRHS >= 0.
00054 *> \endverbatim
00055 *>
00056 *> \param[in] A
00057 *> \verbatim
00058 *>          A is REAL array, dimension (LDA,N)
00059 *>          Details of the RQ factorization of the original matrix A as
00060 *>          returned by SGERQF.
00061 *> \endverbatim
00062 *>
00063 *> \param[in] LDA
00064 *> \verbatim
00065 *>          LDA is INTEGER
00066 *>          The leading dimension of the array A.  LDA >= M.
00067 *> \endverbatim
00068 *>
00069 *> \param[in] TAU
00070 *> \verbatim
00071 *>          TAU is REAL array, dimension (M)
00072 *>          Details of the orthogonal matrix Q.
00073 *> \endverbatim
00074 *>
00075 *> \param[in,out] B
00076 *> \verbatim
00077 *>          B is REAL array, dimension (LDB,NRHS)
00078 *>          On entry, the right hand side vectors for the linear system.
00079 *>          On exit, the solution vectors X.  Each solution vector
00080 *>          is contained in rows 1:N of a column of B.
00081 *> \endverbatim
00082 *>
00083 *> \param[in] LDB
00084 *> \verbatim
00085 *>          LDB is INTEGER
00086 *>          The leading dimension of the array B. LDB >= max(1,N).
00087 *> \endverbatim
00088 *>
00089 *> \param[out] WORK
00090 *> \verbatim
00091 *>          WORK is REAL array, dimension (LWORK)
00092 *> \endverbatim
00093 *>
00094 *> \param[in] LWORK
00095 *> \verbatim
00096 *>          LWORK is INTEGER
00097 *>          The length of the array WORK.  LWORK must be at least NRHS,
00098 *>          and should be at least NRHS*NB, where NB is the block size
00099 *>          for this environment.
00100 *> \endverbatim
00101 *>
00102 *> \param[out] INFO
00103 *> \verbatim
00104 *>          INFO is INTEGER
00105 *>          = 0: successful exit
00106 *>          < 0: if INFO = -i, the i-th argument had an illegal value
00107 *> \endverbatim
00108 *
00109 *  Authors:
00110 *  ========
00111 *
00112 *> \author Univ. of Tennessee 
00113 *> \author Univ. of California Berkeley 
00114 *> \author Univ. of Colorado Denver 
00115 *> \author NAG Ltd. 
00116 *
00117 *> \date November 2011
00118 *
00119 *> \ingroup single_lin
00120 *
00121 *  =====================================================================
00122       SUBROUTINE SGERQS( M, N, NRHS, A, LDA, TAU, B, LDB, WORK, LWORK,
00123      $                   INFO )
00124 *
00125 *  -- LAPACK test routine (version 3.4.0) --
00126 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00127 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00128 *     November 2011
00129 *
00130 *     .. Scalar Arguments ..
00131       INTEGER            INFO, LDA, LDB, LWORK, M, N, NRHS
00132 *     ..
00133 *     .. Array Arguments ..
00134       REAL               A( LDA, * ), B( LDB, * ), TAU( * ),
00135      $                   WORK( LWORK )
00136 *     ..
00137 *
00138 *  =====================================================================
00139 *
00140 *     .. Parameters ..
00141       REAL               ZERO, ONE
00142       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00143 *     ..
00144 *     .. External Subroutines ..
00145       EXTERNAL           SLASET, SORMRQ, STRSM, XERBLA
00146 *     ..
00147 *     .. Intrinsic Functions ..
00148       INTRINSIC          MAX
00149 *     ..
00150 *     .. Executable Statements ..
00151 *
00152 *     Test the input parameters.
00153 *
00154       INFO = 0
00155       IF( M.LT.0 ) THEN
00156          INFO = -1
00157       ELSE IF( N.LT.0 .OR. M.GT.N ) THEN
00158          INFO = -2
00159       ELSE IF( NRHS.LT.0 ) THEN
00160          INFO = -3
00161       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00162          INFO = -5
00163       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00164          INFO = -8
00165       ELSE IF( LWORK.LT.1 .OR. LWORK.LT.NRHS .AND. M.GT.0 .AND. N.GT.0 )
00166      $          THEN
00167          INFO = -10
00168       END IF
00169       IF( INFO.NE.0 ) THEN
00170          CALL XERBLA( 'SGERQS', -INFO )
00171          RETURN
00172       END IF
00173 *
00174 *     Quick return if possible
00175 *
00176       IF( N.EQ.0 .OR. NRHS.EQ.0 .OR. M.EQ.0 )
00177      $   RETURN
00178 *
00179 *     Solve R*X = B(n-m+1:n,:)
00180 *
00181       CALL STRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', M, NRHS,
00182      $            ONE, A( 1, N-M+1 ), LDA, B( N-M+1, 1 ), LDB )
00183 *
00184 *     Set B(1:n-m,:) to zero
00185 *
00186       CALL SLASET( 'Full', N-M, NRHS, ZERO, ZERO, B, LDB )
00187 *
00188 *     B := Q' * B
00189 *
00190       CALL SORMRQ( 'Left', 'Transpose', N, NRHS, M, A, LDA, TAU, B, LDB,
00191      $             WORK, LWORK, INFO )
00192 *
00193       RETURN
00194 *
00195 *     End of SGERQS
00196 *
00197       END
 All Files Functions