LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
cgelqf.f
Go to the documentation of this file.
00001 *> \brief \b CGELQF
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CGELQF + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelqf.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelqf.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelqf.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, LDA, LWORK, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00028 *       ..
00029 *  
00030 *
00031 *> \par Purpose:
00032 *  =============
00033 *>
00034 *> \verbatim
00035 *>
00036 *> CGELQF computes an LQ factorization of a complex M-by-N matrix A:
00037 *> A = L * Q.
00038 *> \endverbatim
00039 *
00040 *  Arguments:
00041 *  ==========
00042 *
00043 *> \param[in] M
00044 *> \verbatim
00045 *>          M is INTEGER
00046 *>          The number of rows of the matrix A.  M >= 0.
00047 *> \endverbatim
00048 *>
00049 *> \param[in] N
00050 *> \verbatim
00051 *>          N is INTEGER
00052 *>          The number of columns of the matrix A.  N >= 0.
00053 *> \endverbatim
00054 *>
00055 *> \param[in,out] A
00056 *> \verbatim
00057 *>          A is COMPLEX array, dimension (LDA,N)
00058 *>          On entry, the M-by-N matrix A.
00059 *>          On exit, the elements on and below the diagonal of the array
00060 *>          contain the m-by-min(m,n) lower trapezoidal matrix L (L is
00061 *>          lower triangular if m <= n); the elements above the diagonal,
00062 *>          with the array TAU, represent the unitary matrix Q as a
00063 *>          product of elementary reflectors (see Further Details).
00064 *> \endverbatim
00065 *>
00066 *> \param[in] LDA
00067 *> \verbatim
00068 *>          LDA is INTEGER
00069 *>          The leading dimension of the array A.  LDA >= max(1,M).
00070 *> \endverbatim
00071 *>
00072 *> \param[out] TAU
00073 *> \verbatim
00074 *>          TAU is COMPLEX array, dimension (min(M,N))
00075 *>          The scalar factors of the elementary reflectors (see Further
00076 *>          Details).
00077 *> \endverbatim
00078 *>
00079 *> \param[out] WORK
00080 *> \verbatim
00081 *>          WORK is COMPLEX array, dimension (MAX(1,LWORK))
00082 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00083 *> \endverbatim
00084 *>
00085 *> \param[in] LWORK
00086 *> \verbatim
00087 *>          LWORK is INTEGER
00088 *>          The dimension of the array WORK.  LWORK >= max(1,M).
00089 *>          For optimum performance LWORK >= M*NB, where NB is the
00090 *>          optimal blocksize.
00091 *>
00092 *>          If LWORK = -1, then a workspace query is assumed; the routine
00093 *>          only calculates the optimal size of the WORK array, returns
00094 *>          this value as the first entry of the WORK array, and no error
00095 *>          message related to LWORK is issued by XERBLA.
00096 *> \endverbatim
00097 *>
00098 *> \param[out] INFO
00099 *> \verbatim
00100 *>          INFO is INTEGER
00101 *>          = 0:  successful exit
00102 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00103 *> \endverbatim
00104 *
00105 *  Authors:
00106 *  ========
00107 *
00108 *> \author Univ. of Tennessee 
00109 *> \author Univ. of California Berkeley 
00110 *> \author Univ. of Colorado Denver 
00111 *> \author NAG Ltd. 
00112 *
00113 *> \date November 2011
00114 *
00115 *> \ingroup complexGEcomputational
00116 *
00117 *> \par Further Details:
00118 *  =====================
00119 *>
00120 *> \verbatim
00121 *>
00122 *>  The matrix Q is represented as a product of elementary reflectors
00123 *>
00124 *>     Q = H(k)**H . . . H(2)**H H(1)**H, where k = min(m,n).
00125 *>
00126 *>  Each H(i) has the form
00127 *>
00128 *>     H(i) = I - tau * v * v**H
00129 *>
00130 *>  where tau is a complex scalar, and v is a complex vector with
00131 *>  v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in
00132 *>  A(i,i+1:n), and tau in TAU(i).
00133 *> \endverbatim
00134 *>
00135 *  =====================================================================
00136       SUBROUTINE CGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
00137 *
00138 *  -- LAPACK computational routine (version 3.4.0) --
00139 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00140 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00141 *     November 2011
00142 *
00143 *     .. Scalar Arguments ..
00144       INTEGER            INFO, LDA, LWORK, M, N
00145 *     ..
00146 *     .. Array Arguments ..
00147       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
00148 *     ..
00149 *
00150 *  =====================================================================
00151 *
00152 *     .. Local Scalars ..
00153       LOGICAL            LQUERY
00154       INTEGER            I, IB, IINFO, IWS, K, LDWORK, LWKOPT, NB,
00155      $                   NBMIN, NX
00156 *     ..
00157 *     .. External Subroutines ..
00158       EXTERNAL           CGELQ2, CLARFB, CLARFT, XERBLA
00159 *     ..
00160 *     .. Intrinsic Functions ..
00161       INTRINSIC          MAX, MIN
00162 *     ..
00163 *     .. External Functions ..
00164       INTEGER            ILAENV
00165       EXTERNAL           ILAENV
00166 *     ..
00167 *     .. Executable Statements ..
00168 *
00169 *     Test the input arguments
00170 *
00171       INFO = 0
00172       NB = ILAENV( 1, 'CGELQF', ' ', M, N, -1, -1 )
00173       LWKOPT = M*NB
00174       WORK( 1 ) = LWKOPT
00175       LQUERY = ( LWORK.EQ.-1 )
00176       IF( M.LT.0 ) THEN
00177          INFO = -1
00178       ELSE IF( N.LT.0 ) THEN
00179          INFO = -2
00180       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00181          INFO = -4
00182       ELSE IF( LWORK.LT.MAX( 1, M ) .AND. .NOT.LQUERY ) THEN
00183          INFO = -7
00184       END IF
00185       IF( INFO.NE.0 ) THEN
00186          CALL XERBLA( 'CGELQF', -INFO )
00187          RETURN
00188       ELSE IF( LQUERY ) THEN
00189          RETURN
00190       END IF
00191 *
00192 *     Quick return if possible
00193 *
00194       K = MIN( M, N )
00195       IF( K.EQ.0 ) THEN
00196          WORK( 1 ) = 1
00197          RETURN
00198       END IF
00199 *
00200       NBMIN = 2
00201       NX = 0
00202       IWS = M
00203       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00204 *
00205 *        Determine when to cross over from blocked to unblocked code.
00206 *
00207          NX = MAX( 0, ILAENV( 3, 'CGELQF', ' ', M, N, -1, -1 ) )
00208          IF( NX.LT.K ) THEN
00209 *
00210 *           Determine if workspace is large enough for blocked code.
00211 *
00212             LDWORK = M
00213             IWS = LDWORK*NB
00214             IF( LWORK.LT.IWS ) THEN
00215 *
00216 *              Not enough workspace to use optimal NB:  reduce NB and
00217 *              determine the minimum value of NB.
00218 *
00219                NB = LWORK / LDWORK
00220                NBMIN = MAX( 2, ILAENV( 2, 'CGELQF', ' ', M, N, -1,
00221      $                 -1 ) )
00222             END IF
00223          END IF
00224       END IF
00225 *
00226       IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
00227 *
00228 *        Use blocked code initially
00229 *
00230          DO 10 I = 1, K - NX, NB
00231             IB = MIN( K-I+1, NB )
00232 *
00233 *           Compute the LQ factorization of the current block
00234 *           A(i:i+ib-1,i:n)
00235 *
00236             CALL CGELQ2( IB, N-I+1, A( I, I ), LDA, TAU( I ), WORK,
00237      $                   IINFO )
00238             IF( I+IB.LE.M ) THEN
00239 *
00240 *              Form the triangular factor of the block reflector
00241 *              H = H(i) H(i+1) . . . H(i+ib-1)
00242 *
00243                CALL CLARFT( 'Forward', 'Rowwise', N-I+1, IB, A( I, I ),
00244      $                      LDA, TAU( I ), WORK, LDWORK )
00245 *
00246 *              Apply H to A(i+ib:m,i:n) from the right
00247 *
00248                CALL CLARFB( 'Right', 'No transpose', 'Forward',
00249      $                      'Rowwise', M-I-IB+1, N-I+1, IB, A( I, I ),
00250      $                      LDA, WORK, LDWORK, A( I+IB, I ), LDA,
00251      $                      WORK( IB+1 ), LDWORK )
00252             END IF
00253    10    CONTINUE
00254       ELSE
00255          I = 1
00256       END IF
00257 *
00258 *     Use unblocked code to factor the last or only block.
00259 *
00260       IF( I.LE.K )
00261      $   CALL CGELQ2( M-I+1, N-I+1, A( I, I ), LDA, TAU( I ), WORK,
00262      $                IINFO )
00263 *
00264       WORK( 1 ) = IWS
00265       RETURN
00266 *
00267 *     End of CGELQF
00268 *
00269       END
 All Files Functions