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.

sla_syamv.f 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. *> \brief \b SLA_SYAMV computes a matrix-vector product using a symmetric indefinite matrix to calculate error bounds.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLA_SYAMV + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sla_syamv.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sla_syamv.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sla_syamv.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SLA_SYAMV( UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y,
  22. * INCY )
  23. *
  24. * .. Scalar Arguments ..
  25. * REAL ALPHA, BETA
  26. * INTEGER INCX, INCY, LDA, N, UPLO
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL A( LDA, * ), X( * ), Y( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> SLA_SYAMV performs the matrix-vector operation
  39. *>
  40. *> y := alpha*abs(A)*abs(x) + beta*abs(y),
  41. *>
  42. *> where alpha and beta are scalars, x and y are vectors and A is an
  43. *> n by n symmetric matrix.
  44. *>
  45. *> This function is primarily used in calculating error bounds.
  46. *> To protect against underflow during evaluation, components in
  47. *> the resulting vector are perturbed away from zero by (N+1)
  48. *> times the underflow threshold. To prevent unnecessarily large
  49. *> errors for block-structure embedded in general matrices,
  50. *> "symbolically" zero components are not perturbed. A zero
  51. *> entry is considered "symbolic" if all multiplications involved
  52. *> in computing that entry have at least one zero multiplicand.
  53. *> \endverbatim
  54. *
  55. * Arguments:
  56. * ==========
  57. *
  58. *> \param[in] UPLO
  59. *> \verbatim
  60. *> UPLO is INTEGER
  61. *> On entry, UPLO specifies whether the upper or lower
  62. *> triangular part of the array A is to be referenced as
  63. *> follows:
  64. *>
  65. *> UPLO = BLAS_UPPER Only the upper triangular part of A
  66. *> is to be referenced.
  67. *>
  68. *> UPLO = BLAS_LOWER Only the lower triangular part of A
  69. *> is to be referenced.
  70. *>
  71. *> Unchanged on exit.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] N
  75. *> \verbatim
  76. *> N is INTEGER
  77. *> On entry, N specifies the number of columns of the matrix A.
  78. *> N must be at least zero.
  79. *> Unchanged on exit.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] ALPHA
  83. *> \verbatim
  84. *> ALPHA is REAL .
  85. *> On entry, ALPHA specifies the scalar alpha.
  86. *> Unchanged on exit.
  87. *> \endverbatim
  88. *>
  89. *> \param[in] A
  90. *> \verbatim
  91. *> A is REAL array, dimension ( LDA, n ).
  92. *> Before entry, the leading m by n part of the array A must
  93. *> contain the matrix of coefficients.
  94. *> Unchanged on exit.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] LDA
  98. *> \verbatim
  99. *> LDA is INTEGER
  100. *> On entry, LDA specifies the first dimension of A as declared
  101. *> in the calling (sub) program. LDA must be at least
  102. *> max( 1, n ).
  103. *> Unchanged on exit.
  104. *> \endverbatim
  105. *>
  106. *> \param[in] X
  107. *> \verbatim
  108. *> X is REAL array, dimension
  109. *> ( 1 + ( n - 1 )*abs( INCX ) )
  110. *> Before entry, the incremented array X must contain the
  111. *> vector x.
  112. *> Unchanged on exit.
  113. *> \endverbatim
  114. *>
  115. *> \param[in] INCX
  116. *> \verbatim
  117. *> INCX is INTEGER
  118. *> On entry, INCX specifies the increment for the elements of
  119. *> X. INCX must not be zero.
  120. *> Unchanged on exit.
  121. *> \endverbatim
  122. *>
  123. *> \param[in] BETA
  124. *> \verbatim
  125. *> BETA is REAL .
  126. *> On entry, BETA specifies the scalar beta. When BETA is
  127. *> supplied as zero then Y need not be set on input.
  128. *> Unchanged on exit.
  129. *> \endverbatim
  130. *>
  131. *> \param[in,out] Y
  132. *> \verbatim
  133. *> Y is REAL array, dimension
  134. *> ( 1 + ( n - 1 )*abs( INCY ) )
  135. *> Before entry with BETA non-zero, the incremented array Y
  136. *> must contain the vector y. On exit, Y is overwritten by the
  137. *> updated vector y.
  138. *> \endverbatim
  139. *>
  140. *> \param[in] INCY
  141. *> \verbatim
  142. *> INCY is INTEGER
  143. *> On entry, INCY specifies the increment for the elements of
  144. *> Y. INCY must not be zero.
  145. *> Unchanged on exit.
  146. *> \endverbatim
  147. *
  148. * Authors:
  149. * ========
  150. *
  151. *> \author Univ. of Tennessee
  152. *> \author Univ. of California Berkeley
  153. *> \author Univ. of Colorado Denver
  154. *> \author NAG Ltd.
  155. *
  156. *> \date June 2017
  157. *
  158. *> \ingroup realSYcomputational
  159. *
  160. *> \par Further Details:
  161. * =====================
  162. *>
  163. *> \verbatim
  164. *>
  165. *> Level 2 Blas routine.
  166. *>
  167. *> -- Written on 22-October-1986.
  168. *> Jack Dongarra, Argonne National Lab.
  169. *> Jeremy Du Croz, Nag Central Office.
  170. *> Sven Hammarling, Nag Central Office.
  171. *> Richard Hanson, Sandia National Labs.
  172. *> -- Modified for the absolute-value product, April 2006
  173. *> Jason Riedy, UC Berkeley
  174. *> \endverbatim
  175. *>
  176. * =====================================================================
  177. SUBROUTINE SLA_SYAMV( UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y,
  178. $ INCY )
  179. *
  180. * -- LAPACK computational routine (version 3.7.1) --
  181. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  182. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  183. * June 2017
  184. *
  185. * .. Scalar Arguments ..
  186. REAL ALPHA, BETA
  187. INTEGER INCX, INCY, LDA, N, UPLO
  188. * ..
  189. * .. Array Arguments ..
  190. REAL A( LDA, * ), X( * ), Y( * )
  191. * ..
  192. *
  193. * =====================================================================
  194. *
  195. * .. Parameters ..
  196. REAL ONE, ZERO
  197. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  198. * ..
  199. * .. Local Scalars ..
  200. LOGICAL SYMB_ZERO
  201. REAL TEMP, SAFE1
  202. INTEGER I, INFO, IY, J, JX, KX, KY
  203. * ..
  204. * .. External Subroutines ..
  205. EXTERNAL XERBLA, SLAMCH
  206. REAL SLAMCH
  207. * ..
  208. * .. External Functions ..
  209. EXTERNAL ILAUPLO
  210. INTEGER ILAUPLO
  211. * ..
  212. * .. Intrinsic Functions ..
  213. INTRINSIC MAX, ABS, SIGN
  214. * ..
  215. * .. Executable Statements ..
  216. *
  217. * Test the input parameters.
  218. *
  219. INFO = 0
  220. IF ( UPLO.NE.ILAUPLO( 'U' ) .AND.
  221. $ UPLO.NE.ILAUPLO( 'L' ) ) THEN
  222. INFO = 1
  223. ELSE IF( N.LT.0 )THEN
  224. INFO = 2
  225. ELSE IF( LDA.LT.MAX( 1, N ) )THEN
  226. INFO = 5
  227. ELSE IF( INCX.EQ.0 )THEN
  228. INFO = 7
  229. ELSE IF( INCY.EQ.0 )THEN
  230. INFO = 10
  231. END IF
  232. IF( INFO.NE.0 )THEN
  233. CALL XERBLA( 'SLA_SYAMV', INFO )
  234. RETURN
  235. END IF
  236. *
  237. * Quick return if possible.
  238. *
  239. IF( ( N.EQ.0 ).OR.( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
  240. $ RETURN
  241. *
  242. * Set up the start points in X and Y.
  243. *
  244. IF( INCX.GT.0 )THEN
  245. KX = 1
  246. ELSE
  247. KX = 1 - ( N - 1 )*INCX
  248. END IF
  249. IF( INCY.GT.0 )THEN
  250. KY = 1
  251. ELSE
  252. KY = 1 - ( N - 1 )*INCY
  253. END IF
  254. *
  255. * Set SAFE1 essentially to be the underflow threshold times the
  256. * number of additions in each row.
  257. *
  258. SAFE1 = SLAMCH( 'Safe minimum' )
  259. SAFE1 = (N+1)*SAFE1
  260. *
  261. * Form y := alpha*abs(A)*abs(x) + beta*abs(y).
  262. *
  263. * The O(N^2) SYMB_ZERO tests could be replaced by O(N) queries to
  264. * the inexact flag. Still doesn't help change the iteration order
  265. * to per-column.
  266. *
  267. IY = KY
  268. IF ( INCX.EQ.1 ) THEN
  269. IF ( UPLO .EQ. ILAUPLO( 'U' ) ) THEN
  270. DO I = 1, N
  271. IF ( BETA .EQ. ZERO ) THEN
  272. SYMB_ZERO = .TRUE.
  273. Y( IY ) = 0.0
  274. ELSE IF ( Y( IY ) .EQ. ZERO ) THEN
  275. SYMB_ZERO = .TRUE.
  276. ELSE
  277. SYMB_ZERO = .FALSE.
  278. Y( IY ) = BETA * ABS( Y( IY ) )
  279. END IF
  280. IF ( ALPHA .NE. ZERO ) THEN
  281. DO J = 1, I
  282. TEMP = ABS( A( J, I ) )
  283. SYMB_ZERO = SYMB_ZERO .AND.
  284. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  285. Y( IY ) = Y( IY ) + ALPHA*ABS( X( J ) )*TEMP
  286. END DO
  287. DO J = I+1, N
  288. TEMP = ABS( A( I, J ) )
  289. SYMB_ZERO = SYMB_ZERO .AND.
  290. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  291. Y( IY ) = Y( IY ) + ALPHA*ABS( X( J ) )*TEMP
  292. END DO
  293. END IF
  294. IF ( .NOT.SYMB_ZERO )
  295. $ Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
  296. IY = IY + INCY
  297. END DO
  298. ELSE
  299. DO I = 1, N
  300. IF ( BETA .EQ. ZERO ) THEN
  301. SYMB_ZERO = .TRUE.
  302. Y( IY ) = 0.0
  303. ELSE IF ( Y( IY ) .EQ. ZERO ) THEN
  304. SYMB_ZERO = .TRUE.
  305. ELSE
  306. SYMB_ZERO = .FALSE.
  307. Y( IY ) = BETA * ABS( Y( IY ) )
  308. END IF
  309. IF ( ALPHA .NE. ZERO ) THEN
  310. DO J = 1, I
  311. TEMP = ABS( A( I, J ) )
  312. SYMB_ZERO = SYMB_ZERO .AND.
  313. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  314. Y( IY ) = Y( IY ) + ALPHA*ABS( X( J ) )*TEMP
  315. END DO
  316. DO J = I+1, N
  317. TEMP = ABS( A( J, I ) )
  318. SYMB_ZERO = SYMB_ZERO .AND.
  319. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  320. Y( IY ) = Y( IY ) + ALPHA*ABS( X( J ) )*TEMP
  321. END DO
  322. END IF
  323. IF ( .NOT.SYMB_ZERO )
  324. $ Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
  325. IY = IY + INCY
  326. END DO
  327. END IF
  328. ELSE
  329. IF ( UPLO .EQ. ILAUPLO( 'U' ) ) THEN
  330. DO I = 1, N
  331. IF ( BETA .EQ. ZERO ) THEN
  332. SYMB_ZERO = .TRUE.
  333. Y( IY ) = 0.0
  334. ELSE IF ( Y( IY ) .EQ. ZERO ) THEN
  335. SYMB_ZERO = .TRUE.
  336. ELSE
  337. SYMB_ZERO = .FALSE.
  338. Y( IY ) = BETA * ABS( Y( IY ) )
  339. END IF
  340. JX = KX
  341. IF ( ALPHA .NE. ZERO ) THEN
  342. DO J = 1, I
  343. TEMP = ABS( A( J, I ) )
  344. SYMB_ZERO = SYMB_ZERO .AND.
  345. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  346. Y( IY ) = Y( IY ) + ALPHA*ABS( X( JX ) )*TEMP
  347. JX = JX + INCX
  348. END DO
  349. DO J = I+1, N
  350. TEMP = ABS( A( I, J ) )
  351. SYMB_ZERO = SYMB_ZERO .AND.
  352. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  353. Y( IY ) = Y( IY ) + ALPHA*ABS( X( JX ) )*TEMP
  354. JX = JX + INCX
  355. END DO
  356. END IF
  357. IF ( .NOT.SYMB_ZERO )
  358. $ Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
  359. IY = IY + INCY
  360. END DO
  361. ELSE
  362. DO I = 1, N
  363. IF ( BETA .EQ. ZERO ) THEN
  364. SYMB_ZERO = .TRUE.
  365. Y( IY ) = 0.0
  366. ELSE IF ( Y( IY ) .EQ. ZERO ) THEN
  367. SYMB_ZERO = .TRUE.
  368. ELSE
  369. SYMB_ZERO = .FALSE.
  370. Y( IY ) = BETA * ABS( Y( IY ) )
  371. END IF
  372. JX = KX
  373. IF ( ALPHA .NE. ZERO ) THEN
  374. DO J = 1, I
  375. TEMP = ABS( A( I, J ) )
  376. SYMB_ZERO = SYMB_ZERO .AND.
  377. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  378. Y( IY ) = Y( IY ) + ALPHA*ABS( X( JX ) )*TEMP
  379. JX = JX + INCX
  380. END DO
  381. DO J = I+1, N
  382. TEMP = ABS( A( J, I ) )
  383. SYMB_ZERO = SYMB_ZERO .AND.
  384. $ ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
  385. Y( IY ) = Y( IY ) + ALPHA*ABS( X( JX ) )*TEMP
  386. JX = JX + INCX
  387. END DO
  388. END IF
  389. IF ( .NOT.SYMB_ZERO )
  390. $ Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
  391. IY = IY + INCY
  392. END DO
  393. END IF
  394. END IF
  395. *
  396. RETURN
  397. *
  398. * End of SLA_SYAMV
  399. *
  400. END