00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int chemm_(char *side, char *uplo, integer *m, integer *n,
00017 complex *alpha, complex *a, integer *lda, complex *b, integer *ldb,
00018 complex *beta, complex *c__, integer *ldc)
00019 {
00020
00021 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
00022 i__3, i__4, i__5, i__6;
00023 real r__1;
00024 complex q__1, q__2, q__3, q__4, q__5;
00025
00026
00027 void r_cnjg(complex *, complex *);
00028
00029
00030 integer i__, j, k, info;
00031 complex temp1, temp2;
00032 extern logical lsame_(char *, char *);
00033 integer nrowa;
00034 logical upper;
00035 extern int xerbla_(char *, integer *);
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 a_dim1 = *lda;
00183 a_offset = 1 + a_dim1;
00184 a -= a_offset;
00185 b_dim1 = *ldb;
00186 b_offset = 1 + b_dim1;
00187 b -= b_offset;
00188 c_dim1 = *ldc;
00189 c_offset = 1 + c_dim1;
00190 c__ -= c_offset;
00191
00192
00193 if (lsame_(side, "L")) {
00194 nrowa = *m;
00195 } else {
00196 nrowa = *n;
00197 }
00198 upper = lsame_(uplo, "U");
00199
00200
00201
00202 info = 0;
00203 if (! lsame_(side, "L") && ! lsame_(side, "R")) {
00204 info = 1;
00205 } else if (! upper && ! lsame_(uplo, "L")) {
00206 info = 2;
00207 } else if (*m < 0) {
00208 info = 3;
00209 } else if (*n < 0) {
00210 info = 4;
00211 } else if (*lda < max(1,nrowa)) {
00212 info = 7;
00213 } else if (*ldb < max(1,*m)) {
00214 info = 9;
00215 } else if (*ldc < max(1,*m)) {
00216 info = 12;
00217 }
00218 if (info != 0) {
00219 xerbla_("CHEMM ", &info);
00220 return 0;
00221 }
00222
00223
00224
00225 if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r
00226 == 1.f && beta->i == 0.f)) {
00227 return 0;
00228 }
00229
00230
00231
00232 if (alpha->r == 0.f && alpha->i == 0.f) {
00233 if (beta->r == 0.f && beta->i == 0.f) {
00234 i__1 = *n;
00235 for (j = 1; j <= i__1; ++j) {
00236 i__2 = *m;
00237 for (i__ = 1; i__ <= i__2; ++i__) {
00238 i__3 = i__ + j * c_dim1;
00239 c__[i__3].r = 0.f, c__[i__3].i = 0.f;
00240
00241 }
00242
00243 }
00244 } else {
00245 i__1 = *n;
00246 for (j = 1; j <= i__1; ++j) {
00247 i__2 = *m;
00248 for (i__ = 1; i__ <= i__2; ++i__) {
00249 i__3 = i__ + j * c_dim1;
00250 i__4 = i__ + j * c_dim1;
00251 q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
00252 q__1.i = beta->r * c__[i__4].i + beta->i * c__[
00253 i__4].r;
00254 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00255
00256 }
00257
00258 }
00259 }
00260 return 0;
00261 }
00262
00263
00264
00265 if (lsame_(side, "L")) {
00266
00267
00268
00269 if (upper) {
00270 i__1 = *n;
00271 for (j = 1; j <= i__1; ++j) {
00272 i__2 = *m;
00273 for (i__ = 1; i__ <= i__2; ++i__) {
00274 i__3 = i__ + j * b_dim1;
00275 q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
00276 q__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
00277 .r;
00278 temp1.r = q__1.r, temp1.i = q__1.i;
00279 temp2.r = 0.f, temp2.i = 0.f;
00280 i__3 = i__ - 1;
00281 for (k = 1; k <= i__3; ++k) {
00282 i__4 = k + j * c_dim1;
00283 i__5 = k + j * c_dim1;
00284 i__6 = k + i__ * a_dim1;
00285 q__2.r = temp1.r * a[i__6].r - temp1.i * a[i__6].i,
00286 q__2.i = temp1.r * a[i__6].i + temp1.i * a[
00287 i__6].r;
00288 q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
00289 q__2.i;
00290 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00291 i__4 = k + j * b_dim1;
00292 r_cnjg(&q__3, &a[k + i__ * a_dim1]);
00293 q__2.r = b[i__4].r * q__3.r - b[i__4].i * q__3.i,
00294 q__2.i = b[i__4].r * q__3.i + b[i__4].i *
00295 q__3.r;
00296 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00297 temp2.r = q__1.r, temp2.i = q__1.i;
00298
00299 }
00300 if (beta->r == 0.f && beta->i == 0.f) {
00301 i__3 = i__ + j * c_dim1;
00302 i__4 = i__ + i__ * a_dim1;
00303 r__1 = a[i__4].r;
00304 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
00305 q__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00306 q__3.i = alpha->r * temp2.i + alpha->i *
00307 temp2.r;
00308 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00309 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00310 } else {
00311 i__3 = i__ + j * c_dim1;
00312 i__4 = i__ + j * c_dim1;
00313 q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
00314 .i, q__3.i = beta->r * c__[i__4].i + beta->i *
00315 c__[i__4].r;
00316 i__5 = i__ + i__ * a_dim1;
00317 r__1 = a[i__5].r;
00318 q__4.r = r__1 * temp1.r, q__4.i = r__1 * temp1.i;
00319 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i + q__4.i;
00320 q__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00321 q__5.i = alpha->r * temp2.i + alpha->i *
00322 temp2.r;
00323 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00324 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00325 }
00326
00327 }
00328
00329 }
00330 } else {
00331 i__1 = *n;
00332 for (j = 1; j <= i__1; ++j) {
00333 for (i__ = *m; i__ >= 1; --i__) {
00334 i__2 = i__ + j * b_dim1;
00335 q__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2].i,
00336 q__1.i = alpha->r * b[i__2].i + alpha->i * b[i__2]
00337 .r;
00338 temp1.r = q__1.r, temp1.i = q__1.i;
00339 temp2.r = 0.f, temp2.i = 0.f;
00340 i__2 = *m;
00341 for (k = i__ + 1; k <= i__2; ++k) {
00342 i__3 = k + j * c_dim1;
00343 i__4 = k + j * c_dim1;
00344 i__5 = k + i__ * a_dim1;
00345 q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
00346 q__2.i = temp1.r * a[i__5].i + temp1.i * a[
00347 i__5].r;
00348 q__1.r = c__[i__4].r + q__2.r, q__1.i = c__[i__4].i +
00349 q__2.i;
00350 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00351 i__3 = k + j * b_dim1;
00352 r_cnjg(&q__3, &a[k + i__ * a_dim1]);
00353 q__2.r = b[i__3].r * q__3.r - b[i__3].i * q__3.i,
00354 q__2.i = b[i__3].r * q__3.i + b[i__3].i *
00355 q__3.r;
00356 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
00357 temp2.r = q__1.r, temp2.i = q__1.i;
00358
00359 }
00360 if (beta->r == 0.f && beta->i == 0.f) {
00361 i__2 = i__ + j * c_dim1;
00362 i__3 = i__ + i__ * a_dim1;
00363 r__1 = a[i__3].r;
00364 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
00365 q__3.r = alpha->r * temp2.r - alpha->i * temp2.i,
00366 q__3.i = alpha->r * temp2.i + alpha->i *
00367 temp2.r;
00368 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00369 c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00370 } else {
00371 i__2 = i__ + j * c_dim1;
00372 i__3 = i__ + j * c_dim1;
00373 q__3.r = beta->r * c__[i__3].r - beta->i * c__[i__3]
00374 .i, q__3.i = beta->r * c__[i__3].i + beta->i *
00375 c__[i__3].r;
00376 i__4 = i__ + i__ * a_dim1;
00377 r__1 = a[i__4].r;
00378 q__4.r = r__1 * temp1.r, q__4.i = r__1 * temp1.i;
00379 q__2.r = q__3.r + q__4.r, q__2.i = q__3.i + q__4.i;
00380 q__5.r = alpha->r * temp2.r - alpha->i * temp2.i,
00381 q__5.i = alpha->r * temp2.i + alpha->i *
00382 temp2.r;
00383 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
00384 c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00385 }
00386
00387 }
00388
00389 }
00390 }
00391 } else {
00392
00393
00394
00395 i__1 = *n;
00396 for (j = 1; j <= i__1; ++j) {
00397 i__2 = j + j * a_dim1;
00398 r__1 = a[i__2].r;
00399 q__1.r = r__1 * alpha->r, q__1.i = r__1 * alpha->i;
00400 temp1.r = q__1.r, temp1.i = q__1.i;
00401 if (beta->r == 0.f && beta->i == 0.f) {
00402 i__2 = *m;
00403 for (i__ = 1; i__ <= i__2; ++i__) {
00404 i__3 = i__ + j * c_dim1;
00405 i__4 = i__ + j * b_dim1;
00406 q__1.r = temp1.r * b[i__4].r - temp1.i * b[i__4].i,
00407 q__1.i = temp1.r * b[i__4].i + temp1.i * b[i__4]
00408 .r;
00409 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00410
00411 }
00412 } else {
00413 i__2 = *m;
00414 for (i__ = 1; i__ <= i__2; ++i__) {
00415 i__3 = i__ + j * c_dim1;
00416 i__4 = i__ + j * c_dim1;
00417 q__2.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
00418 q__2.i = beta->r * c__[i__4].i + beta->i * c__[
00419 i__4].r;
00420 i__5 = i__ + j * b_dim1;
00421 q__3.r = temp1.r * b[i__5].r - temp1.i * b[i__5].i,
00422 q__3.i = temp1.r * b[i__5].i + temp1.i * b[i__5]
00423 .r;
00424 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00425 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00426
00427 }
00428 }
00429 i__2 = j - 1;
00430 for (k = 1; k <= i__2; ++k) {
00431 if (upper) {
00432 i__3 = k + j * a_dim1;
00433 q__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00434 q__1.i = alpha->r * a[i__3].i + alpha->i * a[i__3]
00435 .r;
00436 temp1.r = q__1.r, temp1.i = q__1.i;
00437 } else {
00438 r_cnjg(&q__2, &a[j + k * a_dim1]);
00439 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00440 alpha->r * q__2.i + alpha->i * q__2.r;
00441 temp1.r = q__1.r, temp1.i = q__1.i;
00442 }
00443 i__3 = *m;
00444 for (i__ = 1; i__ <= i__3; ++i__) {
00445 i__4 = i__ + j * c_dim1;
00446 i__5 = i__ + j * c_dim1;
00447 i__6 = i__ + k * b_dim1;
00448 q__2.r = temp1.r * b[i__6].r - temp1.i * b[i__6].i,
00449 q__2.i = temp1.r * b[i__6].i + temp1.i * b[i__6]
00450 .r;
00451 q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
00452 q__2.i;
00453 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00454
00455 }
00456
00457 }
00458 i__2 = *n;
00459 for (k = j + 1; k <= i__2; ++k) {
00460 if (upper) {
00461 r_cnjg(&q__2, &a[j + k * a_dim1]);
00462 q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
00463 alpha->r * q__2.i + alpha->i * q__2.r;
00464 temp1.r = q__1.r, temp1.i = q__1.i;
00465 } else {
00466 i__3 = k + j * a_dim1;
00467 q__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
00468 q__1.i = alpha->r * a[i__3].i + alpha->i * a[i__3]
00469 .r;
00470 temp1.r = q__1.r, temp1.i = q__1.i;
00471 }
00472 i__3 = *m;
00473 for (i__ = 1; i__ <= i__3; ++i__) {
00474 i__4 = i__ + j * c_dim1;
00475 i__5 = i__ + j * c_dim1;
00476 i__6 = i__ + k * b_dim1;
00477 q__2.r = temp1.r * b[i__6].r - temp1.i * b[i__6].i,
00478 q__2.i = temp1.r * b[i__6].i + temp1.i * b[i__6]
00479 .r;
00480 q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
00481 q__2.i;
00482 c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
00483
00484 }
00485
00486 }
00487
00488 }
00489 }
00490
00491 return 0;
00492
00493
00494
00495 }