LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dspt21()

subroutine dspt21 ( integer  ITYPE,
character  UPLO,
integer  N,
integer  KBAND,
double precision, dimension( * )  AP,
double precision, dimension( * )  D,
double precision, dimension( * )  E,
double precision, dimension( ldu, * )  U,
integer  LDU,
double precision, dimension( * )  VP,
double precision, dimension( * )  TAU,
double precision, dimension( * )  WORK,
double precision, dimension( 2 )  RESULT 
)

DSPT21

Purpose:
 DSPT21  generally checks a decomposition of the form

         A = U S U**T

 where **T means transpose, A is symmetric (stored in packed format), U
 is orthogonal, and S is diagonal (if KBAND=0) or symmetric
 tridiagonal (if KBAND=1).  If ITYPE=1, then U is represented as a
 dense matrix, otherwise the U is expressed as a product of
 Householder transformations, whose vectors are stored in the array
 "V" and whose scaling constants are in "TAU"; we shall use the
 letter "V" to refer to the product of Householder transformations
 (which should be equal to U).

 Specifically, if ITYPE=1, then:

         RESULT(1) = | A - U S U**T | / ( |A| n ulp ) and
         RESULT(2) = | I - U U**T | / ( n ulp )

 If ITYPE=2, then:

         RESULT(1) = | A - V S V**T | / ( |A| n ulp )

 If ITYPE=3, then:

         RESULT(1) = | I - V U**T | / ( n ulp )

 Packed storage means that, for example, if UPLO='U', then the columns
 of the upper triangle of A are stored one after another, so that
 A(1,j+1) immediately follows A(j,j) in the array AP.  Similarly, if
 UPLO='L', then the columns of the lower triangle of A are stored one
 after another in AP, so that A(j+1,j+1) immediately follows A(n,j)
 in the array AP.  This means that A(i,j) is stored in:

    AP( i + j*(j-1)/2 )                 if UPLO='U'

    AP( i + (2*n-j)*(j-1)/2 )           if UPLO='L'

 The array VP bears the same relation to the matrix V that A does to
 AP.

 For ITYPE > 1, the transformation U is expressed as a product
 of Householder transformations:

    If UPLO='U', then  V = H(n-1)...H(1),  where

        H(j) = I  -  tau(j) v(j) v(j)**T

    and the first j-1 elements of v(j) are stored in V(1:j-1,j+1),
    (i.e., VP( j*(j+1)/2 + 1 : j*(j+1)/2 + j-1 ) ),
    the j-th element is 1, and the last n-j elements are 0.

    If UPLO='L', then  V = H(1)...H(n-1),  where

        H(j) = I  -  tau(j) v(j) v(j)**T

    and the first j elements of v(j) are 0, the (j+1)-st is 1, and the
    (j+2)-nd through n-th elements are stored in V(j+2:n,j) (i.e.,
    in VP( (2*n-j)*(j-1)/2 + j+2 : (2*n-j)*(j-1)/2 + n ) .)
Parameters
[in]ITYPE
          ITYPE is INTEGER
          Specifies the type of tests to be performed.
          1: U expressed as a dense orthogonal matrix:
             RESULT(1) = | A - U S U**T | / ( |A| n ulp ) and
             RESULT(2) = | I - U U**T | / ( n ulp )

          2: U expressed as a product V of Housholder transformations:
             RESULT(1) = | A - V S V**T | / ( |A| n ulp )

          3: U expressed both as a dense orthogonal matrix and
             as a product of Housholder transformations:
             RESULT(1) = | I - V U**T | / ( n ulp )
[in]UPLO
          UPLO is CHARACTER
          If UPLO='U', AP and VP are considered to contain the upper
          triangle of A and V.
          If UPLO='L', AP and VP are considered to contain the lower
          triangle of A and V.
[in]N
          N is INTEGER
          The size of the matrix.  If it is zero, DSPT21 does nothing.
          It must be at least zero.
