Télécharger dtrmm.eso

Retour à la liste

Numérotation des lignes :

dtrmm
  1. C DTRMM SOURCE BP208322 22/09/16 21:15:09 11454
  2. *
  3. * Purpose
  4. * =======
  5. *
  6. * DTRMM performs one of the matrix-matrix operations
  7. *
  8. * B := alpha*op( A )*B, or B := alpha*B*op( A ),
  9. *
  10. * where alpha is a scalar, B is an m by n matrix, A is a unit, or
  11. * non-unit, upper or lower triangular matrix and op( A ) is one of
  12. *
  13. * op( A ) = A or op( A ) = A'.
  14. *
  15. * Parameters
  16. * ==========
  17. *
  18. * SIDE - CHARACTER*1.
  19. * On entry, SIDE specifies whether op( A ) multiplies B from
  20. * the left or right as follows:
  21. *
  22. * SIDE = 'L' or 'l' B := alpha*op( A )*B.
  23. *
  24. * SIDE = 'R' or 'r' B := alpha*B*op( A ).
  25. *
  26. * Unchanged on exit.
  27. *
  28. * UPLO - CHARACTER*1.
  29. * On entry, UPLO specifies whether the matrix A is an upper or
  30. * lower triangular matrix as follows:
  31. *
  32. * UPLO = 'U' or 'u' A is an upper triangular matrix.
  33. *
  34. * UPLO = 'L' or 'l' A is a lower triangular matrix.
  35. *
  36. * Unchanged on exit.
  37. *
  38. * TRANSA - CHARACTER*1.
  39. * On entry, TRANSA specifies the form of op( A ) to be used in
  40. * the matrix multiplication as follows:
  41. *
  42. * TRANSA = 'N' or 'n' op( A ) = A.
  43. *
  44. * TRANSA = 'T' or 't' op( A ) = A'.
  45. *
  46. * TRANSA = 'C' or 'c' op( A ) = A'.
  47. *
  48. * Unchanged on exit.
  49. *
  50. * DIAG - CHARACTER*1.
  51. * On entry, DIAG specifies whether or not A is unit triangular
  52. * as follows:
  53. *
  54. * DIAG = 'U' or 'u' A is assumed to be unit triangular.
  55. *
  56. * DIAG = 'N' or 'n' A is not assumed to be unit
  57. * triangular.
  58. *
  59. * Unchanged on exit.
  60. *
  61. * M - INTEGER.
  62. * On entry, M specifies the number of rows of B. M must be at
  63. * least zero.
  64. * Unchanged on exit.
  65. *
  66. * N - INTEGER.
  67. * On entry, N specifies the number of columns of B. N must be
  68. * at least zero.
  69. * Unchanged on exit.
  70. *
  71. * ALPHA - REAL*8.
  72. * On entry, ALPHA specifies the scalar alpha. When alpha is
  73. * zero then A is not referenced and B need not be set before
  74. * entry.
  75. * Unchanged on exit.
  76. *
  77. * A - REAL*8 array of DIMENSION ( LDA, k ), where k is m
  78. * when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
  79. * Before entry with UPLO = 'U' or 'u', the leading k by k
  80. * upper triangular part of the array A must contain the upper
  81. * triangular matrix and the strictly lower triangular part of
  82. * A is not referenced.
  83. * Before entry with UPLO = 'L' or 'l', the leading k by k
  84. * lower triangular part of the array A must contain the lower
  85. * triangular matrix and the strictly upper triangular part of
  86. * A is not referenced.
  87. * Note that when DIAG = 'U' or 'u', the diagonal elements of
  88. * A are not referenced either, but are assumed to be unity.
  89. * Unchanged on exit.
  90. *
  91. * LDA - INTEGER.
  92. * On entry, LDA specifies the first dimension of A as declared
  93. * in the calling (sub) program. When SIDE = 'L' or 'l' then
  94. * LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
  95. * then LDA must be at least max( 1, n ).
  96. * Unchanged on exit.
  97. *
  98. * B - REAL*8 array of DIMENSION ( LDB, n ).
  99. * Before entry, the leading m by n part of the array B must
  100. * contain the matrix B, and on exit is overwritten by the
  101. * transformed matrix.
  102. *
  103. * LDB - INTEGER.
  104. * On entry, LDB specifies the first dimension of B as declared
  105. * in the calling (sub) program. LDB must be at least
  106. * max( 1, m ).
  107. * Unchanged on exit.
  108. *
  109. *
  110. * Level 3 Blas routine.
  111. *
  112. * -- Written on 8-February-1989.
  113. * Jack Dongarra, Argonne National Laboratory.
  114. * Iain Duff, AERE Harwell.
  115. * Jeremy Du Croz, Numerical Algorithms Group Ltd.
  116. * Sven Hammarling, Numerical Algorithms Group Ltd.
  117. *
  118. * =====================================================================
  119. SUBROUTINE DTRMM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA,
  120. $ B, LDB )
  121. *
  122. * .. Scalar Arguments ..
  123. CHARACTER*1 SIDE, UPLO, TRANSA, DIAG
  124. INTEGER M, N, LDA, LDB
  125. REAL*8 ALPHA
  126. * .. Array Arguments ..
  127. REAL*8 A( LDA, * ), B( LDB, * )
  128. * ..
  129. *
  130. * =====================================================================
  131. *
  132. *
  133. * .. External Functions ..
  134. LOGICAL LSAME
  135. EXTERNAL LSAME
  136. * .. External Subroutines ..
  137. EXTERNAL XERBLA
  138. ** .. Intrinsic Functions ..
  139. * INTRINSIC MAX
  140. ** .. Local Scalars ..
  141. LOGICAL LSIDE, NOUNIT, UPPER
  142. INTEGER I, INFO, J, K, NROWA
  143. REAL*8 TEMP
  144. ** .. Parameters ..
  145. REAL*8 ONE , ZERO
  146. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  147. ** ..
  148. ** .. Executable Statements ..
  149. *
  150. * Test the input parameters.
  151. *
  152. LSIDE = LSAME( SIDE , 'L' )
  153. IF( LSIDE )THEN
  154. NROWA = M
  155. ELSE
  156. NROWA = N
  157. END IF
  158. NOUNIT = LSAME( DIAG , 'N' )
  159. UPPER = LSAME( UPLO , 'U' )
  160. *
  161. INFO = 0
  162. IF( ( .NOT.LSIDE ).AND.
  163. $ ( .NOT.LSAME( SIDE , 'R' ) ) )THEN
  164. INFO = 1
  165. ELSE IF( ( .NOT.UPPER ).AND.
  166. $ ( .NOT.LSAME( UPLO , 'L' ) ) )THEN
  167. INFO = 2
  168. ELSE IF( ( .NOT.LSAME( TRANSA, 'N' ) ).AND.
  169. $ ( .NOT.LSAME( TRANSA, 'T' ) ).AND.
  170. $ ( .NOT.LSAME( TRANSA, 'C' ) ) )THEN
  171. INFO = 3
  172. ELSE IF( ( .NOT.LSAME( DIAG , 'U' ) ).AND.
  173. $ ( .NOT.LSAME( DIAG , 'N' ) ) )THEN
  174. INFO = 4
  175. ELSE IF( M .LT.0 )THEN
  176. INFO = 5
  177. ELSE IF( N .LT.0 )THEN
  178. INFO = 6
  179. ELSE IF( LDA.LT.MAX( 1, NROWA ) )THEN
  180. INFO = 9
  181. ELSE IF( LDB.LT.MAX( 1, M ) )THEN
  182. INFO = 11
  183. END IF
  184. IF( INFO.NE.0 )THEN
  185. CALL XERBLA( 'DTRMM ', INFO )
  186. RETURN
  187. END IF
  188. *
  189. * Quick return if possible.
  190. *
  191. IF( N.EQ.0 )
  192. $ RETURN
  193. *
  194. * And when alpha.eq.zero.
  195. *
  196. IF( ALPHA.EQ.ZERO )THEN
  197. DO 20, J = 1, N
  198. DO 10, I = 1, M
  199. B( I, J ) = ZERO
  200. 10 CONTINUE
  201. 20 CONTINUE
  202. RETURN
  203. END IF
  204. *
  205. * Start the operations.
  206. *
  207. IF( LSIDE )THEN
  208. IF( LSAME( TRANSA, 'N' ) )THEN
  209. *
  210. * Form B := alpha*A*B.
  211. *
  212. IF( UPPER )THEN
  213. DO 50, J = 1, N
  214. DO 40, K = 1, M
  215. IF( B( K, J ).NE.ZERO )THEN
  216. TEMP = ALPHA*B( K, J )
  217. DO 30, I = 1, K - 1
  218. B( I, J ) = B( I, J ) + TEMP*A( I, K )
  219. 30 CONTINUE
  220. IF( NOUNIT )
  221. $ TEMP = TEMP*A( K, K )
  222. B( K, J ) = TEMP
  223. END IF
  224. 40 CONTINUE
  225. 50 CONTINUE
  226. ELSE
  227. DO 80, J = 1, N
  228. DO 70 K = M, 1, -1
  229. IF( B( K, J ).NE.ZERO )THEN
  230. TEMP = ALPHA*B( K, J )
  231. B( K, J ) = TEMP
  232. IF( NOUNIT )
  233. $ B( K, J ) = B( K, J )*A( K, K )
  234. DO 60, I = K + 1, M
  235. B( I, J ) = B( I, J ) + TEMP*A( I, K )
  236. 60 CONTINUE
  237. END IF
  238. 70 CONTINUE
  239. 80 CONTINUE
  240. END IF
  241. ELSE
  242. *
  243. * Form B := alpha*B*A'.
  244. *
  245. IF( UPPER )THEN
  246. DO 110, J = 1, N
  247. DO 100, I = M, 1, -1
  248. TEMP = B( I, J )
  249. IF( NOUNIT )
  250. $ TEMP = TEMP*A( I, I )
  251. DO 90, K = 1, I - 1
  252. TEMP = TEMP + A( K, I )*B( K, J )
  253. 90 CONTINUE
  254. B( I, J ) = ALPHA*TEMP
  255. 100 CONTINUE
  256. 110 CONTINUE
  257. ELSE
  258. DO 140, J = 1, N
  259. DO 130, I = 1, M
  260. TEMP = B( I, J )
  261. IF( NOUNIT )
  262. $ TEMP = TEMP*A( I, I )
  263. DO 120, K = I + 1, M
  264. TEMP = TEMP + A( K, I )*B( K, J )
  265. 120 CONTINUE
  266. B( I, J ) = ALPHA*TEMP
  267. 130 CONTINUE
  268. 140 CONTINUE
  269. END IF
  270. END IF
  271. ELSE
  272. IF( LSAME( TRANSA, 'N' ) )THEN
  273. *
  274. * Form B := alpha*B*A.
  275. *
  276. IF( UPPER )THEN
  277. DO 180, J = N, 1, -1
  278. TEMP = ALPHA
  279. IF( NOUNIT )
  280. $ TEMP = TEMP*A( J, J )
  281. DO 150, I = 1, M
  282. B( I, J ) = TEMP*B( I, J )
  283. 150 CONTINUE
  284. DO 170, K = 1, J - 1
  285. IF( A( K, J ).NE.ZERO )THEN
  286. TEMP = ALPHA*A( K, J )
  287. DO 160, I = 1, M
  288. B( I, J ) = B( I, J ) + TEMP*B( I, K )
  289. 160 CONTINUE
  290. END IF
  291. 170 CONTINUE
  292. 180 CONTINUE
  293. ELSE
  294. DO 220, J = 1, N
  295. TEMP = ALPHA
  296. IF( NOUNIT )
  297. $ TEMP = TEMP*A( J, J )
  298. DO 190, I = 1, M
  299. B( I, J ) = TEMP*B( I, J )
  300. 190 CONTINUE
  301. DO 210, K = J + 1, N
  302. IF( A( K, J ).NE.ZERO )THEN
  303. TEMP = ALPHA*A( K, J )
  304. DO 200, I = 1, M
  305. B( I, J ) = B( I, J ) + TEMP*B( I, K )
  306. 200 CONTINUE
  307. END IF
  308. 210 CONTINUE
  309. 220 CONTINUE
  310. END IF
  311. ELSE
  312. *
  313. * Form B := alpha*B*A'.
  314. *
  315. IF( UPPER )THEN
  316. DO 260, K = 1, N
  317. DO 240, J = 1, K - 1
  318. IF( A( J, K ).NE.ZERO )THEN
  319. TEMP = ALPHA*A( J, K )
  320. DO 230, I = 1, M
  321. B( I, J ) = B( I, J ) + TEMP*B( I, K )
  322. 230 CONTINUE
  323. END IF
  324. 240 CONTINUE
  325. TEMP = ALPHA
  326. IF( NOUNIT )
  327. $ TEMP = TEMP*A( K, K )
  328. IF( TEMP.NE.ONE )THEN
  329. DO 250, I = 1, M
  330. B( I, K ) = TEMP*B( I, K )
  331. 250 CONTINUE
  332. END IF
  333. 260 CONTINUE
  334. ELSE
  335. DO 300, K = N, 1, -1
  336. DO 280, J = K + 1, N
  337. IF( A( J, K ).NE.ZERO )THEN
  338. TEMP = ALPHA*A( J, K )
  339. DO 270, I = 1, M
  340. B( I, J ) = B( I, J ) + TEMP*B( I, K )
  341. 270 CONTINUE
  342. END IF
  343. 280 CONTINUE
  344. TEMP = ALPHA
  345. IF( NOUNIT )
  346. $ TEMP = TEMP*A( K, K )
  347. IF( TEMP.NE.ONE )THEN
  348. DO 290, I = 1, M
  349. B( I, K ) = TEMP*B( I, K )
  350. 290 CONTINUE
  351. END IF
  352. 300 CONTINUE
  353. END IF
  354. END IF
  355. END IF
  356. *
  357. RETURN
  358. *
  359. * End of DTRMM
  360. *
  361. END
  362.  
  363.  
  364.  

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