1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
      SUBROUTINE DGET51ITYPENALDABLDBULDUVLDVWORK,
     $                   RESULT )
*
*  -- LAPACK test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2006
*
*     .. Scalar Arguments ..
      INTEGER            ITYPELDALDBLDULDVN
      DOUBLE PRECISION   RESULT
*     ..
*     .. Array Arguments ..
      DOUBLE PRECISION   ALDA* ), BLDB* ), ULDU* ),
     $                   VLDV* ), WORK* )
*     ..
*
*  Purpose
*  =======
*
*       DGET51  generally checks a decomposition of the form
*
*               A = U B V'
*
*       where ' means transpose and U and V are orthogonal.
*
*       Specifically, if ITYPE=1
*
*               RESULT = | A - U B V' | / ( |A| n ulp )
*
*       If ITYPE=2, then:
*
*               RESULT = | A - B | / ( |A| n ulp )
*
*       If ITYPE=3, then:
*
*               RESULT = | I - UU' | / ( n ulp )
*
*  Arguments
*  =========
*
*  ITYPE   (input) INTEGER
*          Specifies the type of tests to be performed.
*          =1: RESULT = | A - U B V' | / ( |A| n ulp )
*          =2: RESULT = | A - B | / ( |A| n ulp )
*          =3: RESULT = | I - UU' | / ( n ulp )
*
*  N       (input) INTEGER
*          The size of the matrix.  If it is zero, DGET51 does nothing.
*          It must be at least zero.
*
*  A       (input) DOUBLE PRECISION array, dimension (LDA, N)
*          The original (unfactored) matrix.
*
*  LDA     (input) INTEGER
*          The leading dimension of A.  It must be at least 1
*          and at least N.
*
*  B       (input) DOUBLE PRECISION array, dimension (LDB, N)
*          The factored matrix.
*
*  LDB     (input) INTEGER
*          The leading dimension of B.  It must be at least 1
*          and at least N.
*
*  U       (input) DOUBLE PRECISION array, dimension (LDU, N)
*          The orthogonal matrix on the left-hand side in the
*          decomposition.
*          Not referenced if ITYPE=2
*
*  LDU     (input) INTEGER
*          The leading dimension of U.  LDU must be at least N and
*          at least 1.
*
*  V       (input) DOUBLE PRECISION array, dimension (LDV, N)
*          The orthogonal matrix on the left-hand side in the
*          decomposition.
*          Not referenced if ITYPE=2
*
*  LDV     (input) INTEGER
*          The leading dimension of V.  LDV must be at least N and
*          at least 1.
*
*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*N**2)
*
*  RESULT  (output) DOUBLE PRECISION
*          The values computed by the test specified by ITYPE.  The
*          value is currently limited to 1/ulp, to avoid overflow.
*          Errors are flagged by RESULT=10/ulp.
*
*  =====================================================================
*
*     .. Parameters ..
      DOUBLE PRECISION   ZEROONETEN
      PARAMETER          ( ZERO = 0.0D0ONE = 1.0D0TEN = 10.0D0 )
*     ..
*     .. Local Scalars ..
      INTEGER            JCOLJDIAGJROW
      DOUBLE PRECISION   ANORMULPUNFLWNORM
*     ..
*     .. External Functions ..
      DOUBLE PRECISION   DLAMCHDLANGE
      EXTERNAL           DLAMCHDLANGE
*     ..
*     .. External Subroutines ..
      EXTERNAL           DGEMMDLACPY
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          DBLEMAXMIN
*     ..
*     .. Executable Statements ..
*
      RESULT = ZERO
      IFN.LE.0 )
     $   RETURN
*
*     Constants
*
      UNFL = DLAMCH'Safe minimum' )
      ULP = DLAMCH'Epsilon' )*DLAMCH'Base' )
*
*     Some Error Checks
*
      IFITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
         RESULT = TEN / ULP
         RETURN
      END IF
*
      IFITYPE.LE.2 ) THEN
*
*        Tests scaled by the norm(A)
*
         ANORM = MAXDLANGE'1'NNALDAWORK ), UNFL )
*
         IFITYPE.EQ.1 ) THEN
*
*           ITYPE=1: Compute W = A - UBV'
*
            CALL DLACPY' 'NNALDAWORKN )
            CALL DGEMM'N''N'NNNONEULDUBLDBZERO,
     $                  WORKN**2+1 ), N )
*
            CALL DGEMM'N''C'NNN-ONEWORKN**2+1 ), NV,
     $                  LDVONEWORKN )
*
         ELSE
*
*           ITYPE=2: Compute W = A - B
*
            CALL DLACPY' 'NNBLDBWORKN )
*
            DO 20 JCOL = 1N
               DO 10 JROW = 1N
                  WORKJROW+N*JCOL-1 ) ) = WORKJROW+N*JCOL-1 ) )
     $                - AJROWJCOL )
   10          CONTINUE
   20       CONTINUE
         END IF
*
*        Compute norm(W)/ ( ulp*norm(A) )
*
         WNORM = DLANGE'1'NNWORKNWORKN**2+1 ) )
*
         IFANORM.GT.WNORM ) THEN
            RESULT = ( WNORM / ANORM ) / ( N*ULP )
         ELSE
            IFANORM.LT.ONE ) THEN
               RESULT = ( MINWNORMN*ANORM ) / ANORM ) / ( N*ULP )
            ELSE
               RESULT = MINWNORM / ANORMDBLEN ) ) / ( N*ULP )
            END IF
         END IF
*
      ELSE
*
*        Tests not scaled by norm(A)
*
*        ITYPE=3: Compute  UU' - I
*
         CALL DGEMM'N''C'NNNONEULDUULDUZEROWORK,
     $               N )
*
         DO 30 JDIAG = 1N
            WORK( ( N+1 )*JDIAG-1 )+1 ) = WORK( ( N+1 )*JDIAG-1 )+
     $         1 ) - ONE
   30    CONTINUE
*
         RESULT = MINDLANGE'1'NNWORKNWORKN**2+1 ) ),
     $            DBLEN ) ) / ( N*ULP )
      END IF
*
      RETURN
*
*     End of DGET51
*
      END