dsymm.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. /* dsymm.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 dsymm_(char *side, char *uplo, integer *m, integer *n,
  14. doublereal *alpha, doublereal *a, integer *lda, doublereal *b,
  15. integer *ldb, doublereal *beta, doublereal *c__, integer *ldc)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
  19. i__3;
  20. /* Local variables */
  21. integer i__, j, k, info;
  22. doublereal temp1, temp2;
  23. extern logical lsame_(char *, char *);
  24. integer nrowa;
  25. logical upper;
  26. extern /* Subroutine */ int xerbla_(char *, integer *);
  27. /* .. Scalar Arguments .. */
  28. /* .. */
  29. /* .. Array Arguments .. */
  30. /* .. */
  31. /* Purpose */
  32. /* ======= */
  33. /* DSYMM performs one of the matrix-matrix operations */
  34. /* C := alpha*A*B + beta*C, */
  35. /* or */
  36. /* C := alpha*B*A + beta*C, */
  37. /* where alpha and beta are scalars, A is a symmetric matrix and B and */
  38. /* C are m by n matrices. */
  39. /* Arguments */
  40. /* ========== */
  41. /* SIDE - CHARACTER*1. */
  42. /* On entry, SIDE specifies whether the symmetric matrix A */
  43. /* appears on the left or right in the operation as follows: */
  44. /* SIDE = 'L' or 'l' C := alpha*A*B + beta*C, */
  45. /* SIDE = 'R' or 'r' C := alpha*B*A + beta*C, */
  46. /* Unchanged on exit. */
  47. /* UPLO - CHARACTER*1. */
  48. /* On entry, UPLO specifies whether the upper or lower */
  49. /* triangular part of the symmetric matrix A is to be */
  50. /* referenced as follows: */
  51. /* UPLO = 'U' or 'u' Only the upper triangular part of the */
  52. /* symmetric matrix is to be referenced. */
  53. /* UPLO = 'L' or 'l' Only the lower triangular part of the */
  54. /* symmetric matrix is to be referenced. */
  55. /* Unchanged on exit. */
  56. /* M - INTEGER. */
  57. /* On entry, M specifies the number of rows of the matrix C. */
  58. /* M must be at least zero. */
  59. /* Unchanged on exit. */
  60. /* N - INTEGER. */
  61. /* On entry, N specifies the number of columns of the matrix C. */
  62. /* N must be at least zero. */
  63. /* Unchanged on exit. */
  64. /* ALPHA - DOUBLE PRECISION. */
  65. /* On entry, ALPHA specifies the scalar alpha. */
  66. /* Unchanged on exit. */
  67. /* A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is */
  68. /* m when SIDE = 'L' or 'l' and is n otherwise. */
  69. /* Before entry with SIDE = 'L' or 'l', the m by m part of */
  70. /* the array A must contain the symmetric matrix, such that */
  71. /* when UPLO = 'U' or 'u', the leading m by m upper triangular */
  72. /* part of the array A must contain the upper triangular part */
  73. /* of the symmetric matrix and the strictly lower triangular */
  74. /* part of A is not referenced, and when UPLO = 'L' or 'l', */
  75. /* the leading m by m lower triangular part of the array A */
  76. /* must contain the lower triangular part of the symmetric */
  77. /* matrix and the strictly upper triangular part of A is not */
  78. /* referenced. */
  79. /* Before entry with SIDE = 'R' or 'r', the n by n part of */
  80. /* the array A must contain the symmetric matrix, such that */
  81. /* when UPLO = 'U' or 'u', the leading n by n upper triangular */
  82. /* part of the array A must contain the upper triangular part */
  83. /* of the symmetric matrix and the strictly lower triangular */
  84. /* part of A is not referenced, and when UPLO = 'L' or 'l', */
  85. /* the leading n by n lower triangular part of the array A */
  86. /* must contain the lower triangular part of the symmetric */
  87. /* matrix and the strictly upper triangular part of A is not */
  88. /* referenced. */
  89. /* Unchanged on exit. */
  90. /* LDA - INTEGER. */
  91. /* On entry, LDA specifies the first dimension of A as declared */
  92. /* in the calling (sub) program. When SIDE = 'L' or 'l' then */
  93. /* LDA must be at least max( 1, m ), otherwise LDA must be at */
  94. /* least max( 1, n ). */
  95. /* Unchanged on exit. */
  96. /* B - DOUBLE PRECISION array of DIMENSION ( LDB, n ). */
  97. /* Before entry, the leading m by n part of the array B must */
  98. /* contain the matrix B. */
  99. /* Unchanged on exit. */
  100. /* LDB - INTEGER. */
  101. /* On entry, LDB specifies the first dimension of B as declared */
  102. /* in the calling (sub) program. LDB must be at least */
  103. /* max( 1, m ). */
  104. /* Unchanged on exit. */
  105. /* BETA - DOUBLE PRECISION. */
  106. /* On entry, BETA specifies the scalar beta. When BETA is */
  107. /* supplied as zero then C need not be set on input. */
  108. /* Unchanged on exit. */
  109. /* C - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */
  110. /* Before entry, the leading m by n part of the array C must */
  111. /* contain the matrix C, except when beta is zero, in which */
  112. /* case C need not be set on entry. */
  113. /* On exit, the array C is overwritten by the m by n updated */
  114. /* matrix. */
  115. /* LDC - INTEGER. */
  116. /* On entry, LDC specifies the first dimension of C as declared */
  117. /* in the calling (sub) program. LDC must be at least */
  118. /* max( 1, m ). */
  119. /* Unchanged on exit. */
  120. /* Level 3 Blas routine. */
  121. /* -- Written on 8-February-1989. */
  122. /* Jack Dongarra, Argonne National Laboratory. */
  123. /* Iain Duff, AERE Harwell. */
  124. /* Jeremy Du Croz, Numerical Algorithms Group Ltd. */
  125. /* Sven Hammarling, Numerical Algorithms Group Ltd. */
  126. /* .. External Functions .. */
  127. /* .. */
  128. /* .. External Subroutines .. */
  129. /* .. */
  130. /* .. Intrinsic Functions .. */
  131. /* .. */
  132. /* .. Local Scalars .. */
  133. /* .. */
  134. /* .. Parameters .. */
  135. /* .. */
  136. /* Set NROWA as the number of rows of A. */
  137. /* Parameter adjustments */
  138. a_dim1 = *lda;
  139. a_offset = 1 + a_dim1;
  140. a -= a_offset;
  141. b_dim1 = *ldb;
  142. b_offset = 1 + b_dim1;
  143. b -= b_offset;
  144. c_dim1 = *ldc;
  145. c_offset = 1 + c_dim1;
  146. c__ -= c_offset;
  147. /* Function Body */
  148. if (lsame_(side, "L")) {
  149. nrowa = *m;
  150. } else {
  151. nrowa = *n;
  152. }
  153. upper = lsame_(uplo, "U");
  154. /* Test the input parameters. */
  155. info = 0;
  156. if (! lsame_(side, "L") && ! lsame_(side, "R")) {
  157. info = 1;
  158. } else if (! upper && ! lsame_(uplo, "L")) {
  159. info = 2;
  160. } else if (*m < 0) {
  161. info = 3;
  162. } else if (*n < 0) {
  163. info = 4;
  164. } else if (*lda < max(1,nrowa)) {
  165. info = 7;
  166. } else if (*ldb < max(1,*m)) {
  167. info = 9;
  168. } else if (*ldc < max(1,*m)) {
  169. info = 12;
  170. }
  171. if (info != 0) {
  172. xerbla_("DSYMM ", &info);
  173. return 0;
  174. }
  175. /* Quick return if possible. */
  176. if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
  177. return 0;
  178. }
  179. /* And when alpha.eq.zero. */
  180. if (*alpha == 0.) {
  181. if (*beta == 0.) {
  182. i__1 = *n;
  183. for (j = 1; j <= i__1; ++j) {
  184. i__2 = *m;
  185. for (i__ = 1; i__ <= i__2; ++i__) {
  186. c__[i__ + j * c_dim1] = 0.;
  187. /* L10: */
  188. }
  189. /* L20: */
  190. }
  191. } else {
  192. i__1 = *n;
  193. for (j = 1; j <= i__1; ++j) {
  194. i__2 = *m;
  195. for (i__ = 1; i__ <= i__2; ++i__) {
  196. c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
  197. /* L30: */
  198. }
  199. /* L40: */
  200. }
  201. }
  202. return 0;
  203. }
  204. /* Start the operations. */
  205. if (lsame_(side, "L")) {
  206. /* Form C := alpha*A*B + beta*C. */
  207. if (upper) {
  208. i__1 = *n;
  209. for (j = 1; j <= i__1; ++j) {
  210. i__2 = *m;
  211. for (i__ = 1; i__ <= i__2; ++i__) {
  212. temp1 = *alpha * b[i__ + j * b_dim1];
  213. temp2 = 0.;
  214. i__3 = i__ - 1;
  215. for (k = 1; k <= i__3; ++k) {
  216. c__[k + j * c_dim1] += temp1 * a[k + i__ * a_dim1];
  217. temp2 += b[k + j * b_dim1] * a[k + i__ * a_dim1];
  218. /* L50: */
  219. }
  220. if (*beta == 0.) {
  221. c__[i__ + j * c_dim1] = temp1 * a[i__ + i__ * a_dim1]
  222. + *alpha * temp2;
  223. } else {
  224. c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
  225. + temp1 * a[i__ + i__ * a_dim1] + *alpha *
  226. temp2;
  227. }
  228. /* L60: */
  229. }
  230. /* L70: */
  231. }
  232. } else {
  233. i__1 = *n;
  234. for (j = 1; j <= i__1; ++j) {
  235. for (i__ = *m; i__ >= 1; --i__) {
  236. temp1 = *alpha * b[i__ + j * b_dim1];
  237. temp2 = 0.;
  238. i__2 = *m;
  239. for (k = i__ + 1; k <= i__2; ++k) {
  240. c__[k + j * c_dim1] += temp1 * a[k + i__ * a_dim1];
  241. temp2 += b[k + j * b_dim1] * a[k + i__ * a_dim1];
  242. /* L80: */
  243. }
  244. if (*beta == 0.) {
  245. c__[i__ + j * c_dim1] = temp1 * a[i__ + i__ * a_dim1]
  246. + *alpha * temp2;
  247. } else {
  248. c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
  249. + temp1 * a[i__ + i__ * a_dim1] + *alpha *
  250. temp2;
  251. }
  252. /* L90: */
  253. }
  254. /* L100: */
  255. }
  256. }
  257. } else {
  258. /* Form C := alpha*B*A + beta*C. */
  259. i__1 = *n;
  260. for (j = 1; j <= i__1; ++j) {
  261. temp1 = *alpha * a[j + j * a_dim1];
  262. if (*beta == 0.) {
  263. i__2 = *m;
  264. for (i__ = 1; i__ <= i__2; ++i__) {
  265. c__[i__ + j * c_dim1] = temp1 * b[i__ + j * b_dim1];
  266. /* L110: */
  267. }
  268. } else {
  269. i__2 = *m;
  270. for (i__ = 1; i__ <= i__2; ++i__) {
  271. c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1] +
  272. temp1 * b[i__ + j * b_dim1];
  273. /* L120: */
  274. }
  275. }
  276. i__2 = j - 1;
  277. for (k = 1; k <= i__2; ++k) {
  278. if (upper) {
  279. temp1 = *alpha * a[k + j * a_dim1];
  280. } else {
  281. temp1 = *alpha * a[j + k * a_dim1];
  282. }
  283. i__3 = *m;
  284. for (i__ = 1; i__ <= i__3; ++i__) {
  285. c__[i__ + j * c_dim1] += temp1 * b[i__ + k * b_dim1];
  286. /* L130: */
  287. }
  288. /* L140: */
  289. }
  290. i__2 = *n;
  291. for (k = j + 1; k <= i__2; ++k) {
  292. if (upper) {
  293. temp1 = *alpha * a[j + k * a_dim1];
  294. } else {
  295. temp1 = *alpha * a[k + j * a_dim1];
  296. }
  297. i__3 = *m;
  298. for (i__ = 1; i__ <= i__3; ++i__) {
  299. c__[i__ + j * c_dim1] += temp1 * b[i__ + k * b_dim1];
  300. /* L150: */
  301. }
  302. /* L160: */
  303. }
  304. /* L170: */
  305. }
  306. }
  307. return 0;
  308. /* End of DSYMM . */
  309. } /* dsymm_ */