LAPACK 3.3.1
Linear Algebra PACKage

cgerq2.f

Go to the documentation of this file.
00001       SUBROUTINE CGERQ2( M, N, A, LDA, TAU, WORK, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.3.1) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *  -- April 2011                                                      --
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INFO, LDA, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00013 *     ..
00014 *
00015 *  Purpose
00016 *  =======
00017 *
00018 *  CGERQ2 computes an RQ factorization of a complex 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) COMPLEX 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 unitary 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) COMPLEX array, dimension (min(M,N))
00044 *          The scalar factors of the elementary reflectors (see Further
00045 *          Details).
00046 *
00047 *  WORK    (workspace) COMPLEX 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 H(2)**H . . . H(k)**H, where k = min(m,n).
00059 *
00060 *  Each H(i) has the form
00061 *
00062 *     H(i) = I - tau * v * v**H
00063 *
00064 *  where tau is a complex scalar, and v is a complex vector with
00065 *  v(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on
00066 *  exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i).
00067 *
00068 *  =====================================================================
00069 *
00070 *     .. Parameters ..
00071       COMPLEX            ONE
00072       PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ) )
00073 *     ..
00074 *     .. Local Scalars ..
00075       INTEGER            I, K
00076       COMPLEX            ALPHA
00077 *     ..
00078 *     .. External Subroutines ..
00079       EXTERNAL           CLACGV, CLARF, CLARFG, 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( 'CGERQ2', -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 CLACGV( N-K+I, A( M-K+I, 1 ), LDA )
00109          ALPHA = A( M-K+I, N-K+I )
00110          CALL CLARFG( N-K+I, ALPHA, A( M-K+I, 1 ), LDA,
00111      $                TAU( I ) )
00112 *
00113 *        Apply H(i) to A(1:m-k+i-1,1:n-k+i) from the right
00114 *
00115          A( M-K+I, N-K+I ) = ONE
00116          CALL CLARF( 'Right', M-K+I-1, N-K+I, A( M-K+I, 1 ), LDA,
00117      $               TAU( I ), A, LDA, WORK )
00118          A( M-K+I, N-K+I ) = ALPHA
00119          CALL CLACGV( N-K+I-1, A( M-K+I, 1 ), LDA )
00120    10 CONTINUE
00121       RETURN
00122 *
00123 *     End of CGERQ2
00124 *
00125       END
 All Files Functions