LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sorgl2.f
Go to the documentation of this file.
00001 *> \brief \b SORGL2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SORGL2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorgl2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorgl2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorgl2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SORGL2( M, N, K, A, LDA, TAU, WORK, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INFO, K, LDA, M, N
00025 *       ..
00026 *       .. Array Arguments ..
00027 *       REAL               A( LDA, * ), TAU( * ), WORK( * )
00028 *       ..
00029 *  
00030 *
00031 *> \par Purpose:
00032 *  =============
00033 *>
00034 *> \verbatim
00035 *>
00036 *> SORGL2 generates an m by n real matrix Q with orthonormal rows,
00037 *> which is defined as the first m rows of a product of k elementary
00038 *> reflectors of order n
00039 *>
00040 *>       Q  =  H(k) . . . H(2) H(1)
00041 *>
00042 *> as returned by SGELQF.
00043 *> \endverbatim
00044 *
00045 *  Arguments:
00046 *  ==========
00047 *
00048 *> \param[in] M
00049 *> \verbatim
00050 *>          M is INTEGER
00051 *>          The number of rows of the matrix Q. M >= 0.
00052 *> \endverbatim
00053 *>
00054 *> \param[in] N
00055 *> \verbatim
00056 *>          N is INTEGER
00057 *>          The number of columns of the matrix Q. N >= M.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] K
00061 *> \verbatim
00062 *>          K is INTEGER
00063 *>          The number of elementary reflectors whose product defines the
00064 *>          matrix Q. M >= K >= 0.
00065 *> \endverbatim
00066 *>
00067 *> \param[in,out] A
00068 *> \verbatim
00069 *>          A is REAL array, dimension (LDA,N)
00070 *>          On entry, the i-th row must contain the vector which defines
00071 *>          the elementary reflector H(i), for i = 1,2,...,k, as returned
00072 *>          by SGELQF in the first k rows of its array argument A.
00073 *>          On exit, the m-by-n matrix Q.
00074 *> \endverbatim
00075 *>
00076 *> \param[in] LDA
00077 *> \verbatim
00078 *>          LDA is INTEGER
00079 *>          The first dimension of the array A. LDA >= max(1,M).
00080 *> \endverbatim
00081 *>
00082 *> \param[in] TAU
00083 *> \verbatim
00084 *>          TAU is REAL array, dimension (K)
00085 *>          TAU(i) must contain the scalar factor of the elementary
00086 *>          reflector H(i), as returned by SGELQF.
00087 *> \endverbatim
00088 *>
00089 *> \param[out] WORK
00090 *> \verbatim
00091 *>          WORK is REAL array, dimension (M)
00092 *> \endverbatim
00093 *>
00094 *> \param[out] INFO
00095 *> \verbatim
00096 *>          INFO is INTEGER
00097 *>          = 0: successful exit
00098 *>          < 0: if INFO = -i, the i-th argument has an illegal value
00099 *> \endverbatim
00100 *
00101 *  Authors:
00102 *  ========
00103 *
00104 *> \author Univ. of Tennessee 
00105 *> \author Univ. of California Berkeley 
00106 *> \author Univ. of Colorado Denver 
00107 *> \author NAG Ltd. 
00108 *
00109 *> \date November 2011
00110 *
00111 *> \ingroup realOTHERcomputational
00112 *
00113 *  =====================================================================
00114       SUBROUTINE SORGL2( M, N, K, A, LDA, TAU, WORK, INFO )
00115 *
00116 *  -- LAPACK computational routine (version 3.4.0) --
00117 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00118 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00119 *     November 2011
00120 *
00121 *     .. Scalar Arguments ..
00122       INTEGER            INFO, K, LDA, M, N
00123 *     ..
00124 *     .. Array Arguments ..
00125       REAL               A( LDA, * ), TAU( * ), WORK( * )
00126 *     ..
00127 *
00128 *  =====================================================================
00129 *
00130 *     .. Parameters ..
00131       REAL               ONE, ZERO
00132       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00133 *     ..
00134 *     .. Local Scalars ..
00135       INTEGER            I, J, L
00136 *     ..
00137 *     .. External Subroutines ..
00138       EXTERNAL           SLARF, SSCAL, XERBLA
00139 *     ..
00140 *     .. Intrinsic Functions ..
00141       INTRINSIC          MAX
00142 *     ..
00143 *     .. Executable Statements ..
00144 *
00145 *     Test the input arguments
00146 *
00147       INFO = 0
00148       IF( M.LT.0 ) THEN
00149          INFO = -1
00150       ELSE IF( N.LT.M ) THEN
00151          INFO = -2
00152       ELSE IF( K.LT.0 .OR. K.GT.M ) THEN
00153          INFO = -3
00154       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00155          INFO = -5
00156       END IF
00157       IF( INFO.NE.0 ) THEN
00158          CALL XERBLA( 'SORGL2', -INFO )
00159          RETURN
00160       END IF
00161 *
00162 *     Quick return if possible
00163 *
00164       IF( M.LE.0 )
00165      $   RETURN
00166 *
00167       IF( K.LT.M ) THEN
00168 *
00169 *        Initialise rows k+1:m to rows of the unit matrix
00170 *
00171          DO 20 J = 1, N
00172             DO 10 L = K + 1, M
00173                A( L, J ) = ZERO
00174    10       CONTINUE
00175             IF( J.GT.K .AND. J.LE.M )
00176      $         A( J, J ) = ONE
00177    20    CONTINUE
00178       END IF
00179 *
00180       DO 40 I = K, 1, -1
00181 *
00182 *        Apply H(i) to A(i:m,i:n) from the right
00183 *
00184          IF( I.LT.N ) THEN
00185             IF( I.LT.M ) THEN
00186                A( I, I ) = ONE
00187                CALL SLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
00188      $                     TAU( I ), A( I+1, I ), LDA, WORK )
00189             END IF
00190             CALL SSCAL( N-I, -TAU( I ), A( I, I+1 ), LDA )
00191          END IF
00192          A( I, I ) = ONE - TAU( I )
00193 *
00194 *        Set A(i,1:i-1) to zero
00195 *
00196          DO 30 L = 1, I - 1
00197             A( I, L ) = ZERO
00198    30    CONTINUE
00199    40 CONTINUE
00200       RETURN
00201 *
00202 *     End of SORGL2
00203 *
00204       END
 All Files Functions