 LAPACK  3.9.0 LAPACK: Linear Algebra PACKage

## ◆ sspt21()

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

SSPT21

Purpose:
``` SSPT21  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, SSPT21 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 REAL 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 REAL array, dimension (N) The diagonal of the (symmetric tri-) diagonal matrix.``` [in] E ``` E is REAL 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 REAL 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 REAL 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 REAL 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 REAL array, dimension (N**2+N) Workspace.``` [out] RESULT ``` RESULT is REAL 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.```
Date
December 2016

Definition at line 223 of file sspt21.f.

223 *
224 * -- LAPACK test routine (version 3.7.0) --
225 * -- LAPACK is a software package provided by Univ. of Tennessee, --
226 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
227 * December 2016
228 *
229 * .. Scalar Arguments ..
230  CHARACTER UPLO
231  INTEGER ITYPE, KBAND, LDU, N
232 * ..
233 * .. Array Arguments ..
234  REAL AP( * ), D( * ), E( * ), RESULT( 2 ), TAU( * ),
235  \$ U( LDU, * ), VP( * ), WORK( * )
236 * ..
237 *
238 * =====================================================================
239 *
240 * .. Parameters ..
241  REAL ZERO, ONE, TEN
242  parameter( zero = 0.0e0, one = 1.0e0, ten = 10.0e0 )
243  REAL HALF
244  parameter( half = 1.0e+0 / 2.0e+0 )
245 * ..
246 * .. Local Scalars ..
247  LOGICAL LOWER
248  CHARACTER CUPLO
249  INTEGER IINFO, J, JP, JP1, JR, LAP
250  REAL ANORM, TEMP, ULP, UNFL, VSAVE, WNORM
251 * ..
252 * .. External Functions ..
253  LOGICAL LSAME
254  REAL SDOT, SLAMCH, SLANGE, SLANSP
255  EXTERNAL lsame, sdot, slamch, slange, slansp
256 * ..
257 * .. External Subroutines ..
258  EXTERNAL saxpy, scopy, sgemm, slacpy, slaset, sopmtr,
259  \$ sspmv, sspr, sspr2
260 * ..
261 * .. Intrinsic Functions ..
262  INTRINSIC max, min, real
263 * ..
264 * .. Executable Statements ..
265 *
266 * 1) Constants
267 *
268  result( 1 ) = zero
269  IF( itype.EQ.1 )
270  \$ result( 2 ) = zero
271  IF( n.LE.0 )
272  \$ RETURN
273 *
274  lap = ( n*( n+1 ) ) / 2
275 *
276  IF( lsame( uplo, 'U' ) ) THEN
277  lower = .false.
278  cuplo = 'U'
279  ELSE
280  lower = .true.
281  cuplo = 'L'
282  END IF
283 *
284  unfl = slamch( 'Safe minimum' )
285  ulp = slamch( 'Epsilon' )*slamch( 'Base' )
286 *
287 * Some Error Checks
288 *
289  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
290  result( 1 ) = ten / ulp
291  RETURN
292  END IF
293 *
294 * Do Test 1
295 *
296 * Norm of A:
297 *
298  IF( itype.EQ.3 ) THEN
299  anorm = one
300  ELSE
301  anorm = max( slansp( '1', cuplo, n, ap, work ), unfl )
302  END IF
303 *
304 * Compute error matrix:
305 *
306  IF( itype.EQ.1 ) THEN
307 *
308 * ITYPE=1: error = A - U S U**T
309 *
310  CALL slaset( 'Full', n, n, zero, zero, work, n )
311  CALL scopy( lap, ap, 1, work, 1 )
312 *
313  DO 10 j = 1, n
314  CALL sspr( cuplo, n, -d( j ), u( 1, j ), 1, work )
315  10 CONTINUE
316 *
317  IF( n.GT.1 .AND. kband.EQ.1 ) THEN
318  DO 20 j = 1, n - 1
319  CALL sspr2( cuplo, n, -e( j ), u( 1, j ), 1, u( 1, j+1 ),
320  \$ 1, work )
321  20 CONTINUE
322  END IF
323  wnorm = slansp( '1', cuplo, n, work, work( n**2+1 ) )
324 *
325  ELSE IF( itype.EQ.2 ) THEN
326 *
327 * ITYPE=2: error = V S V**T - A
328 *
329  CALL slaset( 'Full', n, n, zero, zero, work, n )
330 *
331  IF( lower ) THEN
332  work( lap ) = d( n )
333  DO 40 j = n - 1, 1, -1
334  jp = ( ( 2*n-j )*( j-1 ) ) / 2
335  jp1 = jp + n - j
336  IF( kband.EQ.1 ) THEN
337  work( jp+j+1 ) = ( one-tau( j ) )*e( j )
338  DO 30 jr = j + 2, n
339  work( jp+jr ) = -tau( j )*e( j )*vp( jp+jr )
340  30 CONTINUE
341  END IF
342 *
343  IF( tau( j ).NE.zero ) THEN
344  vsave = vp( jp+j+1 )
345  vp( jp+j+1 ) = one
346  CALL sspmv( 'L', n-j, one, work( jp1+j+1 ),
347  \$ vp( jp+j+1 ), 1, zero, work( lap+1 ), 1 )
348  temp = -half*tau( j )*sdot( n-j, work( lap+1 ), 1,
349  \$ vp( jp+j+1 ), 1 )
350  CALL saxpy( n-j, temp, vp( jp+j+1 ), 1, work( lap+1 ),
351  \$ 1 )
352  CALL sspr2( 'L', n-j, -tau( j ), vp( jp+j+1 ), 1,
353  \$ work( lap+1 ), 1, work( jp1+j+1 ) )
354  vp( jp+j+1 ) = vsave
355  END IF
356  work( jp+j ) = d( j )
357  40 CONTINUE
358  ELSE
359  work( 1 ) = d( 1 )
360  DO 60 j = 1, n - 1
361  jp = ( j*( j-1 ) ) / 2
362  jp1 = jp + j
363  IF( kband.EQ.1 ) THEN
364  work( jp1+j ) = ( one-tau( j ) )*e( j )
365  DO 50 jr = 1, j - 1
366  work( jp1+jr ) = -tau( j )*e( j )*vp( jp1+jr )
367  50 CONTINUE
368  END IF
369 *
370  IF( tau( j ).NE.zero ) THEN
371  vsave = vp( jp1+j )
372  vp( jp1+j ) = one
373  CALL sspmv( 'U', j, one, work, vp( jp1+1 ), 1, zero,
374  \$ work( lap+1 ), 1 )
375  temp = -half*tau( j )*sdot( j, work( lap+1 ), 1,
376  \$ vp( jp1+1 ), 1 )
377  CALL saxpy( j, temp, vp( jp1+1 ), 1, work( lap+1 ),
378  \$ 1 )
379  CALL sspr2( 'U', j, -tau( j ), vp( jp1+1 ), 1,
380  \$ work( lap+1 ), 1, work )
381  vp( jp1+j ) = vsave
382  END IF
383  work( jp1+j+1 ) = d( j+1 )
384  60 CONTINUE
385  END IF
386 *
387  DO 70 j = 1, lap
388  work( j ) = work( j ) - ap( j )
389  70 CONTINUE
390  wnorm = slansp( '1', cuplo, n, work, work( lap+1 ) )
391 *
392  ELSE IF( itype.EQ.3 ) THEN
393 *
394 * ITYPE=3: error = U V**T - I
395 *
396  IF( n.LT.2 )
397  \$ RETURN
398  CALL slacpy( ' ', n, n, u, ldu, work, n )
399  CALL sopmtr( 'R', cuplo, 'T', n, n, vp, tau, work, n,
400  \$ work( n**2+1 ), iinfo )
401  IF( iinfo.NE.0 ) THEN
402  result( 1 ) = ten / ulp
403  RETURN
404  END IF
405 *
406  DO 80 j = 1, n
407  work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - one
408  80 CONTINUE
409 *
410  wnorm = slange( '1', n, n, work, n, work( n**2+1 ) )
411  END IF
412 *
413  IF( anorm.GT.wnorm ) THEN
414  result( 1 ) = ( wnorm / anorm ) / ( n*ulp )
415  ELSE
416  IF( anorm.LT.one ) THEN
417  result( 1 ) = ( min( wnorm, n*anorm ) / anorm ) / ( n*ulp )
418  ELSE
419  result( 1 ) = min( wnorm / anorm, real( n ) ) / ( n*ulp )
420  END IF
421  END IF
422 *
423 * Do Test 2
424 *
425 * Compute U U**T - I
426 *
427  IF( itype.EQ.1 ) THEN
428  CALL sgemm( 'N', 'C', n, n, n, one, u, ldu, u, ldu, zero, work,
429  \$ n )
430 *
431  DO 90 j = 1, n
432  work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - one
433  90 CONTINUE
434 *
435  result( 2 ) = min( slange( '1', n, n, work, n,
436  \$ work( n**2+1 ) ), real( n ) ) / ( n*ulp )
437  END IF
438 *
439  RETURN
440 *
441 * End of SSPT21
442 *
Here is the call graph for this function:
Here is the caller graph for this function:
sspr2
subroutine sspr2(UPLO, N, ALPHA, X, INCX, Y, INCY, AP)
SSPR2
Definition: sspr2.f:144
sspmv
subroutine sspmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
SSPMV
Definition: sspmv.f:149
sgemm
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
sspr
subroutine sspr(UPLO, N, ALPHA, X, INCX, AP)
SSPR
Definition: sspr.f:129
slacpy
subroutine slacpy(UPLO, M, N, A, LDA, B, LDB)
SLACPY copies all or part of one two-dimensional array to another.
Definition: slacpy.f:105
scopy
subroutine scopy(N, SX, INCX, SY, INCY)
SCOPY
Definition: scopy.f:84
sopmtr
subroutine sopmtr(SIDE, UPLO, TRANS, M, N, AP, TAU, C, LDC, WORK, INFO)
SOPMTR
Definition: sopmtr.f:152
slaset
subroutine slaset(UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: slaset.f:112
saxpy
subroutine saxpy(N, SA, SX, INCX, SY, INCY)
SAXPY
Definition: saxpy.f:91