strmm.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /* strmm.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int strmm_(char *side, char *uplo, char *transa, char *diag,
  14. integer *m, integer *n, real *alpha, real *a, integer *lda, real *b,
  15. integer *ldb)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
  19. /* Local variables */
  20. integer i__, j, k, info;
  21. real temp;
  22. logical lside;
  23. extern logical lsame_(char *, char *);
  24. integer nrowa;
  25. logical upper;
  26. extern /* Subroutine */ int xerbla_(char *, integer *);
  27. logical nounit;
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* .. Array Arguments .. */
  31. /* .. */
  32. /* Purpose */
  33. /* ======= */
  34. /* STRMM performs one of the matrix-matrix operations */
  35. /* B := alpha*op( A )*B, or B := alpha*B*op( A ), */
  36. /* where alpha is a scalar, B is an m by n matrix, A is a unit, or */
  37. /* non-unit, upper or lower triangular matrix and op( A ) is one of */
  38. /* op( A ) = A or op( A ) = A'. */
  39. /* Arguments */
  40. /* ========== */
  41. /* SIDE - CHARACTER*1. */
  42. /* On entry, SIDE specifies whether op( A ) multiplies B from */
  43. /* the left or right as follows: */
  44. /* SIDE = 'L' or 'l' B := alpha*op( A )*B. */
  45. /* SIDE = 'R' or 'r' B := alpha*B*op( A ). */
  46. /* Unchanged on exit. */
  47. /* UPLO - CHARACTER*1. */
  48. /* On entry, UPLO specifies whether the matrix A is an upper or */
  49. /* lower triangular matrix as follows: */
  50. /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
  51. /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
  52. /* Unchanged on exit. */
  53. /* TRANSA - CHARACTER*1. */
  54. /* On entry, TRANSA specifies the form of op( A ) to be used in */
  55. /* the matrix multiplication as follows: */
  56. /* TRANSA = 'N' or 'n' op( A ) = A. */
  57. /* TRANSA = 'T' or 't' op( A ) = A'. */
  58. /* TRANSA = 'C' or 'c' op( A ) = A'. */
  59. /* Unchanged on exit. */
  60. /* DIAG - CHARACTER*1. */
  61. /* On entry, DIAG specifies whether or not A is unit triangular */
  62. /* as follows: */
  63. /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
  64. /* DIAG = 'N' or 'n' A is not assumed to be unit */
  65. /* triangular. */
  66. /* Unchanged on exit. */
  67. /* M - INTEGER. */
  68. /* On entry, M specifies the number of rows of B. M must be at */
  69. /* least zero. */
  70. /* Unchanged on exit. */
  71. /* N - INTEGER. */
  72. /* On entry, N specifies the number of columns of B. N must be */
  73. /* at least zero. */
  74. /* Unchanged on exit. */
  75. /* ALPHA - REAL . */
  76. /* On entry, ALPHA specifies the scalar alpha. When alpha is */
  77. /* zero then A is not referenced and B need not be set before */
  78. /* entry. */
  79. /* Unchanged on exit. */
  80. /* A - REAL array of DIMENSION ( LDA, k ), where k is m */
  81. /* when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'. */
  82. /* Before entry with UPLO = 'U' or 'u', the leading k by k */
  83. /* upper triangular part of the array A must contain the upper */
  84. /* triangular matrix and the strictly lower triangular part of */
  85. /* A is not referenced. */
  86. /* Before entry with UPLO = 'L' or 'l', the leading k by k */
  87. /* lower triangular part of the array A must contain the lower */
  88. /* triangular matrix and the strictly upper triangular part of */
  89. /* A is not referenced. */
  90. /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
  91. /* A are not referenced either, but are assumed to be unity. */
  92. /* Unchanged on exit. */
  93. /* LDA - INTEGER. */
  94. /* On entry, LDA specifies the first dimension of A as declared */
  95. /* in the calling (sub) program. When SIDE = 'L' or 'l' then */
  96. /* LDA must be at least max( 1, m ), when SIDE = 'R' or 'r' */
  97. /* then LDA must be at least max( 1, n ). */
  98. /* Unchanged on exit. */
  99. /* B - REAL array of DIMENSION ( LDB, n ). */
  100. /* Before entry, the leading m by n part of the array B must */
  101. /* contain the matrix B, and on exit is overwritten by the */
  102. /* transformed matrix. */
  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. /* Level 3 Blas routine. */
  109. /* -- Written on 8-February-1989. */
  110. /* Jack Dongarra, Argonne National Laboratory. */
  111. /* Iain Duff, AERE Harwell. */
  112. /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
  113. /* Sven Hammarling, Numerical Algorithms Group Ltd. */
  114. /* .. External Functions .. */
  115. /* .. */
  116. /* .. External Subroutines .. */
  117. /* .. */
  118. /* .. Intrinsic Functions .. */
  119. /* .. */
  120. /* .. Local Scalars .. */
  121. /* .. */
  122. /* .. Parameters .. */
  123. /* .. */
  124. /* Test the input parameters. */
  125. /* Parameter adjustments */
  126. a_dim1 = *lda;
  127. a_offset = 1 + a_dim1;
  128. a -= a_offset;
  129. b_dim1 = *ldb;
  130. b_offset = 1 + b_dim1;
  131. b -= b_offset;
  132. /* Function Body */
  133. lside = lsame_(side, "L");
  134. if (lside) {
  135. nrowa = *m;
  136. } else {
  137. nrowa = *n;
  138. }
  139. nounit = lsame_(diag, "N");
  140. upper = lsame_(uplo, "U");
  141. info = 0;
  142. if (! lside && ! lsame_(side, "R")) {
  143. info = 1;
  144. } else if (! upper && ! lsame_(uplo, "L")) {
  145. info = 2;
  146. } else if (! lsame_(transa, "N") && ! lsame_(transa,
  147. "T") && ! lsame_(transa, "C")) {
  148. info = 3;
  149. } else if (! lsame_(diag, "U") && ! lsame_(diag,
  150. "N")) {
  151. info = 4;
  152. } else if (*m < 0) {
  153. info = 5;
  154. } else if (*n < 0) {
  155. info = 6;
  156. } else if (*lda < max(1,nrowa)) {
  157. info = 9;
  158. } else if (*ldb < max(1,*m)) {
  159. info = 11;
  160. }
  161. if (info != 0) {
  162. xerbla_("STRMM ", &info);
  163. return 0;
  164. }
  165. /* Quick return if possible. */
  166. if (*m == 0 || *n == 0) {
  167. return 0;
  168. }
  169. /* And when alpha.eq.zero. */
  170. if (*alpha == 0.f) {
  171. i__1 = *n;
  172. for (j = 1; j <= i__1; ++j) {
  173. i__2 = *m;
  174. for (i__ = 1; i__ <= i__2; ++i__) {
  175. b[i__ + j * b_dim1] = 0.f;
  176. /* L10: */
  177. }
  178. /* L20: */
  179. }
  180. return 0;
  181. }
  182. /* Start the operations. */
  183. if (lside) {
  184. if (lsame_(transa, "N")) {
  185. /* Form B := alpha*A*B. */
  186. if (upper) {
  187. i__1 = *n;
  188. for (j = 1; j <= i__1; ++j) {
  189. i__2 = *m;
  190. for (k = 1; k <= i__2; ++k) {
  191. if (b[k + j * b_dim1] != 0.f) {
  192. temp = *alpha * b[k + j * b_dim1];
  193. i__3 = k - 1;
  194. for (i__ = 1; i__ <= i__3; ++i__) {
  195. b[i__ + j * b_dim1] += temp * a[i__ + k *
  196. a_dim1];
  197. /* L30: */
  198. }
  199. if (nounit) {
  200. temp *= a[k + k * a_dim1];
  201. }
  202. b[k + j * b_dim1] = temp;
  203. }
  204. /* L40: */
  205. }
  206. /* L50: */
  207. }
  208. } else {
  209. i__1 = *n;
  210. for (j = 1; j <= i__1; ++j) {
  211. for (k = *m; k >= 1; --k) {
  212. if (b[k + j * b_dim1] != 0.f) {
  213. temp = *alpha * b[k + j * b_dim1];
  214. b[k + j * b_dim1] = temp;
  215. if (nounit) {
  216. b[k + j * b_dim1] *= a[k + k * a_dim1];
  217. }
  218. i__2 = *m;
  219. for (i__ = k + 1; i__ <= i__2; ++i__) {
  220. b[i__ + j * b_dim1] += temp * a[i__ + k *
  221. a_dim1];
  222. /* L60: */
  223. }
  224. }
  225. /* L70: */
  226. }
  227. /* L80: */
  228. }
  229. }
  230. } else {
  231. /* Form B := alpha*A'*B. */
  232. if (upper) {
  233. i__1 = *n;
  234. for (j = 1; j <= i__1; ++j) {
  235. for (i__ = *m; i__ >= 1; --i__) {
  236. temp = b[i__ + j * b_dim1];
  237. if (nounit) {
  238. temp *= a[i__ + i__ * a_dim1];
  239. }
  240. i__2 = i__ - 1;
  241. for (k = 1; k <= i__2; ++k) {
  242. temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
  243. /* L90: */
  244. }
  245. b[i__ + j * b_dim1] = *alpha * temp;
  246. /* L100: */
  247. }
  248. /* L110: */
  249. }
  250. } else {
  251. i__1 = *n;
  252. for (j = 1; j <= i__1; ++j) {
  253. i__2 = *m;
  254. for (i__ = 1; i__ <= i__2; ++i__) {
  255. temp = b[i__ + j * b_dim1];
  256. if (nounit) {
  257. temp *= a[i__ + i__ * a_dim1];
  258. }
  259. i__3 = *m;
  260. for (k = i__ + 1; k <= i__3; ++k) {
  261. temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
  262. /* L120: */
  263. }
  264. b[i__ + j * b_dim1] = *alpha * temp;
  265. /* L130: */
  266. }
  267. /* L140: */
  268. }
  269. }
  270. }
  271. } else {
  272. if (lsame_(transa, "N")) {
  273. /* Form B := alpha*B*A. */
  274. if (upper) {
  275. for (j = *n; j >= 1; --j) {
  276. temp = *alpha;
  277. if (nounit) {
  278. temp *= a[j + j * a_dim1];
  279. }
  280. i__1 = *m;
  281. for (i__ = 1; i__ <= i__1; ++i__) {
  282. b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
  283. /* L150: */
  284. }
  285. i__1 = j - 1;
  286. for (k = 1; k <= i__1; ++k) {
  287. if (a[k + j * a_dim1] != 0.f) {
  288. temp = *alpha * a[k + j * a_dim1];
  289. i__2 = *m;
  290. for (i__ = 1; i__ <= i__2; ++i__) {
  291. b[i__ + j * b_dim1] += temp * b[i__ + k *
  292. b_dim1];
  293. /* L160: */
  294. }
  295. }
  296. /* L170: */
  297. }
  298. /* L180: */
  299. }
  300. } else {
  301. i__1 = *n;
  302. for (j = 1; j <= i__1; ++j) {
  303. temp = *alpha;
  304. if (nounit) {
  305. temp *= a[j + j * a_dim1];
  306. }
  307. i__2 = *m;
  308. for (i__ = 1; i__ <= i__2; ++i__) {
  309. b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
  310. /* L190: */
  311. }
  312. i__2 = *n;
  313. for (k = j + 1; k <= i__2; ++k) {
  314. if (a[k + j * a_dim1] != 0.f) {
  315. temp = *alpha * a[k + j * a_dim1];
  316. i__3 = *m;
  317. for (i__ = 1; i__ <= i__3; ++i__) {
  318. b[i__ + j * b_dim1] += temp * b[i__ + k *
  319. b_dim1];
  320. /* L200: */
  321. }
  322. }
  323. /* L210: */
  324. }
  325. /* L220: */
  326. }
  327. }
  328. } else {
  329. /* Form B := alpha*B*A'. */
  330. if (upper) {
  331. i__1 = *n;
  332. for (k = 1; k <= i__1; ++k) {
  333. i__2 = k - 1;
  334. for (j = 1; j <= i__2; ++j) {
  335. if (a[j + k * a_dim1] != 0.f) {
  336. temp = *alpha * a[j + k * a_dim1];
  337. i__3 = *m;
  338. for (i__ = 1; i__ <= i__3; ++i__) {
  339. b[i__ + j * b_dim1] += temp * b[i__ + k *
  340. b_dim1];
  341. /* L230: */
  342. }
  343. }
  344. /* L240: */
  345. }
  346. temp = *alpha;
  347. if (nounit) {
  348. temp *= a[k + k * a_dim1];
  349. }
  350. if (temp != 1.f) {
  351. i__2 = *m;
  352. for (i__ = 1; i__ <= i__2; ++i__) {
  353. b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
  354. /* L250: */
  355. }
  356. }
  357. /* L260: */
  358. }
  359. } else {
  360. for (k = *n; k >= 1; --k) {
  361. i__1 = *n;
  362. for (j = k + 1; j <= i__1; ++j) {
  363. if (a[j + k * a_dim1] != 0.f) {
  364. temp = *alpha * a[j + k * a_dim1];
  365. i__2 = *m;
  366. for (i__ = 1; i__ <= i__2; ++i__) {
  367. b[i__ + j * b_dim1] += temp * b[i__ + k *
  368. b_dim1];
  369. /* L270: */
  370. }
  371. }
  372. /* L280: */
  373. }
  374. temp = *alpha;
  375. if (nounit) {
  376. temp *= a[k + k * a_dim1];
  377. }
  378. if (temp != 1.f) {
  379. i__1 = *m;
  380. for (i__ = 1; i__ <= i__1; ++i__) {
  381. b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
  382. /* L290: */
  383. }
  384. }
  385. /* L300: */
  386. }
  387. }
  388. }
  389. }
  390. return 0;
  391. /* End of STRMM . */
  392. } /* strmm_ */