LAPACK 3.3.0

zgerq2.f

Go to the documentation of this file.
00001       SUBROUTINE ZGERQ2( 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       COMPLEX*16         A( LDA, * ), TAU( * ), WORK( * )
00013 *     ..
00014 *
00015 *  Purpose
00016 *  =======
00017 *
00018 *  ZGERQ2 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*16 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*16 array, dimension (min(M,N))
00044 *          The scalar factors of the elementary reflectors (see Further
00045 *          Details).
00046 *
00047 *  WORK    (workspace) COMPLEX*16 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 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*16         ONE
00072       PARAMETER          ( ONE = ( 1.0D+0, 0.0D+0 ) )
00073 *     ..
00074 *     .. Local Scalars ..
00075       INTEGER            I, K
00076       COMPLEX*16         ALPHA
00077 *     ..
00078 *     .. External Subroutines ..
00079       EXTERNAL           XERBLA, ZLACGV, ZLARF, ZLARFG
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( 'ZGERQ2', -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 ZLACGV( N-K+I, A( M-K+I, 1 ), LDA )
00109          ALPHA = A( M-K+I, N-K+I )
00110          CALL ZLARFG( N-K+I, ALPHA, A( M-K+I, 1 ), LDA, TAU( I ) )
00111 *
00112 *        Apply H(i) to A(1:m-k+i-1,1:n-k+i) from the right
00113 *
00114          A( M-K+I, N-K+I ) = ONE
00115          CALL ZLARF( '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 ) = ALPHA
00118          CALL ZLACGV( N-K+I-1, A( M-K+I, 1 ), LDA )
00119    10 CONTINUE
00120       RETURN
00121 *
00122 *     End of ZGERQ2
00123 *
00124       END
 All Files Functions