Télécharger dsyr2k.eso

Retour à la liste

Numérotation des lignes :

dsyr2k
  1. C DSYR2K SOURCE BP208322 22/09/16 21:15:08 11454
  2. *> \brief \b DSYR2K
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. * Definition:
  10. * ===========
  11. *
  12. * SUBROUTINE DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
  13. *
  14. * .. Scalar Arguments ..
  15. * REAL*8 ALPHA,BETA
  16. * INTEGER K,LDA,LDB,LDC,N
  17. * CHARACTER TRANS,UPLO
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL*8 A(LDA,*),B(LDB,*),C(LDC,*)
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> DSYR2K performs one of the symmetric rank 2k operations
  30. *>
  31. *> C := alpha*A*B**T + alpha*B*A**T + beta*C,
  32. *>
  33. *> or
  34. *>
  35. *> C := alpha*A**T*B + alpha*B**T*A + beta*C,
  36. *>
  37. *> where alpha and beta are scalars, C is an n by n symmetric matrix
  38. *> and A and B are n by k matrices in the first case and k by n
  39. *> matrices in the second case.
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] UPLO
  46. *> \verbatim
  47. *> UPLO is CHARACTER*1
  48. *> On entry, UPLO specifies whether the upper or lower
  49. *> triangular part of the array C is to be referenced as
  50. *> follows:
  51. *>
  52. *> UPLO = 'U' or 'u' Only the upper triangular part of C
  53. *> is to be referenced.
  54. *>
  55. *> UPLO = 'L' or 'l' Only the lower triangular part of C
  56. *> is to be referenced.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] TRANS
  60. *> \verbatim
  61. *> TRANS is CHARACTER*1
  62. *> On entry, TRANS specifies the operation to be performed as
  63. *> follows:
  64. *>
  65. *> TRANS = 'N' or 'n' C := alpha*A*B**T + alpha*B*A**T +
  66. *> beta*C.
  67. *>
  68. *> TRANS = 'T' or 't' C := alpha*A**T*B + alpha*B**T*A +
  69. *> beta*C.
  70. *>
  71. *> TRANS = 'C' or 'c' C := alpha*A**T*B + alpha*B**T*A +
  72. *> beta*C.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] N
  76. *> \verbatim
  77. *> N is INTEGER
  78. *> On entry, N specifies the order of the matrix C. N must be
  79. *> at least zero.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] K
  83. *> \verbatim
  84. *> K is INTEGER
  85. *> On entry with TRANS = 'N' or 'n', K specifies the number
  86. *> of columns of the matrices A and B, and on entry with
  87. *> TRANS = 'T' or 't' or 'C' or 'c', K specifies the number
  88. *> of rows of the matrices A and B. K must be at least zero.
  89. *> \endverbatim
  90. *>
  91. *> \param[in] ALPHA
  92. *> \verbatim
  93. *> ALPHA is REAL*8.
  94. *> On entry, ALPHA specifies the scalar alpha.
  95. *> \endverbatim
  96. *>
  97. *> \param[in] A
  98. *> \verbatim
  99. *> A is REAL*8 array, dimension ( LDA, ka ), where ka is
  100. *> k when TRANS = 'N' or 'n', and is n otherwise.
  101. *> Before entry with TRANS = 'N' or 'n', the leading n by k
  102. *> part of the array A must contain the matrix A, otherwise
  103. *> the leading k by n part of the array A must contain the
  104. *> matrix A.
  105. *> \endverbatim
  106. *>
  107. *> \param[in] LDA
  108. *> \verbatim
  109. *> LDA is INTEGER
  110. *> On entry, LDA specifies the first dimension of A as declared
  111. *> in the calling (sub) program. When TRANS = 'N' or 'n'
  112. *> then LDA must be at least max( 1, n ), otherwise LDA must
  113. *> be at least max( 1, k ).
  114. *> \endverbatim
  115. *>
  116. *> \param[in] B
  117. *> \verbatim
  118. *> B is REAL*8 array, dimension ( LDB, kb ), where kb is
  119. *> k when TRANS = 'N' or 'n', and is n otherwise.
  120. *> Before entry with TRANS = 'N' or 'n', the leading n by k
  121. *> part of the array B must contain the matrix B, otherwise
  122. *> the leading k by n part of the array B must contain the
  123. *> matrix B.
  124. *> \endverbatim
  125. *>
  126. *> \param[in] LDB
  127. *> \verbatim
  128. *> LDB is INTEGER
  129. *> On entry, LDB specifies the first dimension of B as declared
  130. *> in the calling (sub) program. When TRANS = 'N' or 'n'
  131. *> then LDB must be at least max( 1, n ), otherwise LDB must
  132. *> be at least max( 1, k ).
  133. *> \endverbatim
  134. *>
  135. *> \param[in] BETA
  136. *> \verbatim
  137. *> BETA is REAL*8.
  138. *> On entry, BETA specifies the scalar beta.
  139. *> \endverbatim
  140. *>
  141. *> \param[in,out] C
  142. *> \verbatim
  143. *> C is REAL*8 array, dimension ( LDC, N )
  144. *> Before entry with UPLO = 'U' or 'u', the leading n by n
  145. *> upper triangular part of the array C must contain the upper
  146. *> triangular part of the symmetric matrix and the strictly
  147. *> lower triangular part of C is not referenced. On exit, the
  148. *> upper triangular part of the array C is overwritten by the
  149. *> upper triangular part of the updated matrix.
  150. *> Before entry with UPLO = 'L' or 'l', the leading n by n
  151. *> lower triangular part of the array C must contain the lower
  152. *> triangular part of the symmetric matrix and the strictly
  153. *> upper triangular part of C is not referenced. On exit, the
  154. *> lower triangular part of the array C is overwritten by the
  155. *> lower triangular part of the updated matrix.
  156. *> \endverbatim
  157. *>
  158. *> \param[in] LDC
  159. *> \verbatim
  160. *> LDC is INTEGER
  161. *> On entry, LDC specifies the first dimension of C as declared
  162. *> in the calling (sub) program. LDC must be at least
  163. *> max( 1, n ).
  164. *> \endverbatim
  165. *
  166. * Authors:
  167. * ========
  168. *
  169. *> \author Univ. of Tennessee
  170. *> \author Univ. of California Berkeley
  171. *> \author Univ. of Colorado Denver
  172. *> \author NAG Ltd.
  173. *
  174. *> \ingroup double_blas_level3
  175. *
  176. *> \par Further Details:
  177. * =====================
  178. *>
  179. *> \verbatim
  180. *>
  181. *> Level 3 Blas routine.
  182. *>
  183. *>
  184. *> -- Written on 8-February-1989.
  185. *> Jack Dongarra, Argonne National Laboratory.
  186. *> Iain Duff, AERE Harwell.
  187. *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
  188. *> Sven Hammarling, Numerical Algorithms Group Ltd.
  189. *> \endverbatim
  190. *>
  191. * =====================================================================
  192. SUBROUTINE DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
  193. *
  194. * -- Reference BLAS level3 routine --
  195. * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
  196. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  197. *
  198. * .. Scalar Arguments ..
  199. REAL*8 ALPHA,BETA
  200. INTEGER K,LDA,LDB,LDC,N
  201. CHARACTER TRANS,UPLO
  202. * ..
  203. * .. Array Arguments ..
  204. REAL*8 A(LDA,*),B(LDB,*),C(LDC,*)
  205. * ..
  206. *
  207. * =====================================================================
  208. *
  209. * .. External Functions ..
  210. LOGICAL LSAME
  211. EXTERNAL LSAME
  212. * ..
  213. * .. External Subroutines ..
  214. EXTERNAL XERBLA
  215. * ..
  216. * .. Intrinsic Functions ..
  217. * INTRINSIC MAX
  218. * ..
  219. * .. Local Scalars ..
  220. REAL*8 TEMP1,TEMP2
  221. INTEGER I,INFO,J,L,NROWA
  222. LOGICAL UPPER
  223. * ..
  224. * .. Parameters ..
  225. REAL*8 ONE,ZERO
  226. PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
  227. * ..
  228. *
  229. * Test the input parameters.
  230. *
  231. IF (LSAME(TRANS,'N')) THEN
  232. NROWA = N
  233. ELSE
  234. NROWA = K
  235. END IF
  236. UPPER = LSAME(UPLO,'U')
  237. *
  238. INFO = 0
  239. IF ((.NOT.UPPER) .AND. (.NOT.LSAME(UPLO,'L'))) THEN
  240. INFO = 1
  241. ELSE IF ((.NOT.LSAME(TRANS,'N')) .AND.
  242. + (.NOT.LSAME(TRANS,'T')) .AND.
  243. + (.NOT.LSAME(TRANS,'C'))) THEN
  244. INFO = 2
  245. ELSE IF (N.LT.0) THEN
  246. INFO = 3
  247. ELSE IF (K.LT.0) THEN
  248. INFO = 4
  249. ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
  250. INFO = 7
  251. ELSE IF (LDB.LT.MAX(1,NROWA)) THEN
  252. INFO = 9
  253. ELSE IF (LDC.LT.MAX(1,N)) THEN
  254. INFO = 12
  255. END IF
  256. IF (INFO.NE.0) THEN
  257. CALL XERBLA('DSYR2K',INFO)
  258. RETURN
  259. END IF
  260. *
  261. * Quick return if possible.
  262. *
  263. IF ((N.EQ.0) .OR. (((ALPHA.EQ.ZERO).OR.
  264. + (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
  265. *
  266. * And when alpha.eq.zero.
  267. *
  268. IF (ALPHA.EQ.ZERO) THEN
  269. IF (UPPER) THEN
  270. IF (BETA.EQ.ZERO) THEN
  271. DO 20 J = 1,N
  272. DO 10 I = 1,J
  273. C(I,J) = ZERO
  274. 10 CONTINUE
  275. 20 CONTINUE
  276. ELSE
  277. DO 40 J = 1,N
  278. DO 30 I = 1,J
  279. C(I,J) = BETA*C(I,J)
  280. 30 CONTINUE
  281. 40 CONTINUE
  282. END IF
  283. ELSE
  284. IF (BETA.EQ.ZERO) THEN
  285. DO 60 J = 1,N
  286. DO 50 I = J,N
  287. C(I,J) = ZERO
  288. 50 CONTINUE
  289. 60 CONTINUE
  290. ELSE
  291. DO 80 J = 1,N
  292. DO 70 I = J,N
  293. C(I,J) = BETA*C(I,J)
  294. 70 CONTINUE
  295. 80 CONTINUE
  296. END IF
  297. END IF
  298. RETURN
  299. END IF
  300. *
  301. * Start the operations.
  302. *
  303. IF (LSAME(TRANS,'N')) THEN
  304. *
  305. * Form C := alpha*A*B**T + alpha*B*A**T + C.
  306. *
  307. IF (UPPER) THEN
  308. DO 130 J = 1,N
  309. IF (BETA.EQ.ZERO) THEN
  310. DO 90 I = 1,J
  311. C(I,J) = ZERO
  312. 90 CONTINUE
  313. ELSE IF (BETA.NE.ONE) THEN
  314. DO 100 I = 1,J
  315. C(I,J) = BETA*C(I,J)
  316. 100 CONTINUE
  317. END IF
  318. DO 120 L = 1,K
  319. IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
  320. TEMP1 = ALPHA*B(J,L)
  321. TEMP2 = ALPHA*A(J,L)
  322. DO 110 I = 1,J
  323. C(I,J) = C(I,J) + A(I,L)*TEMP1 +
  324. + B(I,L)*TEMP2
  325. 110 CONTINUE
  326. END IF
  327. 120 CONTINUE
  328. 130 CONTINUE
  329. ELSE
  330. DO 180 J = 1,N
  331. IF (BETA.EQ.ZERO) THEN
  332. DO 140 I = J,N
  333. C(I,J) = ZERO
  334. 140 CONTINUE
  335. ELSE IF (BETA.NE.ONE) THEN
  336. DO 150 I = J,N
  337. C(I,J) = BETA*C(I,J)
  338. 150 CONTINUE
  339. END IF
  340. DO 170 L = 1,K
  341. IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
  342. TEMP1 = ALPHA*B(J,L)
  343. TEMP2 = ALPHA*A(J,L)
  344. DO 160 I = J,N
  345. C(I,J) = C(I,J) + A(I,L)*TEMP1 +
  346. + B(I,L)*TEMP2
  347. 160 CONTINUE
  348. END IF
  349. 170 CONTINUE
  350. 180 CONTINUE
  351. END IF
  352. ELSE
  353. *
  354. * Form C := alpha*A**T*B + alpha*B**T*A + C.
  355. *
  356. IF (UPPER) THEN
  357. DO 210 J = 1,N
  358. DO 200 I = 1,J
  359. TEMP1 = ZERO
  360. TEMP2 = ZERO
  361. DO 190 L = 1,K
  362. TEMP1 = TEMP1 + A(L,I)*B(L,J)
  363. TEMP2 = TEMP2 + B(L,I)*A(L,J)
  364. 190 CONTINUE
  365. IF (BETA.EQ.ZERO) THEN
  366. C(I,J) = ALPHA*TEMP1 + ALPHA*TEMP2
  367. ELSE
  368. C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +
  369. + ALPHA*TEMP2
  370. END IF
  371. 200 CONTINUE
  372. 210 CONTINUE
  373. ELSE
  374. DO 240 J = 1,N
  375. DO 230 I = J,N
  376. TEMP1 = ZERO
  377. TEMP2 = ZERO
  378. DO 220 L = 1,K
  379. TEMP1 = TEMP1 + A(L,I)*B(L,J)
  380. TEMP2 = TEMP2 + B(L,I)*A(L,J)
  381. 220 CONTINUE
  382. IF (BETA.EQ.ZERO) THEN
  383. C(I,J) = ALPHA*TEMP1 + ALPHA*TEMP2
  384. ELSE
  385. C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +
  386. + ALPHA*TEMP2
  387. END IF
  388. 230 CONTINUE
  389. 240 CONTINUE
  390. END IF
  391. END IF
  392. *
  393. RETURN
  394. *
  395. * End of DSYR2K
  396. *
  397. END
  398.  
  399.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales