001:       SUBROUTINE STZRQF( M, N, A, LDA, TAU, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       INTEGER            INFO, LDA, M, N
010: *     ..
011: *     .. Array Arguments ..
012:       REAL               A( LDA, * ), TAU( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  This routine is deprecated and has been replaced by routine STZRZF.
019: *
020: *  STZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A
021: *  to upper triangular form by means of orthogonal transformations.
022: *
023: *  The upper trapezoidal matrix A is factored as
024: *
025: *     A = ( R  0 ) * Z,
026: *
027: *  where Z is an N-by-N orthogonal matrix and R is an M-by-M upper
028: *  triangular matrix.
029: *
030: *  Arguments
031: *  =========
032: *
033: *  M       (input) INTEGER
034: *          The number of rows of the matrix A.  M >= 0.
035: *
036: *  N       (input) INTEGER
037: *          The number of columns of the matrix A.  N >= M.
038: *
039: *  A       (input/output) REAL array, dimension (LDA,N)
040: *          On entry, the leading M-by-N upper trapezoidal part of the
041: *          array A must contain the matrix to be factorized.
042: *          On exit, the leading M-by-M upper triangular part of A
043: *          contains the upper triangular matrix R, and elements M+1 to
044: *          N of the first M rows of A, with the array TAU, represent the
045: *          orthogonal matrix Z as a product of M elementary reflectors.
046: *
047: *  LDA     (input) INTEGER
048: *          The leading dimension of the array A.  LDA >= max(1,M).
049: *
050: *  TAU     (output) REAL array, dimension (M)
051: *          The scalar factors of the elementary reflectors.
052: *
053: *  INFO    (output) INTEGER
054: *          = 0:  successful exit
055: *          < 0:  if INFO = -i, the i-th argument had an illegal value
056: *
057: *  Further Details
058: *  ===============
059: *
060: *  The factorization is obtained by Householder's method.  The kth
061: *  transformation matrix, Z( k ), which is used to introduce zeros into
062: *  the ( m - k + 1 )th row of A, is given in the form
063: *
064: *     Z( k ) = ( I     0   ),
065: *              ( 0  T( k ) )
066: *
067: *  where
068: *
069: *     T( k ) = I - tau*u( k )*u( k )',   u( k ) = (   1    ),
070: *                                                 (   0    )
071: *                                                 ( z( k ) )
072: *
073: *  tau is a scalar and z( k ) is an ( n - m ) element vector.
074: *  tau and z( k ) are chosen to annihilate the elements of the kth row
075: *  of X.
076: *
077: *  The scalar tau is returned in the kth element of TAU and the vector
078: *  u( k ) in the kth row of A, such that the elements of z( k ) are
079: *  in  a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in
080: *  the upper triangular part of A.
081: *
082: *  Z is given by
083: *
084: *     Z =  Z( 1 ) * Z( 2 ) * ... * Z( m ).
085: *
086: *  =====================================================================
087: *
088: *     .. Parameters ..
089:       REAL               ONE, ZERO
090:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
091: *     ..
092: *     .. Local Scalars ..
093:       INTEGER            I, K, M1
094: *     ..
095: *     .. Intrinsic Functions ..
096:       INTRINSIC          MAX, MIN
097: *     ..
098: *     .. External Subroutines ..
099:       EXTERNAL           SAXPY, SCOPY, SGEMV, SGER, SLARFP, XERBLA
100: *     ..
101: *     .. Executable Statements ..
102: *
103: *     Test the input parameters.
104: *
105:       INFO = 0
106:       IF( M.LT.0 ) THEN
107:          INFO = -1
108:       ELSE IF( N.LT.M ) THEN
109:          INFO = -2
110:       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
111:          INFO = -4
112:       END IF
113:       IF( INFO.NE.0 ) THEN
114:          CALL XERBLA( 'STZRQF', -INFO )
115:          RETURN
116:       END IF
117: *
118: *     Perform the factorization.
119: *
120:       IF( M.EQ.0 )
121:      $   RETURN
122:       IF( M.EQ.N ) THEN
123:          DO 10 I = 1, N
124:             TAU( I ) = ZERO
125:    10    CONTINUE
126:       ELSE
127:          M1 = MIN( M+1, N )
128:          DO 20 K = M, 1, -1
129: *
130: *           Use a Householder reflection to zero the kth row of A.
131: *           First set up the reflection.
132: *
133:             CALL SLARFP( N-M+1, A( K, K ), A( K, M1 ), LDA, TAU( K ) )
134: *
135:             IF( ( TAU( K ).NE.ZERO ) .AND. ( K.GT.1 ) ) THEN
136: *
137: *              We now perform the operation  A := A*P( k ).
138: *
139: *              Use the first ( k - 1 ) elements of TAU to store  a( k ),
140: *              where  a( k ) consists of the first ( k - 1 ) elements of
141: *              the  kth column  of  A.  Also  let  B  denote  the  first
142: *              ( k - 1 ) rows of the last ( n - m ) columns of A.
143: *
144:                CALL SCOPY( K-1, A( 1, K ), 1, TAU, 1 )
145: *
146: *              Form   w = a( k ) + B*z( k )  in TAU.
147: *
148:                CALL SGEMV( 'No transpose', K-1, N-M, ONE, A( 1, M1 ),
149:      $                     LDA, A( K, M1 ), LDA, ONE, TAU, 1 )
150: *
151: *              Now form  a( k ) := a( k ) - tau*w
152: *              and       B      := B      - tau*w*z( k )'.
153: *
154:                CALL SAXPY( K-1, -TAU( K ), TAU, 1, A( 1, K ), 1 )
155:                CALL SGER( K-1, N-M, -TAU( K ), TAU, 1, A( K, M1 ), LDA,
156:      $                    A( 1, M1 ), LDA )
157:             END IF
158:    20    CONTINUE
159:       END IF
160: *
161:       RETURN
162: *
163: *     End of STZRQF
164: *
165:       END
166: