1       DOUBLE PRECISION FUNCTION DRZT01( M, N, A, AF, LDA, TAU, WORK,
  2      $                 LWORK )
  3 *
  4 *  -- LAPACK test routine (version 3.1) --
  5 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  6 *     November 2006
  7 *
  8 *     .. Scalar Arguments ..
  9       INTEGER            LDA, LWORK, M, N
 10 *     ..
 11 *     .. Array Arguments ..
 12       DOUBLE PRECISION   A( LDA, * ), AF( LDA, * ), TAU( * ),
 13      $                   WORK( LWORK )
 14 *     ..
 15 *
 16 *  Purpose
 17 *  =======
 18 *
 19 *  DRZT01 returns
 20 *       || A - R*Q || / ( M * eps * ||A|| )
 21 *  for an upper trapezoidal A that was factored with DTZRZF.
 22 *
 23 *  Arguments
 24 *  =========
 25 *
 26 *  M       (input) INTEGER
 27 *          The number of rows of the matrices A and AF.
 28 *
 29 *  N       (input) INTEGER
 30 *          The number of columns of the matrices A and AF.
 31 *
 32 *  A       (input) DOUBLE PRECISION array, dimension (LDA,N)
 33 *          The original upper trapezoidal M by N matrix A.
 34 *
 35 *  AF      (input) DOUBLE PRECISION array, dimension (LDA,N)
 36 *          The output of DTZRZF for input matrix A.
 37 *          The lower triangle is not referenced.
 38 *
 39 *  LDA     (input) INTEGER
 40 *          The leading dimension of the arrays A and AF.
 41 *
 42 *  TAU     (input) DOUBLE PRECISION array, dimension (M)
 43 *          Details of the Householder transformations as returned by
 44 *          DTZRZF.
 45 *
 46 *  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK)
 47 *
 48 *  LWORK   (input) INTEGER
 49 *          The length of the array WORK.  LWORK >= m*n + m*nb.
 50 *
 51 *  =====================================================================
 52 *
 53 *     .. Parameters ..
 54       DOUBLE PRECISION   ZERO, ONE
 55       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
 56 *     ..
 57 *     .. Local Scalars ..
 58       INTEGER            I, INFO, J
 59       DOUBLE PRECISION   NORMA
 60 *     ..
 61 *     .. Local Arrays ..
 62       DOUBLE PRECISION   RWORK( 1 )
 63 *     ..
 64 *     .. External Functions ..
 65       DOUBLE PRECISION   DLAMCH, DLANGE
 66       EXTERNAL           DLAMCH, DLANGE
 67 *     ..
 68 *     .. External Subroutines ..
 69       EXTERNAL           DAXPY, DLASET, DORMRZ, XERBLA
 70 *     ..
 71 *     .. Intrinsic Functions ..
 72       INTRINSIC          DBLEMAX
 73 *     ..
 74 *     .. Executable Statements ..
 75 *
 76       DRZT01 = ZERO
 77 *
 78       IF( LWORK.LT.M*N+M ) THEN
 79          CALL XERBLA( 'DRZT01'8 )
 80          RETURN
 81       END IF
 82 *
 83 *     Quick return if possible
 84 *
 85       IF( M.LE.0 .OR. N.LE.0 )
 86      $   RETURN
 87 *
 88       NORMA = DLANGE( 'One-norm', M, N, A, LDA, RWORK )
 89 *
 90 *     Copy upper triangle R
 91 *
 92       CALL DLASET( 'Full', M, N, ZERO, ZERO, WORK, M )
 93       DO 20 J = 1, M
 94          DO 10 I = 1, J
 95             WORK( ( J-1 )*M+I ) = AF( I, J )
 96    10    CONTINUE
 97    20 CONTINUE
 98 *
 99 *     R = R * P(1) * ... *P(m)
100 *
101       CALL DORMRZ( 'Right''No tranpose', M, N, M, N-M, AF, LDA, TAU,
102      $             WORK, M, WORK( M*N+1 ), LWORK-M*N, INFO )
103 *
104 *     R = R - A
105 *
106       DO 30 I = 1, N
107          CALL DAXPY( M, -ONE, A( 1, I ), 1, WORK( ( I-1 )*M+1 ), 1 )
108    30 CONTINUE
109 *
110       DRZT01 = DLANGE( 'One-norm', M, N, WORK, M, RWORK )
111 *
112       DRZT01 = DRZT01 / ( DLAMCH( 'Epsilon' )*DBLEMAX( M, N ) ) )
113       IF( NORMA.NE.ZERO )
114      $   DRZT01 = DRZT01 / NORMA
115 *
116       RETURN
117 *
118 *     End of DRZT01
119 *
120       END