[in]KBAND
          KBAND is INTEGER
          The bandwidth of the matrix.  It may only be zero or one.
          If zero, then S is diagonal, and E is not referenced.  If
          one, then S is symmetric tri-diagonal.
[in]AP
          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
          The original (unfactored) matrix.  It is assumed to be
          symmetric, and contains the columns of just the upper
          triangle (UPLO='U') or only the lower triangle (UPLO='L'),
          packed one after another.
[in]D
          D is DOUBLE PRECISION array, dimension (N)
          The diagonal of the (symmetric tri-) diagonal matrix.
[in]E
          E is DOUBLE PRECISION array, dimension (N-1)
          The off-diagonal of the (symmetric tri-) diagonal matrix.
          E(1) is the (1,2) and (2,1) element, E(2) is the (2,3) and
          (3,2) element, etc.
          Not referenced if KBAND=0.
[in]U
          U is DOUBLE PRECISION array, dimension (LDU, N)
          If ITYPE=1 or 3, this contains the orthogonal matrix in
          the decomposition, expressed as a dense matrix.  If ITYPE=2,
          then it is not referenced.
[in]LDU
          LDU is INTEGER
          The leading dimension of U.  LDU must be at least N and
          at least 1.
[in]VP
          VP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
          If ITYPE=2 or 3, the columns of this array contain the
          Householder vectors used to describe the orthogonal matrix
          in the decomposition, as described in purpose.
          *NOTE* If ITYPE=2 or 3, V is modified and restored.  The
          subdiagonal (if UPLO='L') or the superdiagonal (if UPLO='U')
          is set to one, and later reset to its original value, during
          the course of the calculation.
          If ITYPE=1, then it is neither referenced nor modified.
[in]TAU
          TAU is DOUBLE PRECISION array, dimension (N)
          If ITYPE >= 2, then TAU(j) is the scalar factor of
          v(j) v(j)**T in the Householder transformation H(j) of
          the product  U = H(1)...H(n-2)
          If ITYPE < 2, then TAU is not referenced.
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (N**2+N)
          Workspace.
[out]RESULT
          RESULT is DOUBLE PRECISION array, dimension (2)
          The values computed by the two tests described above.  The
          values are currently limited to 1/ulp, to avoid overflow.
          RESULT(1) is always modified.  RESULT(2) is modified only
          if ITYPE=1.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 219 of file dspt21.f.

