Annotation of rpl/lapack/lapack/dorgl2.f, revision 1.7

1.1       bertrand    1:       SUBROUTINE DORGL2( M, N, K, A, LDA, TAU, WORK, INFO )
                      2: *
                      3: *  -- LAPACK routine (version 3.2) --
                      4: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                      5: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                      6: *     November 2006
                      7: *
                      8: *     .. Scalar Arguments ..
                      9:       INTEGER            INFO, K, LDA, M, N
                     10: *     ..
                     11: *     .. Array Arguments ..
                     12:       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
                     13: *     ..
                     14: *
                     15: *  Purpose
                     16: *  =======
                     17: *
                     18: *  DORGL2 generates an m by n real matrix Q with orthonormal rows,
                     19: *  which is defined as the first m rows of a product of k elementary
                     20: *  reflectors of order n
                     21: *
                     22: *        Q  =  H(k) . . . H(2) H(1)
                     23: *
                     24: *  as returned by DGELQF.
                     25: *
                     26: *  Arguments
                     27: *  =========
                     28: *
                     29: *  M       (input) INTEGER
                     30: *          The number of rows of the matrix Q. M >= 0.
                     31: *
                     32: *  N       (input) INTEGER
                     33: *          The number of columns of the matrix Q. N >= M.
                     34: *
                     35: *  K       (input) INTEGER
                     36: *          The number of elementary reflectors whose product defines the
                     37: *          matrix Q. M >= K >= 0.
                     38: *
                     39: *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
                     40: *          On entry, the i-th row must contain the vector which defines
                     41: *          the elementary reflector H(i), for i = 1,2,...,k, as returned
                     42: *          by DGELQF in the first k rows of its array argument A.
                     43: *          On exit, the m-by-n matrix Q.
                     44: *
                     45: *  LDA     (input) INTEGER
                     46: *          The first dimension of the array A. LDA >= max(1,M).
                     47: *
                     48: *  TAU     (input) DOUBLE PRECISION array, dimension (K)
                     49: *          TAU(i) must contain the scalar factor of the elementary
                     50: *          reflector H(i), as returned by DGELQF.
                     51: *
                     52: *  WORK    (workspace) DOUBLE PRECISION array, dimension (M)
                     53: *
                     54: *  INFO    (output) INTEGER
                     55: *          = 0: successful exit
                     56: *          < 0: if INFO = -i, the i-th argument has an illegal value
                     57: *
                     58: *  =====================================================================
                     59: *
                     60: *     .. Parameters ..
                     61:       DOUBLE PRECISION   ONE, ZERO
                     62:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
                     63: *     ..
                     64: *     .. Local Scalars ..
                     65:       INTEGER            I, J, L
                     66: *     ..
                     67: *     .. External Subroutines ..
                     68:       EXTERNAL           DLARF, DSCAL, XERBLA
                     69: *     ..
                     70: *     .. Intrinsic Functions ..
                     71:       INTRINSIC          MAX
                     72: *     ..
                     73: *     .. Executable Statements ..
                     74: *
                     75: *     Test the input arguments
                     76: *
                     77:       INFO = 0
                     78:       IF( M.LT.0 ) THEN
                     79:          INFO = -1
                     80:       ELSE IF( N.LT.M ) THEN
                     81:          INFO = -2
                     82:       ELSE IF( K.LT.0 .OR. K.GT.M ) THEN
                     83:          INFO = -3
                     84:       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
                     85:          INFO = -5
                     86:       END IF
                     87:       IF( INFO.NE.0 ) THEN
                     88:          CALL XERBLA( 'DORGL2', -INFO )
                     89:          RETURN
                     90:       END IF
                     91: *
                     92: *     Quick return if possible
                     93: *
                     94:       IF( M.LE.0 )
                     95:      $   RETURN
                     96: *
                     97:       IF( K.LT.M ) THEN
                     98: *
                     99: *        Initialise rows k+1:m to rows of the unit matrix
                    100: *
                    101:          DO 20 J = 1, N
                    102:             DO 10 L = K + 1, M
                    103:                A( L, J ) = ZERO
                    104:    10       CONTINUE
                    105:             IF( J.GT.K .AND. J.LE.M )
                    106:      $         A( J, J ) = ONE
                    107:    20    CONTINUE
                    108:       END IF
                    109: *
                    110:       DO 40 I = K, 1, -1
                    111: *
                    112: *        Apply H(i) to A(i:m,i:n) from the right
                    113: *
                    114:          IF( I.LT.N ) THEN
                    115:             IF( I.LT.M ) THEN
                    116:                A( I, I ) = ONE
                    117:                CALL DLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
                    118:      $                     TAU( I ), A( I+1, I ), LDA, WORK )
                    119:             END IF
                    120:             CALL DSCAL( N-I, -TAU( I ), A( I, I+1 ), LDA )
                    121:          END IF
                    122:          A( I, I ) = ONE - TAU( I )
                    123: *
                    124: *        Set A(i,1:i-1) to zero
                    125: *
                    126:          DO 30 L = 1, I - 1
                    127:             A( I, L ) = ZERO
                    128:    30    CONTINUE
                    129:    40 CONTINUE
                    130:       RETURN
                    131: *
                    132: *     End of DORGL2
                    133: *
                    134:       END

CVSweb interface <joel.bertrand@systella.fr>