Refs #247. Included lapack source codes. Avoid downloading tar.gz from netlib.org
Based on 3.4.2 version, apply patch.for_lapack-3.4.2.
This commit is contained in:
289
lapack-netlib/SRC/dorglq.f
Normal file
289
lapack-netlib/SRC/dorglq.f
Normal file
@@ -0,0 +1,289 @@
|
||||
*> \brief \b DORGLQ
|
||||
*
|
||||
* =========== DOCUMENTATION ===========
|
||||
*
|
||||
* Online html documentation available at
|
||||
* http://www.netlib.org/lapack/explore-html/
|
||||
*
|
||||
*> \htmlonly
|
||||
*> Download DORGLQ + dependencies
|
||||
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorglq.f">
|
||||
*> [TGZ]</a>
|
||||
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorglq.f">
|
||||
*> [ZIP]</a>
|
||||
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorglq.f">
|
||||
*> [TXT]</a>
|
||||
*> \endhtmlonly
|
||||
*
|
||||
* Definition:
|
||||
* ===========
|
||||
*
|
||||
* SUBROUTINE DORGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
|
||||
*
|
||||
* .. Scalar Arguments ..
|
||||
* INTEGER INFO, K, LDA, LWORK, M, N
|
||||
* ..
|
||||
* .. Array Arguments ..
|
||||
* DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
|
||||
* ..
|
||||
*
|
||||
*
|
||||
*> \par Purpose:
|
||||
* =============
|
||||
*>
|
||||
*> \verbatim
|
||||
*>
|
||||
*> DORGLQ generates an M-by-N real matrix Q with orthonormal rows,
|
||||
*> which is defined as the first M rows of a product of K elementary
|
||||
*> reflectors of order N
|
||||
*>
|
||||
*> Q = H(k) . . . H(2) H(1)
|
||||
*>
|
||||
*> as returned by DGELQF.
|
||||
*> \endverbatim
|
||||
*
|
||||
* Arguments:
|
||||
* ==========
|
||||
*
|
||||
*> \param[in] M
|
||||
*> \verbatim
|
||||
*> M is INTEGER
|
||||
*> The number of rows of the matrix Q. M >= 0.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in] N
|
||||
*> \verbatim
|
||||
*> N is INTEGER
|
||||
*> The number of columns of the matrix Q. N >= M.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in] K
|
||||
*> \verbatim
|
||||
*> K is INTEGER
|
||||
*> The number of elementary reflectors whose product defines the
|
||||
*> matrix Q. M >= K >= 0.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in,out] A
|
||||
*> \verbatim
|
||||
*> A is DOUBLE PRECISION array, dimension (LDA,N)
|
||||
*> On entry, the i-th row must contain the vector which defines
|
||||
*> the elementary reflector H(i), for i = 1,2,...,k, as returned
|
||||
*> by DGELQF in the first k rows of its array argument A.
|
||||
*> On exit, the M-by-N matrix Q.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in] LDA
|
||||
*> \verbatim
|
||||
*> LDA is INTEGER
|
||||
*> The first dimension of the array A. LDA >= max(1,M).
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in] TAU
|
||||
*> \verbatim
|
||||
*> TAU is DOUBLE PRECISION array, dimension (K)
|
||||
*> TAU(i) must contain the scalar factor of the elementary
|
||||
*> reflector H(i), as returned by DGELQF.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[out] WORK
|
||||
*> \verbatim
|
||||
*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
|
||||
*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[in] LWORK
|
||||
*> \verbatim
|
||||
*> LWORK is INTEGER
|
||||
*> The dimension of the array WORK. LWORK >= max(1,M).
|
||||
*> For optimum performance LWORK >= M*NB, where NB is
|
||||
*> the optimal blocksize.
|
||||
*>
|
||||
*> If LWORK = -1, then a workspace query is assumed; the routine
|
||||
*> only calculates the optimal size of the WORK array, returns
|
||||
*> this value as the first entry of the WORK array, and no error
|
||||
*> message related to LWORK is issued by XERBLA.
|
||||
*> \endverbatim
|
||||
*>
|
||||
*> \param[out] INFO
|
||||
*> \verbatim
|
||||
*> INFO is INTEGER
|
||||
*> = 0: successful exit
|
||||
*> < 0: if INFO = -i, the i-th argument has an illegal value
|
||||
*> \endverbatim
|
||||
*
|
||||
* Authors:
|
||||
* ========
|
||||
*
|
||||
*> \author Univ. of Tennessee
|
||||
*> \author Univ. of California Berkeley
|
||||
*> \author Univ. of Colorado Denver
|
||||
*> \author NAG Ltd.
|
||||
*
|
||||
*> \date November 2011
|
||||
*
|
||||
*> \ingroup doubleOTHERcomputational
|
||||
*
|
||||
* =====================================================================
|
||||
SUBROUTINE DORGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
|
||||
*
|
||||
* -- LAPACK computational routine (version 3.4.0) --
|
||||
* -- LAPACK is a software package provided by Univ. of Tennessee, --
|
||||
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
||||
* November 2011
|
||||
*
|
||||
* .. Scalar Arguments ..
|
||||
INTEGER INFO, K, LDA, LWORK, M, N
|
||||
* ..
|
||||
* .. Array Arguments ..
|
||||
DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
|
||||
* ..
|
||||
*
|
||||
* =====================================================================
|
||||
*
|
||||
* .. Parameters ..
|
||||
DOUBLE PRECISION ZERO
|
||||
PARAMETER ( ZERO = 0.0D+0 )
|
||||
* ..
|
||||
* .. Local Scalars ..
|
||||
LOGICAL LQUERY
|
||||
INTEGER I, IB, IINFO, IWS, J, KI, KK, L, LDWORK,
|
||||
$ LWKOPT, NB, NBMIN, NX
|
||||
* ..
|
||||
* .. External Subroutines ..
|
||||
EXTERNAL DLARFB, DLARFT, DORGL2, XERBLA
|
||||
* ..
|
||||
* .. Intrinsic Functions ..
|
||||
INTRINSIC MAX, MIN
|
||||
* ..
|
||||
* .. External Functions ..
|
||||
INTEGER ILAENV
|
||||
EXTERNAL ILAENV
|
||||
* ..
|
||||
* .. Executable Statements ..
|
||||
*
|
||||
* Test the input arguments
|
||||
*
|
||||
INFO = 0
|
||||
NB = ILAENV( 1, 'DORGLQ', ' ', M, N, K, -1 )
|
||||
LWKOPT = MAX( 1, M )*NB
|
||||
WORK( 1 ) = LWKOPT
|
||||
LQUERY = ( LWORK.EQ.-1 )
|
||||
IF( M.LT.0 ) THEN
|
||||
INFO = -1
|
||||
ELSE IF( N.LT.M ) THEN
|
||||
INFO = -2
|
||||
ELSE IF( K.LT.0 .OR. K.GT.M ) THEN
|
||||
INFO = -3
|
||||
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
|
||||
INFO = -5
|
||||
ELSE IF( LWORK.LT.MAX( 1, M ) .AND. .NOT.LQUERY ) THEN
|
||||
INFO = -8
|
||||
END IF
|
||||
IF( INFO.NE.0 ) THEN
|
||||
CALL XERBLA( 'DORGLQ', -INFO )
|
||||
RETURN
|
||||
ELSE IF( LQUERY ) THEN
|
||||
RETURN
|
||||
END IF
|
||||
*
|
||||
* Quick return if possible
|
||||
*
|
||||
IF( M.LE.0 ) THEN
|
||||
WORK( 1 ) = 1
|
||||
RETURN
|
||||
END IF
|
||||
*
|
||||
NBMIN = 2
|
||||
NX = 0
|
||||
IWS = M
|
||||
IF( NB.GT.1 .AND. NB.LT.K ) THEN
|
||||
*
|
||||
* Determine when to cross over from blocked to unblocked code.
|
||||
*
|
||||
NX = MAX( 0, ILAENV( 3, 'DORGLQ', ' ', M, N, K, -1 ) )
|
||||
IF( NX.LT.K ) THEN
|
||||
*
|
||||
* Determine if workspace is large enough for blocked code.
|
||||
*
|
||||
LDWORK = M
|
||||
IWS = LDWORK*NB
|
||||
IF( LWORK.LT.IWS ) THEN
|
||||
*
|
||||
* Not enough workspace to use optimal NB: reduce NB and
|
||||
* determine the minimum value of NB.
|
||||
*
|
||||
NB = LWORK / LDWORK
|
||||
NBMIN = MAX( 2, ILAENV( 2, 'DORGLQ', ' ', M, N, K, -1 ) )
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
*
|
||||
IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
|
||||
*
|
||||
* Use blocked code after the last block.
|
||||
* The first kk rows are handled by the block method.
|
||||
*
|
||||
KI = ( ( K-NX-1 ) / NB )*NB
|
||||
KK = MIN( K, KI+NB )
|
||||
*
|
||||
* Set A(kk+1:m,1:kk) to zero.
|
||||
*
|
||||
DO 20 J = 1, KK
|
||||
DO 10 I = KK + 1, M
|
||||
A( I, J ) = ZERO
|
||||
10 CONTINUE
|
||||
20 CONTINUE
|
||||
ELSE
|
||||
KK = 0
|
||||
END IF
|
||||
*
|
||||
* Use unblocked code for the last or only block.
|
||||
*
|
||||
IF( KK.LT.M )
|
||||
$ CALL DORGL2( M-KK, N-KK, K-KK, A( KK+1, KK+1 ), LDA,
|
||||
$ TAU( KK+1 ), WORK, IINFO )
|
||||
*
|
||||
IF( KK.GT.0 ) THEN
|
||||
*
|
||||
* Use blocked code
|
||||
*
|
||||
DO 50 I = KI + 1, 1, -NB
|
||||
IB = MIN( NB, K-I+1 )
|
||||
IF( I+IB.LE.M ) THEN
|
||||
*
|
||||
* Form the triangular factor of the block reflector
|
||||
* H = H(i) H(i+1) . . . H(i+ib-1)
|
||||
*
|
||||
CALL DLARFT( 'Forward', 'Rowwise', N-I+1, IB, A( I, I ),
|
||||
$ LDA, TAU( I ), WORK, LDWORK )
|
||||
*
|
||||
* Apply H**T to A(i+ib:m,i:n) from the right
|
||||
*
|
||||
CALL DLARFB( 'Right', 'Transpose', 'Forward', 'Rowwise',
|
||||
$ M-I-IB+1, N-I+1, IB, A( I, I ), LDA, WORK,
|
||||
$ LDWORK, A( I+IB, I ), LDA, WORK( IB+1 ),
|
||||
$ LDWORK )
|
||||
END IF
|
||||
*
|
||||
* Apply H**T to columns i:n of current block
|
||||
*
|
||||
CALL DORGL2( IB, N-I+1, IB, A( I, I ), LDA, TAU( I ), WORK,
|
||||
$ IINFO )
|
||||
*
|
||||
* Set columns 1:i-1 of current block to zero
|
||||
*
|
||||
DO 40 J = 1, I - 1
|
||||
DO 30 L = I, I + IB - 1
|
||||
A( L, J ) = ZERO
|
||||
30 CONTINUE
|
||||
40 CONTINUE
|
||||
50 CONTINUE
|
||||
END IF
|
||||
*
|
||||
WORK( 1 ) = IWS
|
||||
RETURN
|
||||
*
|
||||
* End of DORGLQ
|
||||
*
|
||||
END
|
||||
Reference in New Issue
Block a user