1*> \brief \b SRZT01
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*  Definition:
9*  ===========
10*
11*       REAL             FUNCTION SRZT01( M, N, A, AF, LDA, TAU, WORK,
12*                        LWORK )
13*
14*       .. Scalar Arguments ..
15*       INTEGER            LDA, LWORK, M, N
16*       ..
17*       .. Array Arguments ..
18*       REAL               A( LDA, * ), AF( LDA, * ), TAU( * ),
19*      $                   WORK( LWORK )
20*       ..
21*
22*
23*> \par Purpose:
24*  =============
25*>
26*> \verbatim
27*>
28*> SRZT01 returns
29*>      || A - R*Q || / ( M * eps * ||A|| )
30*> for an upper trapezoidal A that was factored with STZRZF.
31*> \endverbatim
32*
33*  Arguments:
34*  ==========
35*
36*> \param[in] M
37*> \verbatim
38*>          M is INTEGER
39*>          The number of rows of the matrices A and AF.
40*> \endverbatim
41*>
42*> \param[in] N
43*> \verbatim
44*>          N is INTEGER
45*>          The number of columns of the matrices A and AF.
46*> \endverbatim
47*>
48*> \param[in] A
49*> \verbatim
50*>          A is REAL array, dimension (LDA,N)
51*>          The original upper trapezoidal M by N matrix A.
52*> \endverbatim
53*>
54*> \param[in] AF
55*> \verbatim
56*>          AF is REAL array, dimension (LDA,N)
57*>          The output of STZRZF for input matrix A.
58*>          The lower triangle is not referenced.
59*> \endverbatim
60*>
61*> \param[in] LDA
62*> \verbatim
63*>          LDA is INTEGER
64*>          The leading dimension of the arrays A and AF.
65*> \endverbatim
66*>
67*> \param[in] TAU
68*> \verbatim
69*>          TAU is REAL array, dimension (M)
70*>          Details of the Householder transformations as returned by
71*>          STZRZF.
72*> \endverbatim
73*>
74*> \param[out] WORK
75*> \verbatim
76*>          WORK is REAL array, dimension (LWORK)
77*> \endverbatim
78*>
79*> \param[in] LWORK
80*> \verbatim
81*>          LWORK is INTEGER
82*>          The length of the array WORK.  LWORK >= m*n + m*nb.
83*> \endverbatim
84*
85*  Authors:
86*  ========
87*
88*> \author Univ. of Tennessee
89*> \author Univ. of California Berkeley
90*> \author Univ. of Colorado Denver
91*> \author NAG Ltd.
92*
93*> \ingroup single_lin
94*
95*  =====================================================================
96      REAL             FUNCTION SRZT01( M, N, A, AF, LDA, TAU, WORK,
97     $                 LWORK )
98*
99*  -- LAPACK test routine --
100*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
101*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
102*
103*     .. Scalar Arguments ..
104      INTEGER            LDA, LWORK, M, N
105*     ..
106*     .. Array Arguments ..
107      REAL               A( LDA, * ), AF( LDA, * ), TAU( * ),
108     $                   WORK( LWORK )
109*     ..
110*
111*  =====================================================================
112*
113*     .. Parameters ..
114      REAL               ZERO, ONE
115      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
116*     ..
117*     .. Local Scalars ..
118      INTEGER            I, INFO, J
119      REAL               NORMA
120*     ..
121*     .. Local Arrays ..
122      REAL               RWORK( 1 )
123*     ..
124*     .. External Functions ..
125      REAL               SLAMCH, SLANGE
126      EXTERNAL           SLAMCH, SLANGE
127*     ..
128*     .. External Subroutines ..
129      EXTERNAL           SAXPY, SLASET, SORMRZ, XERBLA
130*     ..
131*     .. Intrinsic Functions ..
132      INTRINSIC          MAX, REAL
133*     ..
134*     .. Executable Statements ..
135*
136      SRZT01 = ZERO
137*
138      IF( LWORK.LT.M*N+M ) THEN
139         CALL XERBLA( 'SRZT01', 8 )
140         RETURN
141      END IF
142*
143*     Quick return if possible
144*
145      IF( M.LE.0 .OR. N.LE.0 )
146     $   RETURN
147*
148      NORMA = SLANGE( 'One-norm', M, N, A, LDA, RWORK )
149*
150*     Copy upper triangle R
151*
152      CALL SLASET( 'Full', M, N, ZERO, ZERO, WORK, M )
153      DO 20 J = 1, M
154         DO 10 I = 1, J
155            WORK( ( J-1 )*M+I ) = AF( I, J )
156   10    CONTINUE
157   20 CONTINUE
158*
159*     R = R * P(1) * ... *P(m)
160*
161      CALL SORMRZ( 'Right', 'No tranpose', M, N, M, N-M, AF, LDA, TAU,
162     $             WORK, M, WORK( M*N+1 ), LWORK-M*N, INFO )
163*
164*     R = R - A
165*
166      DO 30 I = 1, N
167         CALL SAXPY( M, -ONE, A( 1, I ), 1, WORK( ( I-1 )*M+1 ), 1 )
168   30 CONTINUE
169*
170      SRZT01 = SLANGE( 'One-norm', M, N, WORK, M, RWORK )
171*
172      SRZT01 = SRZT01 / ( SLAMCH( 'Epsilon' )*REAL( MAX( M, N ) ) )
173      IF( NORMA.NE.ZERO )
174     $   SRZT01 = SRZT01 / NORMA
175*
176      RETURN
177*
178*     End of SRZT01
179*
180      END
181