221*
222* -- LAPACK test routine --
223* -- LAPACK is a software package provided by Univ. of Tennessee, --
224* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
225*
226* .. Scalar Arguments ..
227 CHARACTER UPLO
228 INTEGER ITYPE, KBAND, LDU, N
229* ..
230* .. Array Arguments ..
231 DOUBLE PRECISION AP( * ), D( * ), E( * ), RESULT( 2 ), TAU( * ),
232 $ U( LDU, * ), VP( * ), WORK( * )
233* ..
234*
235* =====================================================================
236*
237* .. Parameters ..
238 DOUBLE PRECISION ZERO, ONE, TEN
239 parameter( zero = 0.0d0, one = 1.0d0, ten = 10.0d0 )
240 DOUBLE PRECISION HALF
241 parameter( half = 1.0d+0 / 2.0d+0 )
242* ..
243* .. Local Scalars ..
244 LOGICAL LOWER
245 CHARACTER CUPLO
246 INTEGER IINFO, J, JP, JP1, JR, LAP
247 DOUBLE PRECISION ANORM, TEMP, ULP, UNFL, VSAVE, WNORM
248* ..
249* .. External Functions ..
250 LOGICAL LSAME
251 DOUBLE PRECISION DDOT, DLAMCH, DLANGE, DLANSP
252 EXTERNAL lsame, ddot, dlamch, dlange, dlansp
253* ..
254* .. External Subroutines ..
255 EXTERNAL daxpy, dcopy, dgemm, dlacpy, dlaset, dopmtr,
256 $ dspmv, dspr, dspr2
257* ..
258* .. Intrinsic Functions ..
259 INTRINSIC dble, max, min
260* ..
261* .. Executable Statements ..
262*
263* 1) Constants
264*
265 result( 1 ) = zero
266 IF( itype.EQ.1 )
267 $ result( 2 ) = zero
268 IF( n.LE.0 )
269 $ RETURN
270*
271 lap = ( n*( n+1 ) ) / 2
272*
273 IF( lsame( uplo, 'U' ) ) THEN
274 lower = .false.
275 cuplo = 'U'
276 ELSE
277 lower = .true.
278 cuplo = 'L'
279 END IF
280*
281 unfl = dlamch( 'Safe minimum' )
282 ulp = dlamch( 'Epsilon' )*dlamch( 'Base' )
283*
284* Some Error Checks
285*
286 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
287 result( 1 ) = ten / ulp
288 RETURN
289 END IF
290*
291* Do Test 1
292*
293* Norm of A:
294*
295 IF( itype.EQ.3 ) THEN
296 anorm = one
297 ELSE
298 anorm = max( dlansp( '1', cuplo, n, ap, work ), unfl )
299 END IF
300*
301* Compute error matrix:
302*
303 IF( itype.EQ.1 ) THEN
304*
305* ITYPE=1: error = A - U S U**T
306*
307 CALL dlaset( 'Full', n, n, zero, zero, work, n )
308 CALL dcopy( lap, ap, 1, work, 1 )
309*
310 DO 10 j = 1, n
311 CALL dspr( cuplo, n, -d( j ), u( 1, j ), 1, work )
312 10 CONTINUE
313*
314 IF( n.GT.1 .AND. kband.EQ.1 ) THEN
315 DO 20 j = 1, n - 1
316 CALL dspr2( cuplo, n, -e( j ), u( 1, j ), 1, u( 1, j+1 ),
317 $ 1, work )
318 20 CONTINUE
319 END IF
320 wnorm = dlansp( '1', cuplo, n, work, work( n**2+1 ) )
321*
322 ELSE IF( itype.EQ.2 ) THEN
323*
324* ITYPE=2: error = V S V**T - A
325*
326 CALL dlaset( 'Full', n, n, zero, zero, work, n )
327*
328 IF( lower ) THEN
329 work( lap ) = d( n )
330 DO 40 j = n - 1, 1, -1
331 jp = ( ( 2*n-j )*( j-1 ) ) / 2
332 jp1 = jp + n - j
333 IF( kband.EQ.1 ) THEN
334 work( jp+j+1 ) = ( one-tau( j ) )*e( j )
335 DO 30 jr = j + 2, n
336 work( jp+jr ) = -tau( j )*e( j )*vp( jp+jr )
337 30 CONTINUE
338 END IF
339*
340 IF( tau( j ).NE.zero ) THEN
341 vsave = vp( jp+j+1 )
342 vp( jp+j+1 ) = one
343 CALL dspmv( 'L', n-j, one, work( jp1+j+1 ),
344 $ vp( jp+j+1 ), 1, zero, work( lap+1 ), 1 )
345 temp = -half*tau( j )*ddot( n-j, work( lap+1 ), 1,
346 $ vp( jp+j+1 ), 1 )
347 CALL daxpy( n-j, temp, vp( jp+j+1 ), 1, work( lap+1 ),
348 $ 1 )
349 CALL dspr2( 'L', n-j, -tau( j ), vp( jp+j+1 ), 1,
350 $ work( lap+1 ), 1, work( jp1+j+1 ) )
351 vp( jp+j+1 ) = vsave
352 END IF
353 work( jp+j ) = d( j )
354 40 CONTINUE
355 ELSE
356 work( 1 ) = d( 1 )
357 DO 60 j = 1, n - 1
358 jp = ( j*( j-1 ) ) / 2
359 jp1 = jp + j
360 IF( kband.EQ.1 ) THEN
361 work( jp1+j ) = ( one-tau( j ) )*e( j )
362 DO 50 jr = 1, j - 1
363 work( jp1+jr ) = -tau( j )*e( j )*vp( jp1+jr )
364 50 CONTINUE
365 END IF
366*
367 IF( tau( j ).NE.zero ) THEN
368 vsave = vp( jp1+j )
369 vp( jp1+j ) = one
370 CALL dspmv( 'U', j, one, work, vp( jp1+1 ), 1, zero,
371 $ work( lap+1 ), 1 )
372 temp = -half*tau( j )*ddot( j, work( lap+1 ), 1,
373 $ vp( jp1+1 ), 1 )
374 CALL daxpy( j, temp, vp( jp1+1 ), 1, work( lap+1 ),
375 $ 1 )
376 CALL dspr2( 'U', j, -tau( j ), vp( jp1+1 ), 1,
377 $ work( lap+1 ), 1, work )
378 vp( jp1+j ) = vsave
379 END IF
380 work( jp1+j+1 ) = d( j+1 )
381 60 CONTINUE
382 END IF
383*
384 DO 70 j = 1, lap
385 work( j ) = work( j ) - ap( j )
386 70 CONTINUE
387 wnorm = dlansp( '1', cuplo, n, work, work( lap+1 ) )
388*
389 ELSE IF( itype.EQ.3 ) THEN
390*
391* ITYPE=3: error = U V**T - I
392*
393 IF( n.LT.2 )
394 $ RETURN
395 CALL dlacpy( ' ', n, n, u, ldu, work, n )
396 CALL dopmtr( 'R', cuplo, 'T', n, n, vp, tau, work, n,
397 $ work( n**2+1 ), iinfo )
398 IF( iinfo.NE.0 ) THEN
399 result( 1 ) = ten / ulp
400 RETURN
401 END IF
402*
403 DO 80 j = 1, n
404 work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - one
405 80 CONTINUE
406*
407 wnorm = dlange( '1', n, n, work, n, work( n**2+1 ) )
408 END IF
409*
410 IF( anorm.GT.wnorm ) THEN
411 result( 1 ) = ( wnorm / anorm ) / ( n*ulp )
412 ELSE
413 IF( anorm.LT.one ) THEN
414 result( 1 ) = ( min( wnorm, n*anorm ) / anorm ) / ( n*ulp )
415 ELSE
416 result( 1 ) = min( wnorm / anorm, dble( n ) ) / ( n*ulp )
417 END IF
418 END IF
419*
420* Do Test 2
421*
422* Compute U U**T - I
423*
424 IF( itype.EQ.1 ) THEN
425 CALL dgemm( 'N', 'C', n, n, n, one, u, ldu, u, ldu, zero, work,
426 $ n )
427*
428 DO 90 j = 1, n
429 work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - one
430 90 CONTINUE
431*
432 result( 2 ) = min( dlange( '1', n, n, work, n,
433 $ work( n**2+1 ) ), dble( n ) ) / ( n*ulp )
434 END IF
435*
436 RETURN
437*
438* End of DSPT21
439*
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:69
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:103
subroutine dlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: dlaset.f:110
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine dcopy(N, DX, INCX, DY, INCY)
DCOPY
Definition: dcopy.f:82
double precision function ddot(N, DX, INCX, DY, INCY)
DDOT
Definition: ddot.f:82
subroutine daxpy(N, DA, DX, INCX, DY, INCY)
DAXPY
Definition: daxpy.f:89
subroutine dspr2(UPLO, N, ALPHA, X, INCX, Y, INCY, AP)
DSPR2
Definition: dspr2.f:142
subroutine dspr(UPLO, N, ALPHA, X, INCX, AP)
DSPR
Definition: dspr.f:127
subroutine dspmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
DSPMV
Definition: dspmv.f:147
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:187
double precision function dlange(NORM, M, N, A, LDA, WORK)
DLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: dlange.f:114
double precision function dlansp(NORM, UPLO, N, AP, WORK)
DLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: dlansp.f:114
subroutine dopmtr(SIDE, UPLO, TRANS, M, N, AP, TAU, C, LDC, WORK, INFO)
DOPMTR
Definition: dopmtr.f:150
Here is the call graph for this function:
Here is the caller graph for this function: