You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ssyt22.f 8.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. *> \brief \b SSYT22
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE SSYT22( ITYPE, UPLO, N, M, KBAND, A, LDA, D, E, U, LDU,
  12. * V, LDV, TAU, WORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER ITYPE, KBAND, LDA, LDU, LDV, M, N
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL A( LDA, * ), D( * ), E( * ), RESULT( 2 ),
  20. * $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> SSYT22 generally checks a decomposition of the form
  30. *>
  31. *> A U = U S
  32. *>
  33. *> where A is symmetric, the columns of U are orthonormal, and S
  34. *> is diagonal (if KBAND=0) or symmetric tridiagonal (if
  35. *> KBAND=1). If ITYPE=1, then U is represented as a dense matrix,
  36. *> otherwise the U is expressed as a product of Householder
  37. *> transformations, whose vectors are stored in the array "V" and
  38. *> whose scaling constants are in "TAU"; we shall use the letter
  39. *> "V" to refer to the product of Householder transformations
  40. *> (which should be equal to U).
  41. *>
  42. *> Specifically, if ITYPE=1, then:
  43. *>
  44. *> RESULT(1) = | U' A U - S | / ( |A| m ulp ) *andC> RESULT(2) = | I - U'U | / ( m ulp )
  45. *> \endverbatim
  46. *
  47. * Arguments:
  48. * ==========
  49. *
  50. *> \verbatim
  51. *> ITYPE INTEGER
  52. *> Specifies the type of tests to be performed.
  53. *> 1: U expressed as a dense orthogonal matrix:
  54. *> RESULT(1) = | A - U S U' | / ( |A| n ulp ) *andC> RESULT(2) = | I - UU' | / ( n ulp )
  55. *>
  56. *> UPLO CHARACTER
  57. *> If UPLO='U', the upper triangle of A will be used and the
  58. *> (strictly) lower triangle will not be referenced. If
  59. *> UPLO='L', the lower triangle of A will be used and the
  60. *> (strictly) upper triangle will not be referenced.
  61. *> Not modified.
  62. *>
  63. *> N INTEGER
  64. *> The size of the matrix. If it is zero, SSYT22 does nothing.
  65. *> It must be at least zero.
  66. *> Not modified.
  67. *>
  68. *> M INTEGER
  69. *> The number of columns of U. If it is zero, SSYT22 does
  70. *> nothing. It must be at least zero.
  71. *> Not modified.
  72. *>
  73. *> KBAND INTEGER
  74. *> The bandwidth of the matrix. It may only be zero or one.
  75. *> If zero, then S is diagonal, and E is not referenced. If
  76. *> one, then S is symmetric tri-diagonal.
  77. *> Not modified.
  78. *>
  79. *> A REAL array, dimension (LDA , N)
  80. *> The original (unfactored) matrix. It is assumed to be
  81. *> symmetric, and only the upper (UPLO='U') or only the lower
  82. *> (UPLO='L') will be referenced.
  83. *> Not modified.
  84. *>
  85. *> LDA INTEGER
  86. *> The leading dimension of A. It must be at least 1
  87. *> and at least N.
  88. *> Not modified.
  89. *>
  90. *> D REAL array, dimension (N)
  91. *> The diagonal of the (symmetric tri-) diagonal matrix.
  92. *> Not modified.
  93. *>
  94. *> E REAL array, dimension (N)
  95. *> The off-diagonal of the (symmetric tri-) diagonal matrix.
  96. *> E(1) is ignored, E(2) is the (1,2) and (2,1) element, etc.
  97. *> Not referenced if KBAND=0.
  98. *> Not modified.
  99. *>
  100. *> U REAL array, dimension (LDU, N)
  101. *> If ITYPE=1 or 3, this contains the orthogonal matrix in
  102. *> the decomposition, expressed as a dense matrix. If ITYPE=2,
  103. *> then it is not referenced.
  104. *> Not modified.
  105. *>
  106. *> LDU INTEGER
  107. *> The leading dimension of U. LDU must be at least N and
  108. *> at least 1.
  109. *> Not modified.
  110. *>
  111. *> V REAL array, dimension (LDV, N)
  112. *> If ITYPE=2 or 3, the lower triangle of this array contains
  113. *> the Householder vectors used to describe the orthogonal
  114. *> matrix in the decomposition. If ITYPE=1, then it is not
  115. *> referenced.
  116. *> Not modified.
  117. *>
  118. *> LDV INTEGER
  119. *> The leading dimension of V. LDV must be at least N and
  120. *> at least 1.
  121. *> Not modified.
  122. *>
  123. *> TAU REAL array, dimension (N)
  124. *> If ITYPE >= 2, then TAU(j) is the scalar factor of
  125. *> v(j) v(j)' in the Householder transformation H(j) of
  126. *> the product U = H(1)...H(n-2)
  127. *> If ITYPE < 2, then TAU is not referenced.
  128. *> Not modified.
  129. *>
  130. *> WORK REAL array, dimension (2*N**2)
  131. *> Workspace.
  132. *> Modified.
  133. *>
  134. *> RESULT REAL array, dimension (2)
  135. *> The values computed by the two tests described above. The
  136. *> values are currently limited to 1/ulp, to avoid overflow.
  137. *> RESULT(1) is always modified. RESULT(2) is modified only
  138. *> if LDU is at least N.
  139. *> Modified.
  140. *> \endverbatim
  141. *
  142. * Authors:
  143. * ========
  144. *
  145. *> \author Univ. of Tennessee
  146. *> \author Univ. of California Berkeley
  147. *> \author Univ. of Colorado Denver
  148. *> \author NAG Ltd.
  149. *
  150. *> \date December 2016
  151. *
  152. *> \ingroup single_eig
  153. *
  154. * =====================================================================
  155. SUBROUTINE SSYT22( ITYPE, UPLO, N, M, KBAND, A, LDA, D, E, U, LDU,
  156. $ V, LDV, TAU, WORK, RESULT )
  157. *
  158. * -- LAPACK test routine (version 3.7.0) --
  159. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  160. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  161. * December 2016
  162. *
  163. * .. Scalar Arguments ..
  164. CHARACTER UPLO
  165. INTEGER ITYPE, KBAND, LDA, LDU, LDV, M, N
  166. * ..
  167. * .. Array Arguments ..
  168. REAL A( LDA, * ), D( * ), E( * ), RESULT( 2 ),
  169. $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
  170. * ..
  171. *
  172. * =====================================================================
  173. *
  174. * .. Parameters ..
  175. REAL ZERO, ONE
  176. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  177. * ..
  178. * .. Local Scalars ..
  179. INTEGER J, JJ, JJ1, JJ2, NN, NNP1
  180. REAL ANORM, ULP, UNFL, WNORM
  181. * ..
  182. * .. External Functions ..
  183. REAL SLAMCH, SLANSY
  184. EXTERNAL SLAMCH, SLANSY
  185. * ..
  186. * .. External Subroutines ..
  187. EXTERNAL SGEMM, SSYMM
  188. * ..
  189. * .. Intrinsic Functions ..
  190. INTRINSIC MAX, MIN, REAL
  191. * ..
  192. * .. Executable Statements ..
  193. *
  194. RESULT( 1 ) = ZERO
  195. RESULT( 2 ) = ZERO
  196. IF( N.LE.0 .OR. M.LE.0 )
  197. $ RETURN
  198. *
  199. UNFL = SLAMCH( 'Safe minimum' )
  200. ULP = SLAMCH( 'Precision' )
  201. *
  202. * Do Test 1
  203. *
  204. * Norm of A:
  205. *
  206. ANORM = MAX( SLANSY( '1', UPLO, N, A, LDA, WORK ), UNFL )
  207. *
  208. * Compute error matrix:
  209. *
  210. * ITYPE=1: error = U' A U - S
  211. *
  212. CALL SSYMM( 'L', UPLO, N, M, ONE, A, LDA, U, LDU, ZERO, WORK, N )
  213. NN = N*N
  214. NNP1 = NN + 1
  215. CALL SGEMM( 'T', 'N', M, M, N, ONE, U, LDU, WORK, N, ZERO,
  216. $ WORK( NNP1 ), N )
  217. DO 10 J = 1, M
  218. JJ = NN + ( J-1 )*N + J
  219. WORK( JJ ) = WORK( JJ ) - D( J )
  220. 10 CONTINUE
  221. IF( KBAND.EQ.1 .AND. N.GT.1 ) THEN
  222. DO 20 J = 2, M
  223. JJ1 = NN + ( J-1 )*N + J - 1
  224. JJ2 = NN + ( J-2 )*N + J
  225. WORK( JJ1 ) = WORK( JJ1 ) - E( J-1 )
  226. WORK( JJ2 ) = WORK( JJ2 ) - E( J-1 )
  227. 20 CONTINUE
  228. END IF
  229. WNORM = SLANSY( '1', UPLO, M, WORK( NNP1 ), N, WORK( 1 ) )
  230. *
  231. IF( ANORM.GT.WNORM ) THEN
  232. RESULT( 1 ) = ( WNORM / ANORM ) / ( M*ULP )
  233. ELSE
  234. IF( ANORM.LT.ONE ) THEN
  235. RESULT( 1 ) = ( MIN( WNORM, M*ANORM ) / ANORM ) / ( M*ULP )
  236. ELSE
  237. RESULT( 1 ) = MIN( WNORM / ANORM, REAL( M ) ) / ( M*ULP )
  238. END IF
  239. END IF
  240. *
  241. * Do Test 2
  242. *
  243. * Compute U'U - I
  244. *
  245. IF( ITYPE.EQ.1 )
  246. $ CALL SORT01( 'Columns', N, M, U, LDU, WORK, 2*N*N,
  247. $ RESULT( 2 ) )
  248. *
  249. RETURN
  250. *
  251. * End of SSYT22
  252. *
  253. END