LAPACK 3.3.0

dgerq2.f

Go to the documentation of this file.
00001       SUBROUTINE DGERQ2( M, N, A, LDA, TAU, WORK, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.2.2) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *     June 2010
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INFO, LDA, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
00013 *     ..
00014 *
00015 *  Purpose
00016 *  =======
00017 *
00018 *  DGERQ2 computes an RQ factorization of a real m by n matrix A:
00019 *  A = R * Q.
00020 *
00021 *  Arguments
00022 *  =========
00023 *
00024 *  M       (input) INTEGER
00025 *          The number of rows of the matrix A.  M >= 0.
00026 *
00027 *  N       (input) INTEGER
00028 *          The number of columns of the matrix A.  N >= 0.
00029 *
00030 *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
00031 *          On entry, the m by n matrix A.
00032 *          On exit, if m <= n, the upper triangle of the subarray
00033 *          A(1:m,n-m+1:n) contains the m by m upper triangular matrix R;
00034 *          if m >= n, the elements on and above the (m-n)-th subdiagonal
00035 *          contain the m by n upper trapezoidal matrix R; the remaining
00036 *          elements, with the array TAU, represent the orthogonal matrix
00037 *          Q as a product of elementary reflectors (see Further
00038 *          Details).
00039 *
00040 *  LDA     (input) INTEGER
00041 *          The leading dimension of the array A.  LDA >= max(1,M).
00042 *
00043 *  TAU     (output) DOUBLE PRECISION array, dimension (min(M,N))
00044 *          The scalar factors of the elementary reflectors (see Further
00045 *          Details).
00046 *
00047 *  WORK    (workspace) DOUBLE PRECISION array, dimension (M)
00048 *
00049 *  INFO    (output) INTEGER
00050 *          = 0: successful exit
00051 *          < 0: if INFO = -i, the i-th argument had an illegal value
00052 *
00053 *  Further Details
00054 *  ===============
00055 *
00056 *  The matrix Q is represented as a product of elementary reflectors
00057 *
00058 *     Q = H(1) H(2) . . . H(k), where k = min(m,n).
00059 *
00060 *  Each H(i) has the form
00061 *
00062 *     H(i) = I - tau * v * v'
00063 *
00064 *  where tau is a real scalar, and v is a real vector with
00065 *  v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
00066 *  A(m-k+i,1:n-k+i-1), and tau in TAU(i).
00067 *
00068 *  =====================================================================
00069 *
00070 *     .. Parameters ..
00071       DOUBLE PRECISION   ONE
00072       PARAMETER          ( ONE = 1.0D+0 )
00073 *     ..
00074 *     .. Local Scalars ..
00075       INTEGER            I, K
00076       DOUBLE PRECISION   AII
00077 *     ..
00078 *     .. External Subroutines ..
00079       EXTERNAL           DLARF, DLARFG, XERBLA
00080 *     ..
00081 *     .. Intrinsic Functions ..
00082       INTRINSIC          MAX, MIN
00083 *     ..
00084 *     .. Executable Statements ..
00085 *
00086 *     Test the input arguments
00087 *
00088       INFO = 0
00089       IF( M.LT.0 ) THEN
00090          INFO = -1
00091       ELSE IF( N.LT.0 ) THEN
00092          INFO = -2
00093       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00094          INFO = -4
00095       END IF
00096       IF( INFO.NE.0 ) THEN
00097          CALL XERBLA( 'DGERQ2', -INFO )
00098          RETURN
00099       END IF
00100 *
00101       K = MIN( M, N )
00102 *
00103       DO 10 I = K, 1, -1
00104 *
00105 *        Generate elementary reflector H(i) to annihilate
00106 *        A(m-k+i,1:n-k+i-1)
00107 *
00108          CALL DLARFG( N-K+I, A( M-K+I, N-K+I ), A( M-K+I, 1 ), LDA,
00109      $                TAU( I ) )
00110 *
00111 *        Apply H(i) to A(1:m-k+i-1,1:n-k+i) from the right
00112 *
00113          AII = A( M-K+I, N-K+I )
00114          A( M-K+I, N-K+I ) = ONE
00115          CALL DLARF( 'Right', M-K+I-1, N-K+I, A( M-K+I, 1 ), LDA,
00116      $               TAU( I ), A, LDA, WORK )
00117          A( M-K+I, N-K+I ) = AII
00118    10 CONTINUE
00119       RETURN
00120 *
00121 *     End of DGERQ2
00122 *
00123       END
 All Files Functions