Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
numpy
GitHub Repository: numpy/numpy
Path: blob/main/numpy/linalg/lapack_lite/f2c_blas.c
1651 views
1
/*
2
* NOTE: This is generated code. Look in numpy/linalg/lapack_lite for
3
* information on remaking this file.
4
*/
5
#include "f2c.h"
6
7
#ifdef HAVE_CONFIG
8
#include "config.h"
9
#else
10
extern doublereal dlamch_(char *);
11
#define EPSILON dlamch_("Epsilon")
12
#define SAFEMINIMUM dlamch_("Safe minimum")
13
#define PRECISION dlamch_("Precision")
14
#define BASE dlamch_("Base")
15
#endif
16
17
extern doublereal dlapy2_(doublereal *x, doublereal *y);
18
19
/*
20
f2c knows the exact rules for precedence, and so omits parentheses where not
21
strictly necessary. Since this is generated code, we don't really care if
22
it's readable, and we know what is written is correct. So don't warn about
23
them.
24
*/
25
#if defined(__GNUC__)
26
#pragma GCC diagnostic ignored "-Wparentheses"
27
#endif
28
29
30
/* Table of constant values */
31
32
static singlecomplex c_b21 = {1.f,0.f};
33
static doublecomplex c_b1078 = {1.,0.};
34
35
/* Subroutine */ int caxpy_(integer *n, singlecomplex *ca, singlecomplex *cx, integer *
36
incx, singlecomplex *cy, integer *incy)
37
{
38
/* System generated locals */
39
integer i__1, i__2, i__3, i__4;
40
singlecomplex q__1, q__2;
41
42
/* Local variables */
43
static integer i__, ix, iy;
44
extern doublereal scabs1_(singlecomplex *);
45
46
47
/*
48
Purpose
49
=======
50
51
CAXPY constant times a vector plus a vector.
52
53
Further Details
54
===============
55
56
jack dongarra, linpack, 3/11/78.
57
modified 12/3/93, array(1) declarations changed to array(*)
58
59
=====================================================================
60
*/
61
62
/* Parameter adjustments */
63
--cy;
64
--cx;
65
66
/* Function Body */
67
if (*n <= 0) {
68
return 0;
69
}
70
if (scabs1_(ca) == 0.f) {
71
return 0;
72
}
73
if (*incx == 1 && *incy == 1) {
74
goto L20;
75
}
76
77
/*
78
code for unequal increments or equal increments
79
not equal to 1
80
*/
81
82
ix = 1;
83
iy = 1;
84
if (*incx < 0) {
85
ix = (-(*n) + 1) * *incx + 1;
86
}
87
if (*incy < 0) {
88
iy = (-(*n) + 1) * *incy + 1;
89
}
90
i__1 = *n;
91
for (i__ = 1; i__ <= i__1; ++i__) {
92
i__2 = iy;
93
i__3 = iy;
94
i__4 = ix;
95
q__2.r = ca->r * cx[i__4].r - ca->i * cx[i__4].i, q__2.i = ca->r * cx[
96
i__4].i + ca->i * cx[i__4].r;
97
q__1.r = cy[i__3].r + q__2.r, q__1.i = cy[i__3].i + q__2.i;
98
cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
99
ix += *incx;
100
iy += *incy;
101
/* L10: */
102
}
103
return 0;
104
105
/* code for both increments equal to 1 */
106
107
L20:
108
i__1 = *n;
109
for (i__ = 1; i__ <= i__1; ++i__) {
110
i__2 = i__;
111
i__3 = i__;
112
i__4 = i__;
113
q__2.r = ca->r * cx[i__4].r - ca->i * cx[i__4].i, q__2.i = ca->r * cx[
114
i__4].i + ca->i * cx[i__4].r;
115
q__1.r = cy[i__3].r + q__2.r, q__1.i = cy[i__3].i + q__2.i;
116
cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
117
/* L30: */
118
}
119
return 0;
120
} /* caxpy_ */
121
122
/* Subroutine */ int ccopy_(integer *n, singlecomplex *cx, integer *incx, singlecomplex *
123
cy, integer *incy)
124
{
125
/* System generated locals */
126
integer i__1, i__2, i__3;
127
128
/* Local variables */
129
static integer i__, ix, iy;
130
131
132
/*
133
Purpose
134
=======
135
136
CCOPY copies a vector x to a vector y.
137
138
Further Details
139
===============
140
141
jack dongarra, linpack, 3/11/78.
142
modified 12/3/93, array(1) declarations changed to array(*)
143
144
=====================================================================
145
*/
146
147
/* Parameter adjustments */
148
--cy;
149
--cx;
150
151
/* Function Body */
152
if (*n <= 0) {
153
return 0;
154
}
155
if (*incx == 1 && *incy == 1) {
156
goto L20;
157
}
158
159
/*
160
code for unequal increments or equal increments
161
not equal to 1
162
*/
163
164
ix = 1;
165
iy = 1;
166
if (*incx < 0) {
167
ix = (-(*n) + 1) * *incx + 1;
168
}
169
if (*incy < 0) {
170
iy = (-(*n) + 1) * *incy + 1;
171
}
172
i__1 = *n;
173
for (i__ = 1; i__ <= i__1; ++i__) {
174
i__2 = iy;
175
i__3 = ix;
176
cy[i__2].r = cx[i__3].r, cy[i__2].i = cx[i__3].i;
177
ix += *incx;
178
iy += *incy;
179
/* L10: */
180
}
181
return 0;
182
183
/* code for both increments equal to 1 */
184
185
L20:
186
i__1 = *n;
187
for (i__ = 1; i__ <= i__1; ++i__) {
188
i__2 = i__;
189
i__3 = i__;
190
cy[i__2].r = cx[i__3].r, cy[i__2].i = cx[i__3].i;
191
/* L30: */
192
}
193
return 0;
194
} /* ccopy_ */
195
196
/* Complex */ VOID cdotc_(singlecomplex * ret_val, integer *n, singlecomplex *cx, integer
197
*incx, singlecomplex *cy, integer *incy)
198
{
199
/* System generated locals */
200
integer i__1, i__2;
201
singlecomplex q__1, q__2, q__3;
202
203
/* Local variables */
204
static integer i__, ix, iy;
205
static singlecomplex ctemp;
206
207
208
/*
209
Purpose
210
=======
211
212
forms the dot product of two vectors, conjugating the first
213
vector.
214
215
Further Details
216
===============
217
218
jack dongarra, linpack, 3/11/78.
219
modified 12/3/93, array(1) declarations changed to array(*)
220
221
=====================================================================
222
*/
223
224
/* Parameter adjustments */
225
--cy;
226
--cx;
227
228
/* Function Body */
229
ctemp.r = 0.f, ctemp.i = 0.f;
230
ret_val->r = 0.f, ret_val->i = 0.f;
231
if (*n <= 0) {
232
return ;
233
}
234
if (*incx == 1 && *incy == 1) {
235
goto L20;
236
}
237
238
/*
239
code for unequal increments or equal increments
240
not equal to 1
241
*/
242
243
ix = 1;
244
iy = 1;
245
if (*incx < 0) {
246
ix = (-(*n) + 1) * *incx + 1;
247
}
248
if (*incy < 0) {
249
iy = (-(*n) + 1) * *incy + 1;
250
}
251
i__1 = *n;
252
for (i__ = 1; i__ <= i__1; ++i__) {
253
r_cnjg(&q__3, &cx[ix]);
254
i__2 = iy;
255
q__2.r = q__3.r * cy[i__2].r - q__3.i * cy[i__2].i, q__2.i = q__3.r *
256
cy[i__2].i + q__3.i * cy[i__2].r;
257
q__1.r = ctemp.r + q__2.r, q__1.i = ctemp.i + q__2.i;
258
ctemp.r = q__1.r, ctemp.i = q__1.i;
259
ix += *incx;
260
iy += *incy;
261
/* L10: */
262
}
263
ret_val->r = ctemp.r, ret_val->i = ctemp.i;
264
return ;
265
266
/* code for both increments equal to 1 */
267
268
L20:
269
i__1 = *n;
270
for (i__ = 1; i__ <= i__1; ++i__) {
271
r_cnjg(&q__3, &cx[i__]);
272
i__2 = i__;
273
q__2.r = q__3.r * cy[i__2].r - q__3.i * cy[i__2].i, q__2.i = q__3.r *
274
cy[i__2].i + q__3.i * cy[i__2].r;
275
q__1.r = ctemp.r + q__2.r, q__1.i = ctemp.i + q__2.i;
276
ctemp.r = q__1.r, ctemp.i = q__1.i;
277
/* L30: */
278
}
279
ret_val->r = ctemp.r, ret_val->i = ctemp.i;
280
return ;
281
} /* cdotc_ */
282
283
/* Complex */ VOID cdotu_(singlecomplex * ret_val, integer *n, singlecomplex *cx, integer
284
*incx, singlecomplex *cy, integer *incy)
285
{
286
/* System generated locals */
287
integer i__1, i__2, i__3;
288
singlecomplex q__1, q__2;
289
290
/* Local variables */
291
static integer i__, ix, iy;
292
static singlecomplex ctemp;
293
294
295
/*
296
Purpose
297
=======
298
299
CDOTU forms the dot product of two vectors.
300
301
Further Details
302
===============
303
304
jack dongarra, linpack, 3/11/78.
305
modified 12/3/93, array(1) declarations changed to array(*)
306
307
=====================================================================
308
*/
309
310
/* Parameter adjustments */
311
--cy;
312
--cx;
313
314
/* Function Body */
315
ctemp.r = 0.f, ctemp.i = 0.f;
316
ret_val->r = 0.f, ret_val->i = 0.f;
317
if (*n <= 0) {
318
return ;
319
}
320
if (*incx == 1 && *incy == 1) {
321
goto L20;
322
}
323
324
/*
325
code for unequal increments or equal increments
326
not equal to 1
327
*/
328
329
ix = 1;
330
iy = 1;
331
if (*incx < 0) {
332
ix = (-(*n) + 1) * *incx + 1;
333
}
334
if (*incy < 0) {
335
iy = (-(*n) + 1) * *incy + 1;
336
}
337
i__1 = *n;
338
for (i__ = 1; i__ <= i__1; ++i__) {
339
i__2 = ix;
340
i__3 = iy;
341
q__2.r = cx[i__2].r * cy[i__3].r - cx[i__2].i * cy[i__3].i, q__2.i =
342
cx[i__2].r * cy[i__3].i + cx[i__2].i * cy[i__3].r;
343
q__1.r = ctemp.r + q__2.r, q__1.i = ctemp.i + q__2.i;
344
ctemp.r = q__1.r, ctemp.i = q__1.i;
345
ix += *incx;
346
iy += *incy;
347
/* L10: */
348
}
349
ret_val->r = ctemp.r, ret_val->i = ctemp.i;
350
return ;
351
352
/* code for both increments equal to 1 */
353
354
L20:
355
i__1 = *n;
356
for (i__ = 1; i__ <= i__1; ++i__) {
357
i__2 = i__;
358
i__3 = i__;
359
q__2.r = cx[i__2].r * cy[i__3].r - cx[i__2].i * cy[i__3].i, q__2.i =
360
cx[i__2].r * cy[i__3].i + cx[i__2].i * cy[i__3].r;
361
q__1.r = ctemp.r + q__2.r, q__1.i = ctemp.i + q__2.i;
362
ctemp.r = q__1.r, ctemp.i = q__1.i;
363
/* L30: */
364
}
365
ret_val->r = ctemp.r, ret_val->i = ctemp.i;
366
return ;
367
} /* cdotu_ */
368
369
/* Subroutine */ int cgemm_(char *transa, char *transb, integer *m, integer *
370
n, integer *k, singlecomplex *alpha, singlecomplex *a, integer *lda, singlecomplex *b,
371
integer *ldb, singlecomplex *beta, singlecomplex *c__, integer *ldc)
372
{
373
/* System generated locals */
374
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
375
i__3, i__4, i__5, i__6;
376
singlecomplex q__1, q__2, q__3, q__4;
377
378
/* Local variables */
379
static integer i__, j, l, info;
380
static logical nota, notb;
381
static singlecomplex temp;
382
static logical conja, conjb;
383
extern logical lsame_(char *, char *);
384
static integer nrowa, nrowb;
385
extern /* Subroutine */ int xerbla_(char *, integer *);
386
387
388
/*
389
Purpose
390
=======
391
392
CGEMM performs one of the matrix-matrix operations
393
394
C := alpha*op( A )*op( B ) + beta*C,
395
396
where op( X ) is one of
397
398
op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ),
399
400
alpha and beta are scalars, and A, B and C are matrices, with op( A )
401
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
402
403
Arguments
404
==========
405
406
TRANSA - CHARACTER*1.
407
On entry, TRANSA specifies the form of op( A ) to be used in
408
the matrix multiplication as follows:
409
410
TRANSA = 'N' or 'n', op( A ) = A.
411
412
TRANSA = 'T' or 't', op( A ) = A'.
413
414
TRANSA = 'C' or 'c', op( A ) = conjg( A' ).
415
416
Unchanged on exit.
417
418
TRANSB - CHARACTER*1.
419
On entry, TRANSB specifies the form of op( B ) to be used in
420
the matrix multiplication as follows:
421
422
TRANSB = 'N' or 'n', op( B ) = B.
423
424
TRANSB = 'T' or 't', op( B ) = B'.
425
426
TRANSB = 'C' or 'c', op( B ) = conjg( B' ).
427
428
Unchanged on exit.
429
430
M - INTEGER.
431
On entry, M specifies the number of rows of the matrix
432
op( A ) and of the matrix C. M must be at least zero.
433
Unchanged on exit.
434
435
N - INTEGER.
436
On entry, N specifies the number of columns of the matrix
437
op( B ) and the number of columns of the matrix C. N must be
438
at least zero.
439
Unchanged on exit.
440
441
K - INTEGER.
442
On entry, K specifies the number of columns of the matrix
443
op( A ) and the number of rows of the matrix op( B ). K must
444
be at least zero.
445
Unchanged on exit.
446
447
ALPHA - COMPLEX .
448
On entry, ALPHA specifies the scalar alpha.
449
Unchanged on exit.
450
451
A - COMPLEX array of DIMENSION ( LDA, ka ), where ka is
452
k when TRANSA = 'N' or 'n', and is m otherwise.
453
Before entry with TRANSA = 'N' or 'n', the leading m by k
454
part of the array A must contain the matrix A, otherwise
455
the leading k by m part of the array A must contain the
456
matrix A.
457
Unchanged on exit.
458
459
LDA - INTEGER.
460
On entry, LDA specifies the first dimension of A as declared
461
in the calling (sub) program. When TRANSA = 'N' or 'n' then
462
LDA must be at least max( 1, m ), otherwise LDA must be at
463
least max( 1, k ).
464
Unchanged on exit.
465
466
B - COMPLEX array of DIMENSION ( LDB, kb ), where kb is
467
n when TRANSB = 'N' or 'n', and is k otherwise.
468
Before entry with TRANSB = 'N' or 'n', the leading k by n
469
part of the array B must contain the matrix B, otherwise
470
the leading n by k part of the array B must contain the
471
matrix B.
472
Unchanged on exit.
473
474
LDB - INTEGER.
475
On entry, LDB specifies the first dimension of B as declared
476
in the calling (sub) program. When TRANSB = 'N' or 'n' then
477
LDB must be at least max( 1, k ), otherwise LDB must be at
478
least max( 1, n ).
479
Unchanged on exit.
480
481
BETA - COMPLEX .
482
On entry, BETA specifies the scalar beta. When BETA is
483
supplied as zero then C need not be set on input.
484
Unchanged on exit.
485
486
C - COMPLEX array of DIMENSION ( LDC, n ).
487
Before entry, the leading m by n part of the array C must
488
contain the matrix C, except when beta is zero, in which
489
case C need not be set on entry.
490
On exit, the array C is overwritten by the m by n matrix
491
( alpha*op( A )*op( B ) + beta*C ).
492
493
LDC - INTEGER.
494
On entry, LDC specifies the first dimension of C as declared
495
in the calling (sub) program. LDC must be at least
496
max( 1, m ).
497
Unchanged on exit.
498
499
Further Details
500
===============
501
502
Level 3 Blas routine.
503
504
-- Written on 8-February-1989.
505
Jack Dongarra, Argonne National Laboratory.
506
Iain Duff, AERE Harwell.
507
Jeremy Du Croz, Numerical Algorithms Group Ltd.
508
Sven Hammarling, Numerical Algorithms Group Ltd.
509
510
=====================================================================
511
512
513
Set NOTA and NOTB as true if A and B respectively are not
514
conjugated or transposed, set CONJA and CONJB as true if A and
515
B respectively are to be transposed but not conjugated and set
516
NROWA and NROWB as the number of rows and columns of A
517
and the number of rows of B respectively.
518
*/
519
520
/* Parameter adjustments */
521
a_dim1 = *lda;
522
a_offset = 1 + a_dim1;
523
a -= a_offset;
524
b_dim1 = *ldb;
525
b_offset = 1 + b_dim1;
526
b -= b_offset;
527
c_dim1 = *ldc;
528
c_offset = 1 + c_dim1;
529
c__ -= c_offset;
530
531
/* Function Body */
532
nota = lsame_(transa, "N");
533
notb = lsame_(transb, "N");
534
conja = lsame_(transa, "C");
535
conjb = lsame_(transb, "C");
536
if (nota) {
537
nrowa = *m;
538
} else {
539
nrowa = *k;
540
}
541
if (notb) {
542
nrowb = *k;
543
} else {
544
nrowb = *n;
545
}
546
547
/* Test the input parameters. */
548
549
info = 0;
550
if (! nota && ! conja && ! lsame_(transa, "T")) {
551
info = 1;
552
} else if (! notb && ! conjb && ! lsame_(transb, "T")) {
553
info = 2;
554
} else if (*m < 0) {
555
info = 3;
556
} else if (*n < 0) {
557
info = 4;
558
} else if (*k < 0) {
559
info = 5;
560
} else if (*lda < max(1,nrowa)) {
561
info = 8;
562
} else if (*ldb < max(1,nrowb)) {
563
info = 10;
564
} else if (*ldc < max(1,*m)) {
565
info = 13;
566
}
567
if (info != 0) {
568
xerbla_("CGEMM ", &info);
569
return 0;
570
}
571
572
/* Quick return if possible. */
573
574
if (*m == 0 || *n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0)
575
&& (beta->r == 1.f && beta->i == 0.f)) {
576
return 0;
577
}
578
579
/* And when alpha.eq.zero. */
580
581
if (alpha->r == 0.f && alpha->i == 0.f) {
582
if (beta->r == 0.f && beta->i == 0.f) {
583
i__1 = *n;
584
for (j = 1; j <= i__1; ++j) {
585
i__2 = *m;
586
for (i__ = 1; i__ <= i__2; ++i__) {
587
i__3 = i__ + j * c_dim1;
588
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
589
/* L10: */
590
}
591
/* L20: */
592
}
593
} else {
594
i__1 = *n;
595
for (j = 1; j <= i__1; ++j) {
596
i__2 = *m;
597
for (i__ = 1; i__ <= i__2; ++i__) {
598
i__3 = i__ + j * c_dim1;
599
i__4 = i__ + j * c_dim1;
600
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
601
q__1.i = beta->r * c__[i__4].i + beta->i * c__[
602
i__4].r;
603
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
604
/* L30: */
605
}
606
/* L40: */
607
}
608
}
609
return 0;
610
}
611
612
/* Start the operations. */
613
614
if (notb) {
615
if (nota) {
616
617
/* Form C := alpha*A*B + beta*C. */
618
619
i__1 = *n;
620
for (j = 1; j <= i__1; ++j) {
621
if (beta->r == 0.f && beta->i == 0.f) {
622
i__2 = *m;
623
for (i__ = 1; i__ <= i__2; ++i__) {
624
i__3 = i__ + j * c_dim1;
625
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
626
/* L50: */
627
}
628
} else if (beta->r != 1.f || beta->i != 0.f) {
629
i__2 = *m;
630
for (i__ = 1; i__ <= i__2; ++i__) {
631
i__3 = i__ + j * c_dim1;
632
i__4 = i__ + j * c_dim1;
633
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
634
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
635
c__[i__4].r;
636
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
637
/* L60: */
638
}
639
}
640
i__2 = *k;
641
for (l = 1; l <= i__2; ++l) {
642
i__3 = l + j * b_dim1;
643
if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
644
i__3 = l + j * b_dim1;
645
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
646
q__1.i = alpha->r * b[i__3].i + alpha->i * b[
647
i__3].r;
648
temp.r = q__1.r, temp.i = q__1.i;
649
i__3 = *m;
650
for (i__ = 1; i__ <= i__3; ++i__) {
651
i__4 = i__ + j * c_dim1;
652
i__5 = i__ + j * c_dim1;
653
i__6 = i__ + l * a_dim1;
654
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
655
q__2.i = temp.r * a[i__6].i + temp.i * a[
656
i__6].r;
657
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
658
.i + q__2.i;
659
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
660
/* L70: */
661
}
662
}
663
/* L80: */
664
}
665
/* L90: */
666
}
667
} else if (conja) {
668
669
/* Form C := alpha*conjg( A' )*B + beta*C. */
670
671
i__1 = *n;
672
for (j = 1; j <= i__1; ++j) {
673
i__2 = *m;
674
for (i__ = 1; i__ <= i__2; ++i__) {
675
temp.r = 0.f, temp.i = 0.f;
676
i__3 = *k;
677
for (l = 1; l <= i__3; ++l) {
678
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
679
i__4 = l + j * b_dim1;
680
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
681
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
682
.r;
683
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
684
temp.r = q__1.r, temp.i = q__1.i;
685
/* L100: */
686
}
687
if (beta->r == 0.f && beta->i == 0.f) {
688
i__3 = i__ + j * c_dim1;
689
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
690
q__1.i = alpha->r * temp.i + alpha->i *
691
temp.r;
692
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
693
} else {
694
i__3 = i__ + j * c_dim1;
695
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
696
q__2.i = alpha->r * temp.i + alpha->i *
697
temp.r;
698
i__4 = i__ + j * c_dim1;
699
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
700
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
701
c__[i__4].r;
702
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
703
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
704
}
705
/* L110: */
706
}
707
/* L120: */
708
}
709
} else {
710
711
/* Form C := alpha*A'*B + beta*C */
712
713
i__1 = *n;
714
for (j = 1; j <= i__1; ++j) {
715
i__2 = *m;
716
for (i__ = 1; i__ <= i__2; ++i__) {
717
temp.r = 0.f, temp.i = 0.f;
718
i__3 = *k;
719
for (l = 1; l <= i__3; ++l) {
720
i__4 = l + i__ * a_dim1;
721
i__5 = l + j * b_dim1;
722
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
723
.i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
724
.i * b[i__5].r;
725
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
726
temp.r = q__1.r, temp.i = q__1.i;
727
/* L130: */
728
}
729
if (beta->r == 0.f && beta->i == 0.f) {
730
i__3 = i__ + j * c_dim1;
731
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
732
q__1.i = alpha->r * temp.i + alpha->i *
733
temp.r;
734
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
735
} else {
736
i__3 = i__ + j * c_dim1;
737
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
738
q__2.i = alpha->r * temp.i + alpha->i *
739
temp.r;
740
i__4 = i__ + j * c_dim1;
741
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
742
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
743
c__[i__4].r;
744
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
745
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
746
}
747
/* L140: */
748
}
749
/* L150: */
750
}
751
}
752
} else if (nota) {
753
if (conjb) {
754
755
/* Form C := alpha*A*conjg( B' ) + beta*C. */
756
757
i__1 = *n;
758
for (j = 1; j <= i__1; ++j) {
759
if (beta->r == 0.f && beta->i == 0.f) {
760
i__2 = *m;
761
for (i__ = 1; i__ <= i__2; ++i__) {
762
i__3 = i__ + j * c_dim1;
763
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
764
/* L160: */
765
}
766
} else if (beta->r != 1.f || beta->i != 0.f) {
767
i__2 = *m;
768
for (i__ = 1; i__ <= i__2; ++i__) {
769
i__3 = i__ + j * c_dim1;
770
i__4 = i__ + j * c_dim1;
771
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
772
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
773
c__[i__4].r;
774
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
775
/* L170: */
776
}
777
}
778
i__2 = *k;
779
for (l = 1; l <= i__2; ++l) {
780
i__3 = j + l * b_dim1;
781
if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
782
r_cnjg(&q__2, &b[j + l * b_dim1]);
783
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
784
q__1.i = alpha->r * q__2.i + alpha->i *
785
q__2.r;
786
temp.r = q__1.r, temp.i = q__1.i;
787
i__3 = *m;
788
for (i__ = 1; i__ <= i__3; ++i__) {
789
i__4 = i__ + j * c_dim1;
790
i__5 = i__ + j * c_dim1;
791
i__6 = i__ + l * a_dim1;
792
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
793
q__2.i = temp.r * a[i__6].i + temp.i * a[
794
i__6].r;
795
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
796
.i + q__2.i;
797
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
798
/* L180: */
799
}
800
}
801
/* L190: */
802
}
803
/* L200: */
804
}
805
} else {
806
807
/* Form C := alpha*A*B' + beta*C */
808
809
i__1 = *n;
810
for (j = 1; j <= i__1; ++j) {
811
if (beta->r == 0.f && beta->i == 0.f) {
812
i__2 = *m;
813
for (i__ = 1; i__ <= i__2; ++i__) {
814
i__3 = i__ + j * c_dim1;
815
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
816
/* L210: */
817
}
818
} else if (beta->r != 1.f || beta->i != 0.f) {
819
i__2 = *m;
820
for (i__ = 1; i__ <= i__2; ++i__) {
821
i__3 = i__ + j * c_dim1;
822
i__4 = i__ + j * c_dim1;
823
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
824
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
825
c__[i__4].r;
826
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
827
/* L220: */
828
}
829
}
830
i__2 = *k;
831
for (l = 1; l <= i__2; ++l) {
832
i__3 = j + l * b_dim1;
833
if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
834
i__3 = j + l * b_dim1;
835
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
836
q__1.i = alpha->r * b[i__3].i + alpha->i * b[
837
i__3].r;
838
temp.r = q__1.r, temp.i = q__1.i;
839
i__3 = *m;
840
for (i__ = 1; i__ <= i__3; ++i__) {
841
i__4 = i__ + j * c_dim1;
842
i__5 = i__ + j * c_dim1;
843
i__6 = i__ + l * a_dim1;
844
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
845
q__2.i = temp.r * a[i__6].i + temp.i * a[
846
i__6].r;
847
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
848
.i + q__2.i;
849
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
850
/* L230: */
851
}
852
}
853
/* L240: */
854
}
855
/* L250: */
856
}
857
}
858
} else if (conja) {
859
if (conjb) {
860
861
/* Form C := alpha*conjg( A' )*conjg( B' ) + beta*C. */
862
863
i__1 = *n;
864
for (j = 1; j <= i__1; ++j) {
865
i__2 = *m;
866
for (i__ = 1; i__ <= i__2; ++i__) {
867
temp.r = 0.f, temp.i = 0.f;
868
i__3 = *k;
869
for (l = 1; l <= i__3; ++l) {
870
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
871
r_cnjg(&q__4, &b[j + l * b_dim1]);
872
q__2.r = q__3.r * q__4.r - q__3.i * q__4.i, q__2.i =
873
q__3.r * q__4.i + q__3.i * q__4.r;
874
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
875
temp.r = q__1.r, temp.i = q__1.i;
876
/* L260: */
877
}
878
if (beta->r == 0.f && beta->i == 0.f) {
879
i__3 = i__ + j * c_dim1;
880
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
881
q__1.i = alpha->r * temp.i + alpha->i *
882
temp.r;
883
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
884
} else {
885
i__3 = i__ + j * c_dim1;
886
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
887
q__2.i = alpha->r * temp.i + alpha->i *
888
temp.r;
889
i__4 = i__ + j * c_dim1;
890
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
891
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
892
c__[i__4].r;
893
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
894
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
895
}
896
/* L270: */
897
}
898
/* L280: */
899
}
900
} else {
901
902
/* Form C := alpha*conjg( A' )*B' + beta*C */
903
904
i__1 = *n;
905
for (j = 1; j <= i__1; ++j) {
906
i__2 = *m;
907
for (i__ = 1; i__ <= i__2; ++i__) {
908
temp.r = 0.f, temp.i = 0.f;
909
i__3 = *k;
910
for (l = 1; l <= i__3; ++l) {
911
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
912
i__4 = j + l * b_dim1;
913
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
914
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
915
.r;
916
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
917
temp.r = q__1.r, temp.i = q__1.i;
918
/* L290: */
919
}
920
if (beta->r == 0.f && beta->i == 0.f) {
921
i__3 = i__ + j * c_dim1;
922
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
923
q__1.i = alpha->r * temp.i + alpha->i *
924
temp.r;
925
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
926
} else {
927
i__3 = i__ + j * c_dim1;
928
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
929
q__2.i = alpha->r * temp.i + alpha->i *
930
temp.r;
931
i__4 = i__ + j * c_dim1;
932
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
933
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
934
c__[i__4].r;
935
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
936
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
937
}
938
/* L300: */
939
}
940
/* L310: */
941
}
942
}
943
} else {
944
if (conjb) {
945
946
/* Form C := alpha*A'*conjg( B' ) + beta*C */
947
948
i__1 = *n;
949
for (j = 1; j <= i__1; ++j) {
950
i__2 = *m;
951
for (i__ = 1; i__ <= i__2; ++i__) {
952
temp.r = 0.f, temp.i = 0.f;
953
i__3 = *k;
954
for (l = 1; l <= i__3; ++l) {
955
i__4 = l + i__ * a_dim1;
956
r_cnjg(&q__3, &b[j + l * b_dim1]);
957
q__2.r = a[i__4].r * q__3.r - a[i__4].i * q__3.i,
958
q__2.i = a[i__4].r * q__3.i + a[i__4].i *
959
q__3.r;
960
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
961
temp.r = q__1.r, temp.i = q__1.i;
962
/* L320: */
963
}
964
if (beta->r == 0.f && beta->i == 0.f) {
965
i__3 = i__ + j * c_dim1;
966
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
967
q__1.i = alpha->r * temp.i + alpha->i *
968
temp.r;
969
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
970
} else {
971
i__3 = i__ + j * c_dim1;
972
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
973
q__2.i = alpha->r * temp.i + alpha->i *
974
temp.r;
975
i__4 = i__ + j * c_dim1;
976
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
977
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
978
c__[i__4].r;
979
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
980
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
981
}
982
/* L330: */
983
}
984
/* L340: */
985
}
986
} else {
987
988
/* Form C := alpha*A'*B' + beta*C */
989
990
i__1 = *n;
991
for (j = 1; j <= i__1; ++j) {
992
i__2 = *m;
993
for (i__ = 1; i__ <= i__2; ++i__) {
994
temp.r = 0.f, temp.i = 0.f;
995
i__3 = *k;
996
for (l = 1; l <= i__3; ++l) {
997
i__4 = l + i__ * a_dim1;
998
i__5 = j + l * b_dim1;
999
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
1000
.i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
1001
.i * b[i__5].r;
1002
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
1003
temp.r = q__1.r, temp.i = q__1.i;
1004
/* L350: */
1005
}
1006
if (beta->r == 0.f && beta->i == 0.f) {
1007
i__3 = i__ + j * c_dim1;
1008
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
1009
q__1.i = alpha->r * temp.i + alpha->i *
1010
temp.r;
1011
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
1012
} else {
1013
i__3 = i__ + j * c_dim1;
1014
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
1015
q__2.i = alpha->r * temp.i + alpha->i *
1016
temp.r;
1017
i__4 = i__ + j * c_dim1;
1018
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
1019
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
1020
c__[i__4].r;
1021
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
1022
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
1023
}
1024
/* L360: */
1025
}
1026
/* L370: */
1027
}
1028
}
1029
}
1030
1031
return 0;
1032
1033
/* End of CGEMM . */
1034
1035
} /* cgemm_ */
1036
1037
/* Subroutine */ int cgemv_(char *trans, integer *m, integer *n, singlecomplex *
1038
alpha, singlecomplex *a, integer *lda, singlecomplex *x, integer *incx, singlecomplex *
1039
beta, singlecomplex *y, integer *incy)
1040
{
1041
/* System generated locals */
1042
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
1043
singlecomplex q__1, q__2, q__3;
1044
1045
/* Local variables */
1046
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
1047
static singlecomplex temp;
1048
static integer lenx, leny;
1049
extern logical lsame_(char *, char *);
1050
extern /* Subroutine */ int xerbla_(char *, integer *);
1051
static logical noconj;
1052
1053
1054
/*
1055
Purpose
1056
=======
1057
1058
CGEMV performs one of the matrix-vector operations
1059
1060
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or
1061
1062
y := alpha*conjg( A' )*x + beta*y,
1063
1064
where alpha and beta are scalars, x and y are vectors and A is an
1065
m by n matrix.
1066
1067
Arguments
1068
==========
1069
1070
TRANS - CHARACTER*1.
1071
On entry, TRANS specifies the operation to be performed as
1072
follows:
1073
1074
TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
1075
1076
TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
1077
1078
TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y.
1079
1080
Unchanged on exit.
1081
1082
M - INTEGER.
1083
On entry, M specifies the number of rows of the matrix A.
1084
M must be at least zero.
1085
Unchanged on exit.
1086
1087
N - INTEGER.
1088
On entry, N specifies the number of columns of the matrix A.
1089
N must be at least zero.
1090
Unchanged on exit.
1091
1092
ALPHA - COMPLEX .
1093
On entry, ALPHA specifies the scalar alpha.
1094
Unchanged on exit.
1095
1096
A - COMPLEX array of DIMENSION ( LDA, n ).
1097
Before entry, the leading m by n part of the array A must
1098
contain the matrix of coefficients.
1099
Unchanged on exit.
1100
1101
LDA - INTEGER.
1102
On entry, LDA specifies the first dimension of A as declared
1103
in the calling (sub) program. LDA must be at least
1104
max( 1, m ).
1105
Unchanged on exit.
1106
1107
X - COMPLEX array of DIMENSION at least
1108
( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
1109
and at least
1110
( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
1111
Before entry, the incremented array X must contain the
1112
vector x.
1113
Unchanged on exit.
1114
1115
INCX - INTEGER.
1116
On entry, INCX specifies the increment for the elements of
1117
X. INCX must not be zero.
1118
Unchanged on exit.
1119
1120
BETA - COMPLEX .
1121
On entry, BETA specifies the scalar beta. When BETA is
1122
supplied as zero then Y need not be set on input.
1123
Unchanged on exit.
1124
1125
Y - COMPLEX array of DIMENSION at least
1126
( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
1127
and at least
1128
( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
1129
Before entry with BETA non-zero, the incremented array Y
1130
must contain the vector y. On exit, Y is overwritten by the
1131
updated vector y.
1132
1133
INCY - INTEGER.
1134
On entry, INCY specifies the increment for the elements of
1135
Y. INCY must not be zero.
1136
Unchanged on exit.
1137
1138
Further Details
1139
===============
1140
1141
Level 2 Blas routine.
1142
1143
-- Written on 22-October-1986.
1144
Jack Dongarra, Argonne National Lab.
1145
Jeremy Du Croz, Nag Central Office.
1146
Sven Hammarling, Nag Central Office.
1147
Richard Hanson, Sandia National Labs.
1148
1149
=====================================================================
1150
1151
1152
Test the input parameters.
1153
*/
1154
1155
/* Parameter adjustments */
1156
a_dim1 = *lda;
1157
a_offset = 1 + a_dim1;
1158
a -= a_offset;
1159
--x;
1160
--y;
1161
1162
/* Function Body */
1163
info = 0;
1164
if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
1165
) {
1166
info = 1;
1167
} else if (*m < 0) {
1168
info = 2;
1169
} else if (*n < 0) {
1170
info = 3;
1171
} else if (*lda < max(1,*m)) {
1172
info = 6;
1173
} else if (*incx == 0) {
1174
info = 8;
1175
} else if (*incy == 0) {
1176
info = 11;
1177
}
1178
if (info != 0) {
1179
xerbla_("CGEMV ", &info);
1180
return 0;
1181
}
1182
1183
/* Quick return if possible. */
1184
1185
if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r
1186
== 1.f && beta->i == 0.f)) {
1187
return 0;
1188
}
1189
1190
noconj = lsame_(trans, "T");
1191
1192
/*
1193
Set LENX and LENY, the lengths of the vectors x and y, and set
1194
up the start points in X and Y.
1195
*/
1196
1197
if (lsame_(trans, "N")) {
1198
lenx = *n;
1199
leny = *m;
1200
} else {
1201
lenx = *m;
1202
leny = *n;
1203
}
1204
if (*incx > 0) {
1205
kx = 1;
1206
} else {
1207
kx = 1 - (lenx - 1) * *incx;
1208
}
1209
if (*incy > 0) {
1210
ky = 1;
1211
} else {
1212
ky = 1 - (leny - 1) * *incy;
1213
}
1214
1215
/*
1216
Start the operations. In this version the elements of A are
1217
accessed sequentially with one pass through A.
1218
1219
First form y := beta*y.
1220
*/
1221
1222
if (beta->r != 1.f || beta->i != 0.f) {
1223
if (*incy == 1) {
1224
if (beta->r == 0.f && beta->i == 0.f) {
1225
i__1 = leny;
1226
for (i__ = 1; i__ <= i__1; ++i__) {
1227
i__2 = i__;
1228
y[i__2].r = 0.f, y[i__2].i = 0.f;
1229
/* L10: */
1230
}
1231
} else {
1232
i__1 = leny;
1233
for (i__ = 1; i__ <= i__1; ++i__) {
1234
i__2 = i__;
1235
i__3 = i__;
1236
q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
1237
q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
1238
.r;
1239
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
1240
/* L20: */
1241
}
1242
}
1243
} else {
1244
iy = ky;
1245
if (beta->r == 0.f && beta->i == 0.f) {
1246
i__1 = leny;
1247
for (i__ = 1; i__ <= i__1; ++i__) {
1248
i__2 = iy;
1249
y[i__2].r = 0.f, y[i__2].i = 0.f;
1250
iy += *incy;
1251
/* L30: */
1252
}
1253
} else {
1254
i__1 = leny;
1255
for (i__ = 1; i__ <= i__1; ++i__) {
1256
i__2 = iy;
1257
i__3 = iy;
1258
q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
1259
q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
1260
.r;
1261
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
1262
iy += *incy;
1263
/* L40: */
1264
}
1265
}
1266
}
1267
}
1268
if (alpha->r == 0.f && alpha->i == 0.f) {
1269
return 0;
1270
}
1271
if (lsame_(trans, "N")) {
1272
1273
/* Form y := alpha*A*x + y. */
1274
1275
jx = kx;
1276
if (*incy == 1) {
1277
i__1 = *n;
1278
for (j = 1; j <= i__1; ++j) {
1279
i__2 = jx;
1280
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
1281
i__2 = jx;
1282
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
1283
q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
1284
.r;
1285
temp.r = q__1.r, temp.i = q__1.i;
1286
i__2 = *m;
1287
for (i__ = 1; i__ <= i__2; ++i__) {
1288
i__3 = i__;
1289
i__4 = i__;
1290
i__5 = i__ + j * a_dim1;
1291
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
1292
q__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
1293
.r;
1294
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i +
1295
q__2.i;
1296
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
1297
/* L50: */
1298
}
1299
}
1300
jx += *incx;
1301
/* L60: */
1302
}
1303
} else {
1304
i__1 = *n;
1305
for (j = 1; j <= i__1; ++j) {
1306
i__2 = jx;
1307
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
1308
i__2 = jx;
1309
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
1310
q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
1311
.r;
1312
temp.r = q__1.r, temp.i = q__1.i;
1313
iy = ky;
1314
i__2 = *m;
1315
for (i__ = 1; i__ <= i__2; ++i__) {
1316
i__3 = iy;
1317
i__4 = iy;
1318
i__5 = i__ + j * a_dim1;
1319
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
1320
q__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
1321
.r;
1322
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i +
1323
q__2.i;
1324
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
1325
iy += *incy;
1326
/* L70: */
1327
}
1328
}
1329
jx += *incx;
1330
/* L80: */
1331
}
1332
}
1333
} else {
1334
1335
/* Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. */
1336
1337
jy = ky;
1338
if (*incx == 1) {
1339
i__1 = *n;
1340
for (j = 1; j <= i__1; ++j) {
1341
temp.r = 0.f, temp.i = 0.f;
1342
if (noconj) {
1343
i__2 = *m;
1344
for (i__ = 1; i__ <= i__2; ++i__) {
1345
i__3 = i__ + j * a_dim1;
1346
i__4 = i__;
1347
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
1348
.i, q__2.i = a[i__3].r * x[i__4].i + a[i__3]
1349
.i * x[i__4].r;
1350
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
1351
temp.r = q__1.r, temp.i = q__1.i;
1352
/* L90: */
1353
}
1354
} else {
1355
i__2 = *m;
1356
for (i__ = 1; i__ <= i__2; ++i__) {
1357
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
1358
i__3 = i__;
1359
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
1360
q__2.i = q__3.r * x[i__3].i + q__3.i * x[i__3]
1361
.r;
1362
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
1363
temp.r = q__1.r, temp.i = q__1.i;
1364
/* L100: */
1365
}
1366
}
1367
i__2 = jy;
1368
i__3 = jy;
1369
q__2.r = alpha->r * temp.r - alpha->i * temp.i, q__2.i =
1370
alpha->r * temp.i + alpha->i * temp.r;
1371
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
1372
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
1373
jy += *incy;
1374
/* L110: */
1375
}
1376
} else {
1377
i__1 = *n;
1378
for (j = 1; j <= i__1; ++j) {
1379
temp.r = 0.f, temp.i = 0.f;
1380
ix = kx;
1381
if (noconj) {
1382
i__2 = *m;
1383
for (i__ = 1; i__ <= i__2; ++i__) {
1384
i__3 = i__ + j * a_dim1;
1385
i__4 = ix;
1386
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
1387
.i, q__2.i = a[i__3].r * x[i__4].i + a[i__3]
1388
.i * x[i__4].r;
1389
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
1390
temp.r = q__1.r, temp.i = q__1.i;
1391
ix += *incx;
1392
/* L120: */
1393
}
1394
} else {
1395
i__2 = *m;
1396
for (i__ = 1; i__ <= i__2; ++i__) {
1397
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
1398
i__3 = ix;
1399
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
1400
q__2.i = q__3.r * x[i__3].i + q__3.i * x[i__3]
1401
.r;
1402
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
1403
temp.r = q__1.r, temp.i = q__1.i;
1404
ix += *incx;
1405
/* L130: */
1406
}
1407
}
1408
i__2 = jy;
1409
i__3 = jy;
1410
q__2.r = alpha->r * temp.r - alpha->i * temp.i, q__2.i =
1411
alpha->r * temp.i + alpha->i * temp.r;
1412
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
1413
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
1414
jy += *incy;
1415
/* L140: */
1416
}
1417
}
1418
}
1419
1420
return 0;
1421
1422
/* End of CGEMV . */
1423
1424
} /* cgemv_ */
1425
1426
/* Subroutine */ int cgerc_(integer *m, integer *n, singlecomplex *alpha, singlecomplex *
1427
x, integer *incx, singlecomplex *y, integer *incy, singlecomplex *a, integer *lda)
1428
{
1429
/* System generated locals */
1430
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
1431
singlecomplex q__1, q__2;
1432
1433
/* Local variables */
1434
static integer i__, j, ix, jy, kx, info;
1435
static singlecomplex temp;
1436
extern /* Subroutine */ int xerbla_(char *, integer *);
1437
1438
1439
/*
1440
Purpose
1441
=======
1442
1443
CGERC performs the rank 1 operation
1444
1445
A := alpha*x*conjg( y' ) + A,
1446
1447
where alpha is a scalar, x is an m element vector, y is an n element
1448
vector and A is an m by n matrix.
1449
1450
Arguments
1451
==========
1452
1453
M - INTEGER.
1454
On entry, M specifies the number of rows of the matrix A.
1455
M must be at least zero.
1456
Unchanged on exit.
1457
1458
N - INTEGER.
1459
On entry, N specifies the number of columns of the matrix A.
1460
N must be at least zero.
1461
Unchanged on exit.
1462
1463
ALPHA - COMPLEX .
1464
On entry, ALPHA specifies the scalar alpha.
1465
Unchanged on exit.
1466
1467
X - COMPLEX array of dimension at least
1468
( 1 + ( m - 1 )*abs( INCX ) ).
1469
Before entry, the incremented array X must contain the m
1470
element vector x.
1471
Unchanged on exit.
1472
1473
INCX - INTEGER.
1474
On entry, INCX specifies the increment for the elements of
1475
X. INCX must not be zero.
1476
Unchanged on exit.
1477
1478
Y - COMPLEX array of dimension at least
1479
( 1 + ( n - 1 )*abs( INCY ) ).
1480
Before entry, the incremented array Y must contain the n
1481
element vector y.
1482
Unchanged on exit.
1483
1484
INCY - INTEGER.
1485
On entry, INCY specifies the increment for the elements of
1486
Y. INCY must not be zero.
1487
Unchanged on exit.
1488
1489
A - COMPLEX array of DIMENSION ( LDA, n ).
1490
Before entry, the leading m by n part of the array A must
1491
contain the matrix of coefficients. On exit, A is
1492
overwritten by the updated matrix.
1493
1494
LDA - INTEGER.
1495
On entry, LDA specifies the first dimension of A as declared
1496
in the calling (sub) program. LDA must be at least
1497
max( 1, m ).
1498
Unchanged on exit.
1499
1500
Further Details
1501
===============
1502
1503
Level 2 Blas routine.
1504
1505
-- Written on 22-October-1986.
1506
Jack Dongarra, Argonne National Lab.
1507
Jeremy Du Croz, Nag Central Office.
1508
Sven Hammarling, Nag Central Office.
1509
Richard Hanson, Sandia National Labs.
1510
1511
=====================================================================
1512
1513
1514
Test the input parameters.
1515
*/
1516
1517
/* Parameter adjustments */
1518
--x;
1519
--y;
1520
a_dim1 = *lda;
1521
a_offset = 1 + a_dim1;
1522
a -= a_offset;
1523
1524
/* Function Body */
1525
info = 0;
1526
if (*m < 0) {
1527
info = 1;
1528
} else if (*n < 0) {
1529
info = 2;
1530
} else if (*incx == 0) {
1531
info = 5;
1532
} else if (*incy == 0) {
1533
info = 7;
1534
} else if (*lda < max(1,*m)) {
1535
info = 9;
1536
}
1537
if (info != 0) {
1538
xerbla_("CGERC ", &info);
1539
return 0;
1540
}
1541
1542
/* Quick return if possible. */
1543
1544
if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
1545
return 0;
1546
}
1547
1548
/*
1549
Start the operations. In this version the elements of A are
1550
accessed sequentially with one pass through A.
1551
*/
1552
1553
if (*incy > 0) {
1554
jy = 1;
1555
} else {
1556
jy = 1 - (*n - 1) * *incy;
1557
}
1558
if (*incx == 1) {
1559
i__1 = *n;
1560
for (j = 1; j <= i__1; ++j) {
1561
i__2 = jy;
1562
if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
1563
r_cnjg(&q__2, &y[jy]);
1564
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
1565
alpha->r * q__2.i + alpha->i * q__2.r;
1566
temp.r = q__1.r, temp.i = q__1.i;
1567
i__2 = *m;
1568
for (i__ = 1; i__ <= i__2; ++i__) {
1569
i__3 = i__ + j * a_dim1;
1570
i__4 = i__ + j * a_dim1;
1571
i__5 = i__;
1572
q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
1573
x[i__5].r * temp.i + x[i__5].i * temp.r;
1574
q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
1575
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1576
/* L10: */
1577
}
1578
}
1579
jy += *incy;
1580
/* L20: */
1581
}
1582
} else {
1583
if (*incx > 0) {
1584
kx = 1;
1585
} else {
1586
kx = 1 - (*m - 1) * *incx;
1587
}
1588
i__1 = *n;
1589
for (j = 1; j <= i__1; ++j) {
1590
i__2 = jy;
1591
if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
1592
r_cnjg(&q__2, &y[jy]);
1593
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
1594
alpha->r * q__2.i + alpha->i * q__2.r;
1595
temp.r = q__1.r, temp.i = q__1.i;
1596
ix = kx;
1597
i__2 = *m;
1598
for (i__ = 1; i__ <= i__2; ++i__) {
1599
i__3 = i__ + j * a_dim1;
1600
i__4 = i__ + j * a_dim1;
1601
i__5 = ix;
1602
q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
1603
x[i__5].r * temp.i + x[i__5].i * temp.r;
1604
q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
1605
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1606
ix += *incx;
1607
/* L30: */
1608
}
1609
}
1610
jy += *incy;
1611
/* L40: */
1612
}
1613
}
1614
1615
return 0;
1616
1617
/* End of CGERC . */
1618
1619
} /* cgerc_ */
1620
1621
/* Subroutine */ int cgeru_(integer *m, integer *n, singlecomplex *alpha, singlecomplex *
1622
x, integer *incx, singlecomplex *y, integer *incy, singlecomplex *a, integer *lda)
1623
{
1624
/* System generated locals */
1625
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
1626
singlecomplex q__1, q__2;
1627
1628
/* Local variables */
1629
static integer i__, j, ix, jy, kx, info;
1630
static singlecomplex temp;
1631
extern /* Subroutine */ int xerbla_(char *, integer *);
1632
1633
1634
/*
1635
Purpose
1636
=======
1637
1638
CGERU performs the rank 1 operation
1639
1640
A := alpha*x*y' + A,
1641
1642
where alpha is a scalar, x is an m element vector, y is an n element
1643
vector and A is an m by n matrix.
1644
1645
Arguments
1646
==========
1647
1648
M - INTEGER.
1649
On entry, M specifies the number of rows of the matrix A.
1650
M must be at least zero.
1651
Unchanged on exit.
1652
1653
N - INTEGER.
1654
On entry, N specifies the number of columns of the matrix A.
1655
N must be at least zero.
1656
Unchanged on exit.
1657
1658
ALPHA - COMPLEX .
1659
On entry, ALPHA specifies the scalar alpha.
1660
Unchanged on exit.
1661
1662
X - COMPLEX array of dimension at least
1663
( 1 + ( m - 1 )*abs( INCX ) ).
1664
Before entry, the incremented array X must contain the m
1665
element vector x.
1666
Unchanged on exit.
1667
1668
INCX - INTEGER.
1669
On entry, INCX specifies the increment for the elements of
1670
X. INCX must not be zero.
1671
Unchanged on exit.
1672
1673
Y - COMPLEX array of dimension at least
1674
( 1 + ( n - 1 )*abs( INCY ) ).
1675
Before entry, the incremented array Y must contain the n
1676
element vector y.
1677
Unchanged on exit.
1678
1679
INCY - INTEGER.
1680
On entry, INCY specifies the increment for the elements of
1681
Y. INCY must not be zero.
1682
Unchanged on exit.
1683
1684
A - COMPLEX array of DIMENSION ( LDA, n ).
1685
Before entry, the leading m by n part of the array A must
1686
contain the matrix of coefficients. On exit, A is
1687
overwritten by the updated matrix.
1688
1689
LDA - INTEGER.
1690
On entry, LDA specifies the first dimension of A as declared
1691
in the calling (sub) program. LDA must be at least
1692
max( 1, m ).
1693
Unchanged on exit.
1694
1695
Further Details
1696
===============
1697
1698
Level 2 Blas routine.
1699
1700
-- Written on 22-October-1986.
1701
Jack Dongarra, Argonne National Lab.
1702
Jeremy Du Croz, Nag Central Office.
1703
Sven Hammarling, Nag Central Office.
1704
Richard Hanson, Sandia National Labs.
1705
1706
=====================================================================
1707
1708
1709
Test the input parameters.
1710
*/
1711
1712
/* Parameter adjustments */
1713
--x;
1714
--y;
1715
a_dim1 = *lda;
1716
a_offset = 1 + a_dim1;
1717
a -= a_offset;
1718
1719
/* Function Body */
1720
info = 0;
1721
if (*m < 0) {
1722
info = 1;
1723
} else if (*n < 0) {
1724
info = 2;
1725
} else if (*incx == 0) {
1726
info = 5;
1727
} else if (*incy == 0) {
1728
info = 7;
1729
} else if (*lda < max(1,*m)) {
1730
info = 9;
1731
}
1732
if (info != 0) {
1733
xerbla_("CGERU ", &info);
1734
return 0;
1735
}
1736
1737
/* Quick return if possible. */
1738
1739
if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
1740
return 0;
1741
}
1742
1743
/*
1744
Start the operations. In this version the elements of A are
1745
accessed sequentially with one pass through A.
1746
*/
1747
1748
if (*incy > 0) {
1749
jy = 1;
1750
} else {
1751
jy = 1 - (*n - 1) * *incy;
1752
}
1753
if (*incx == 1) {
1754
i__1 = *n;
1755
for (j = 1; j <= i__1; ++j) {
1756
i__2 = jy;
1757
if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
1758
i__2 = jy;
1759
q__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, q__1.i =
1760
alpha->r * y[i__2].i + alpha->i * y[i__2].r;
1761
temp.r = q__1.r, temp.i = q__1.i;
1762
i__2 = *m;
1763
for (i__ = 1; i__ <= i__2; ++i__) {
1764
i__3 = i__ + j * a_dim1;
1765
i__4 = i__ + j * a_dim1;
1766
i__5 = i__;
1767
q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
1768
x[i__5].r * temp.i + x[i__5].i * temp.r;
1769
q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
1770
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1771
/* L10: */
1772
}
1773
}
1774
jy += *incy;
1775
/* L20: */
1776
}
1777
} else {
1778
if (*incx > 0) {
1779
kx = 1;
1780
} else {
1781
kx = 1 - (*m - 1) * *incx;
1782
}
1783
i__1 = *n;
1784
for (j = 1; j <= i__1; ++j) {
1785
i__2 = jy;
1786
if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
1787
i__2 = jy;
1788
q__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, q__1.i =
1789
alpha->r * y[i__2].i + alpha->i * y[i__2].r;
1790
temp.r = q__1.r, temp.i = q__1.i;
1791
ix = kx;
1792
i__2 = *m;
1793
for (i__ = 1; i__ <= i__2; ++i__) {
1794
i__3 = i__ + j * a_dim1;
1795
i__4 = i__ + j * a_dim1;
1796
i__5 = ix;
1797
q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
1798
x[i__5].r * temp.i + x[i__5].i * temp.r;
1799
q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
1800
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
1801
ix += *incx;
1802
/* L30: */
1803
}
1804
}
1805
jy += *incy;
1806
/* L40: */
1807
}
1808
}
1809
1810
return 0;
1811
1812
/* End of CGERU . */
1813
1814
} /* cgeru_ */
1815
1816
/* Subroutine */ int chemv_(char *uplo, integer *n, singlecomplex *alpha, singlecomplex *
1817
a, integer *lda, singlecomplex *x, integer *incx, singlecomplex *beta, singlecomplex *y,
1818
integer *incy)
1819
{
1820
/* System generated locals */
1821
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
1822
real r__1;
1823
singlecomplex q__1, q__2, q__3, q__4;
1824
1825
/* Local variables */
1826
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
1827
static singlecomplex temp1, temp2;
1828
extern logical lsame_(char *, char *);
1829
extern /* Subroutine */ int xerbla_(char *, integer *);
1830
1831
1832
/*
1833
Purpose
1834
=======
1835
1836
CHEMV performs the matrix-vector operation
1837
1838
y := alpha*A*x + beta*y,
1839
1840
where alpha and beta are scalars, x and y are n element vectors and
1841
A is an n by n hermitian matrix.
1842
1843
Arguments
1844
==========
1845
1846
UPLO - CHARACTER*1.
1847
On entry, UPLO specifies whether the upper or lower
1848
triangular part of the array A is to be referenced as
1849
follows:
1850
1851
UPLO = 'U' or 'u' Only the upper triangular part of A
1852
is to be referenced.
1853
1854
UPLO = 'L' or 'l' Only the lower triangular part of A
1855
is to be referenced.
1856
1857
Unchanged on exit.
1858
1859
N - INTEGER.
1860
On entry, N specifies the order of the matrix A.
1861
N must be at least zero.
1862
Unchanged on exit.
1863
1864
ALPHA - COMPLEX .
1865
On entry, ALPHA specifies the scalar alpha.
1866
Unchanged on exit.
1867
1868
A - COMPLEX array of DIMENSION ( LDA, n ).
1869
Before entry with UPLO = 'U' or 'u', the leading n by n
1870
upper triangular part of the array A must contain the upper
1871
triangular part of the hermitian matrix and the strictly
1872
lower triangular part of A is not referenced.
1873
Before entry with UPLO = 'L' or 'l', the leading n by n
1874
lower triangular part of the array A must contain the lower
1875
triangular part of the hermitian matrix and the strictly
1876
upper triangular part of A is not referenced.
1877
Note that the imaginary parts of the diagonal elements need
1878
not be set and are assumed to be zero.
1879
Unchanged on exit.
1880
1881
LDA - INTEGER.
1882
On entry, LDA specifies the first dimension of A as declared
1883
in the calling (sub) program. LDA must be at least
1884
max( 1, n ).
1885
Unchanged on exit.
1886
1887
X - COMPLEX array of dimension at least
1888
( 1 + ( n - 1 )*abs( INCX ) ).
1889
Before entry, the incremented array X must contain the n
1890
element vector x.
1891
Unchanged on exit.
1892
1893
INCX - INTEGER.
1894
On entry, INCX specifies the increment for the elements of
1895
X. INCX must not be zero.
1896
Unchanged on exit.
1897
1898
BETA - COMPLEX .
1899
On entry, BETA specifies the scalar beta. When BETA is
1900
supplied as zero then Y need not be set on input.
1901
Unchanged on exit.
1902
1903
Y - COMPLEX array of dimension at least
1904
( 1 + ( n - 1 )*abs( INCY ) ).
1905
Before entry, the incremented array Y must contain the n
1906
element vector y. On exit, Y is overwritten by the updated
1907
vector y.
1908
1909
INCY - INTEGER.
1910
On entry, INCY specifies the increment for the elements of
1911
Y. INCY must not be zero.
1912
Unchanged on exit.
1913
1914
Further Details
1915
===============
1916
1917
Level 2 Blas routine.
1918
1919
-- Written on 22-October-1986.
1920
Jack Dongarra, Argonne National Lab.
1921
Jeremy Du Croz, Nag Central Office.
1922
Sven Hammarling, Nag Central Office.
1923
Richard Hanson, Sandia National Labs.
1924
1925
=====================================================================
1926
1927
1928
Test the input parameters.
1929
*/
1930
1931
/* Parameter adjustments */
1932
a_dim1 = *lda;
1933
a_offset = 1 + a_dim1;
1934
a -= a_offset;
1935
--x;
1936
--y;
1937
1938
/* Function Body */
1939
info = 0;
1940
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
1941
info = 1;
1942
} else if (*n < 0) {
1943
info = 2;
1944
} else if (*lda < max(1,*n)) {
1945
info = 5;
1946
} else if (*incx == 0) {
1947
info = 7;
1948
} else if (*incy == 0) {
1949
info = 10;
1950
}
1951
if (info != 0) {
1952
xerbla_("CHEMV ", &info);
1953
return 0;
1954
}
1955
1956
/* Quick return if possible. */
1957
1958
if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r == 1.f &&
1959
beta->i == 0.f)) {
1960
return 0;
1961
}
1962
1963
/* Set up the start points in X and Y. */
1964
1965
if (*incx > 0) {
1966
kx = 1;
1967
} else {
1968
kx = 1 - (*n - 1) * *incx;
1969
}
1970
if (*incy > 0) {
1971
ky = 1;
1972
} else {
1973
ky = 1 - (*n - 1) * *incy;
1974
}
1975
1976
/*
1977
Start the operations. In this version the elements of A are
1978
accessed sequentially with one pass through the triangular part
1979
of A.
1980
1981
First form y := beta*y.
1982
*/
1983
1984
if (beta->r != 1.f || beta->i != 0.f) {
1985
if (*incy == 1) {
1986
if (beta->r == 0.f && beta->i == 0.f) {
1987
i__1 = *n;
1988
for (i__ = 1; i__ <= i__1; ++i__) {
1989
i__2 = i__;
1990
y[i__2].r = 0.f, y[i__2].i = 0.f;
1991
/* L10: */
1992
}
1993
} else {
1994
i__1 = *n;
1995
for (i__ = 1; i__ <= i__1; ++i__) {
1996
i__2 = i__;
1997
i__3 = i__;
1998
q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
1999
q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
2000
.r;
2001
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2002
/* L20: */
2003
}
2004
}
2005
} else {
2006
iy = ky;
2007
if (beta->r == 0.f && beta->i == 0.f) {
2008
i__1 = *n;
2009
for (i__ = 1; i__ <= i__1; ++i__) {
2010
i__2 = iy;
2011
y[i__2].r = 0.f, y[i__2].i = 0.f;
2012
iy += *incy;
2013
/* L30: */
2014
}
2015
} else {
2016
i__1 = *n;
2017
for (i__ = 1; i__ <= i__1; ++i__) {
2018
i__2 = iy;
2019
i__3 = iy;
2020
q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
2021
q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
2022
.r;
2023
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2024
iy += *incy;
2025
/* L40: */
2026
}
2027
}
2028
}
2029
}
2030
if (alpha->r == 0.f && alpha->i == 0.f) {
2031
return 0;
2032
}
2033
if (lsame_(uplo, "U")) {
2034
2035
/* Form y when A is stored in upper triangle. */
2036
2037
if (*incx == 1 && *incy == 1) {
2038
i__1 = *n;
2039
for (j = 1; j <= i__1; ++j) {
2040
i__2 = j;
2041
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
2042
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
2043
temp1.r = q__1.r, temp1.i = q__1.i;
2044
temp2.r = 0.f, temp2.i = 0.f;
2045
i__2 = j - 1;
2046
for (i__ = 1; i__ <= i__2; ++i__) {
2047
i__3 = i__;
2048
i__4 = i__;
2049
i__5 = i__ + j * a_dim1;
2050
q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
2051
q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
2052
.r;
2053
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
2054
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
2055
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
2056
i__3 = i__;
2057
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
2058
q__3.r * x[i__3].i + q__3.i * x[i__3].r;
2059
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
2060
temp2.r = q__1.r, temp2.i = q__1.i;
2061
/* L50: */
2062
}
2063
i__2 = j;
2064
i__3 = j;
2065
i__4 = j + j * a_dim1;
2066
r__1 = a[i__4].r;
2067
q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
2068
q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
2069
q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
2070
alpha->r * temp2.i + alpha->i * temp2.r;
2071
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2072
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2073
/* L60: */
2074
}
2075
} else {
2076
jx = kx;
2077
jy = ky;
2078
i__1 = *n;
2079
for (j = 1; j <= i__1; ++j) {
2080
i__2 = jx;
2081
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
2082
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
2083
temp1.r = q__1.r, temp1.i = q__1.i;
2084
temp2.r = 0.f, temp2.i = 0.f;
2085
ix = kx;
2086
iy = ky;
2087
i__2 = j - 1;
2088
for (i__ = 1; i__ <= i__2; ++i__) {
2089
i__3 = iy;
2090
i__4 = iy;
2091
i__5 = i__ + j * a_dim1;
2092
q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
2093
q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
2094
.r;
2095
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
2096
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
2097
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
2098
i__3 = ix;
2099
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
2100
q__3.r * x[i__3].i + q__3.i * x[i__3].r;
2101
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
2102
temp2.r = q__1.r, temp2.i = q__1.i;
2103
ix += *incx;
2104
iy += *incy;
2105
/* L70: */
2106
}
2107
i__2 = jy;
2108
i__3 = jy;
2109
i__4 = j + j * a_dim1;
2110
r__1 = a[i__4].r;
2111
q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
2112
q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
2113
q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
2114
alpha->r * temp2.i + alpha->i * temp2.r;
2115
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2116
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2117
jx += *incx;
2118
jy += *incy;
2119
/* L80: */
2120
}
2121
}
2122
} else {
2123
2124
/* Form y when A is stored in lower triangle. */
2125
2126
if (*incx == 1 && *incy == 1) {
2127
i__1 = *n;
2128
for (j = 1; j <= i__1; ++j) {
2129
i__2 = j;
2130
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
2131
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
2132
temp1.r = q__1.r, temp1.i = q__1.i;
2133
temp2.r = 0.f, temp2.i = 0.f;
2134
i__2 = j;
2135
i__3 = j;
2136
i__4 = j + j * a_dim1;
2137
r__1 = a[i__4].r;
2138
q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
2139
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
2140
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2141
i__2 = *n;
2142
for (i__ = j + 1; i__ <= i__2; ++i__) {
2143
i__3 = i__;
2144
i__4 = i__;
2145
i__5 = i__ + j * a_dim1;
2146
q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
2147
q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
2148
.r;
2149
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
2150
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
2151
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
2152
i__3 = i__;
2153
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
2154
q__3.r * x[i__3].i + q__3.i * x[i__3].r;
2155
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
2156
temp2.r = q__1.r, temp2.i = q__1.i;
2157
/* L90: */
2158
}
2159
i__2 = j;
2160
i__3 = j;
2161
q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
2162
alpha->r * temp2.i + alpha->i * temp2.r;
2163
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
2164
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2165
/* L100: */
2166
}
2167
} else {
2168
jx = kx;
2169
jy = ky;
2170
i__1 = *n;
2171
for (j = 1; j <= i__1; ++j) {
2172
i__2 = jx;
2173
q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
2174
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
2175
temp1.r = q__1.r, temp1.i = q__1.i;
2176
temp2.r = 0.f, temp2.i = 0.f;
2177
i__2 = jy;
2178
i__3 = jy;
2179
i__4 = j + j * a_dim1;
2180
r__1 = a[i__4].r;
2181
q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
2182
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
2183
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2184
ix = jx;
2185
iy = jy;
2186
i__2 = *n;
2187
for (i__ = j + 1; i__ <= i__2; ++i__) {
2188
ix += *incx;
2189
iy += *incy;
2190
i__3 = iy;
2191
i__4 = iy;
2192
i__5 = i__ + j * a_dim1;
2193
q__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
2194
q__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
2195
.r;
2196
q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
2197
y[i__3].r = q__1.r, y[i__3].i = q__1.i;
2198
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
2199
i__3 = ix;
2200
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
2201
q__3.r * x[i__3].i + q__3.i * x[i__3].r;
2202
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
2203
temp2.r = q__1.r, temp2.i = q__1.i;
2204
/* L110: */
2205
}
2206
i__2 = jy;
2207
i__3 = jy;
2208
q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
2209
alpha->r * temp2.i + alpha->i * temp2.r;
2210
q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
2211
y[i__2].r = q__1.r, y[i__2].i = q__1.i;
2212
jx += *incx;
2213
jy += *incy;
2214
/* L120: */
2215
}
2216
}
2217
}
2218
2219
return 0;
2220
2221
/* End of CHEMV . */
2222
2223
} /* chemv_ */
2224
2225
/* Subroutine */ int cher2_(char *uplo, integer *n, singlecomplex *alpha, singlecomplex *
2226
x, integer *incx, singlecomplex *y, integer *incy, singlecomplex *a, integer *lda)
2227
{
2228
/* System generated locals */
2229
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
2230
real r__1;
2231
singlecomplex q__1, q__2, q__3, q__4;
2232
2233
/* Local variables */
2234
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
2235
static singlecomplex temp1, temp2;
2236
extern logical lsame_(char *, char *);
2237
extern /* Subroutine */ int xerbla_(char *, integer *);
2238
2239
2240
/*
2241
Purpose
2242
=======
2243
2244
CHER2 performs the hermitian rank 2 operation
2245
2246
A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
2247
2248
where alpha is a scalar, x and y are n element vectors and A is an n
2249
by n hermitian matrix.
2250
2251
Arguments
2252
==========
2253
2254
UPLO - CHARACTER*1.
2255
On entry, UPLO specifies whether the upper or lower
2256
triangular part of the array A is to be referenced as
2257
follows:
2258
2259
UPLO = 'U' or 'u' Only the upper triangular part of A
2260
is to be referenced.
2261
2262
UPLO = 'L' or 'l' Only the lower triangular part of A
2263
is to be referenced.
2264
2265
Unchanged on exit.
2266
2267
N - INTEGER.
2268
On entry, N specifies the order of the matrix A.
2269
N must be at least zero.
2270
Unchanged on exit.
2271
2272
ALPHA - COMPLEX .
2273
On entry, ALPHA specifies the scalar alpha.
2274
Unchanged on exit.
2275
2276
X - COMPLEX array of dimension at least
2277
( 1 + ( n - 1 )*abs( INCX ) ).
2278
Before entry, the incremented array X must contain the n
2279
element vector x.
2280
Unchanged on exit.
2281
2282
INCX - INTEGER.
2283
On entry, INCX specifies the increment for the elements of
2284
X. INCX must not be zero.
2285
Unchanged on exit.
2286
2287
Y - COMPLEX array of dimension at least
2288
( 1 + ( n - 1 )*abs( INCY ) ).
2289
Before entry, the incremented array Y must contain the n
2290
element vector y.
2291
Unchanged on exit.
2292
2293
INCY - INTEGER.
2294
On entry, INCY specifies the increment for the elements of
2295
Y. INCY must not be zero.
2296
Unchanged on exit.
2297
2298
A - COMPLEX array of DIMENSION ( LDA, n ).
2299
Before entry with UPLO = 'U' or 'u', the leading n by n
2300
upper triangular part of the array A must contain the upper
2301
triangular part of the hermitian matrix and the strictly
2302
lower triangular part of A is not referenced. On exit, the
2303
upper triangular part of the array A is overwritten by the
2304
upper triangular part of the updated matrix.
2305
Before entry with UPLO = 'L' or 'l', the leading n by n
2306
lower triangular part of the array A must contain the lower
2307
triangular part of the hermitian matrix and the strictly
2308
upper triangular part of A is not referenced. On exit, the
2309
lower triangular part of the array A is overwritten by the
2310
lower triangular part of the updated matrix.
2311
Note that the imaginary parts of the diagonal elements need
2312
not be set, they are assumed to be zero, and on exit they
2313
are set to zero.
2314
2315
LDA - INTEGER.
2316
On entry, LDA specifies the first dimension of A as declared
2317
in the calling (sub) program. LDA must be at least
2318
max( 1, n ).
2319
Unchanged on exit.
2320
2321
Further Details
2322
===============
2323
2324
Level 2 Blas routine.
2325
2326
-- Written on 22-October-1986.
2327
Jack Dongarra, Argonne National Lab.
2328
Jeremy Du Croz, Nag Central Office.
2329
Sven Hammarling, Nag Central Office.
2330
Richard Hanson, Sandia National Labs.
2331
2332
=====================================================================
2333
2334
2335
Test the input parameters.
2336
*/
2337
2338
/* Parameter adjustments */
2339
--x;
2340
--y;
2341
a_dim1 = *lda;
2342
a_offset = 1 + a_dim1;
2343
a -= a_offset;
2344
2345
/* Function Body */
2346
info = 0;
2347
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
2348
info = 1;
2349
} else if (*n < 0) {
2350
info = 2;
2351
} else if (*incx == 0) {
2352
info = 5;
2353
} else if (*incy == 0) {
2354
info = 7;
2355
} else if (*lda < max(1,*n)) {
2356
info = 9;
2357
}
2358
if (info != 0) {
2359
xerbla_("CHER2 ", &info);
2360
return 0;
2361
}
2362
2363
/* Quick return if possible. */
2364
2365
if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
2366
return 0;
2367
}
2368
2369
/*
2370
Set up the start points in X and Y if the increments are not both
2371
unity.
2372
*/
2373
2374
if (*incx != 1 || *incy != 1) {
2375
if (*incx > 0) {
2376
kx = 1;
2377
} else {
2378
kx = 1 - (*n - 1) * *incx;
2379
}
2380
if (*incy > 0) {
2381
ky = 1;
2382
} else {
2383
ky = 1 - (*n - 1) * *incy;
2384
}
2385
jx = kx;
2386
jy = ky;
2387
}
2388
2389
/*
2390
Start the operations. In this version the elements of A are
2391
accessed sequentially with one pass through the triangular part
2392
of A.
2393
*/
2394
2395
if (lsame_(uplo, "U")) {
2396
2397
/* Form A when A is stored in the upper triangle. */
2398
2399
if (*incx == 1 && *incy == 1) {
2400
i__1 = *n;
2401
for (j = 1; j <= i__1; ++j) {
2402
i__2 = j;
2403
i__3 = j;
2404
if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
2405
|| y[i__3].i != 0.f)) {
2406
r_cnjg(&q__2, &y[j]);
2407
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
2408
alpha->r * q__2.i + alpha->i * q__2.r;
2409
temp1.r = q__1.r, temp1.i = q__1.i;
2410
i__2 = j;
2411
q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
2412
q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
2413
.r;
2414
r_cnjg(&q__1, &q__2);
2415
temp2.r = q__1.r, temp2.i = q__1.i;
2416
i__2 = j - 1;
2417
for (i__ = 1; i__ <= i__2; ++i__) {
2418
i__3 = i__ + j * a_dim1;
2419
i__4 = i__ + j * a_dim1;
2420
i__5 = i__;
2421
q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
2422
q__3.i = x[i__5].r * temp1.i + x[i__5].i *
2423
temp1.r;
2424
q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
2425
q__3.i;
2426
i__6 = i__;
2427
q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
2428
q__4.i = y[i__6].r * temp2.i + y[i__6].i *
2429
temp2.r;
2430
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2431
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
2432
/* L10: */
2433
}
2434
i__2 = j + j * a_dim1;
2435
i__3 = j + j * a_dim1;
2436
i__4 = j;
2437
q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
2438
q__2.i = x[i__4].r * temp1.i + x[i__4].i *
2439
temp1.r;
2440
i__5 = j;
2441
q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
2442
q__3.i = y[i__5].r * temp2.i + y[i__5].i *
2443
temp2.r;
2444
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
2445
r__1 = a[i__3].r + q__1.r;
2446
a[i__2].r = r__1, a[i__2].i = 0.f;
2447
} else {
2448
i__2 = j + j * a_dim1;
2449
i__3 = j + j * a_dim1;
2450
r__1 = a[i__3].r;
2451
a[i__2].r = r__1, a[i__2].i = 0.f;
2452
}
2453
/* L20: */
2454
}
2455
} else {
2456
i__1 = *n;
2457
for (j = 1; j <= i__1; ++j) {
2458
i__2 = jx;
2459
i__3 = jy;
2460
if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
2461
|| y[i__3].i != 0.f)) {
2462
r_cnjg(&q__2, &y[jy]);
2463
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
2464
alpha->r * q__2.i + alpha->i * q__2.r;
2465
temp1.r = q__1.r, temp1.i = q__1.i;
2466
i__2 = jx;
2467
q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
2468
q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
2469
.r;
2470
r_cnjg(&q__1, &q__2);
2471
temp2.r = q__1.r, temp2.i = q__1.i;
2472
ix = kx;
2473
iy = ky;
2474
i__2 = j - 1;
2475
for (i__ = 1; i__ <= i__2; ++i__) {
2476
i__3 = i__ + j * a_dim1;
2477
i__4 = i__ + j * a_dim1;
2478
i__5 = ix;
2479
q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
2480
q__3.i = x[i__5].r * temp1.i + x[i__5].i *
2481
temp1.r;
2482
q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
2483
q__3.i;
2484
i__6 = iy;
2485
q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
2486
q__4.i = y[i__6].r * temp2.i + y[i__6].i *
2487
temp2.r;
2488
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2489
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
2490
ix += *incx;
2491
iy += *incy;
2492
/* L30: */
2493
}
2494
i__2 = j + j * a_dim1;
2495
i__3 = j + j * a_dim1;
2496
i__4 = jx;
2497
q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
2498
q__2.i = x[i__4].r * temp1.i + x[i__4].i *
2499
temp1.r;
2500
i__5 = jy;
2501
q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
2502
q__3.i = y[i__5].r * temp2.i + y[i__5].i *
2503
temp2.r;
2504
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
2505
r__1 = a[i__3].r + q__1.r;
2506
a[i__2].r = r__1, a[i__2].i = 0.f;
2507
} else {
2508
i__2 = j + j * a_dim1;
2509
i__3 = j + j * a_dim1;
2510
r__1 = a[i__3].r;
2511
a[i__2].r = r__1, a[i__2].i = 0.f;
2512
}
2513
jx += *incx;
2514
jy += *incy;
2515
/* L40: */
2516
}
2517
}
2518
} else {
2519
2520
/* Form A when A is stored in the lower triangle. */
2521
2522
if (*incx == 1 && *incy == 1) {
2523
i__1 = *n;
2524
for (j = 1; j <= i__1; ++j) {
2525
i__2 = j;
2526
i__3 = j;
2527
if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
2528
|| y[i__3].i != 0.f)) {
2529
r_cnjg(&q__2, &y[j]);
2530
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
2531
alpha->r * q__2.i + alpha->i * q__2.r;
2532
temp1.r = q__1.r, temp1.i = q__1.i;
2533
i__2 = j;
2534
q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
2535
q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
2536
.r;
2537
r_cnjg(&q__1, &q__2);
2538
temp2.r = q__1.r, temp2.i = q__1.i;
2539
i__2 = j + j * a_dim1;
2540
i__3 = j + j * a_dim1;
2541
i__4 = j;
2542
q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
2543
q__2.i = x[i__4].r * temp1.i + x[i__4].i *
2544
temp1.r;
2545
i__5 = j;
2546
q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
2547
q__3.i = y[i__5].r * temp2.i + y[i__5].i *
2548
temp2.r;
2549
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
2550
r__1 = a[i__3].r + q__1.r;
2551
a[i__2].r = r__1, a[i__2].i = 0.f;
2552
i__2 = *n;
2553
for (i__ = j + 1; i__ <= i__2; ++i__) {
2554
i__3 = i__ + j * a_dim1;
2555
i__4 = i__ + j * a_dim1;
2556
i__5 = i__;
2557
q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
2558
q__3.i = x[i__5].r * temp1.i + x[i__5].i *
2559
temp1.r;
2560
q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
2561
q__3.i;
2562
i__6 = i__;
2563
q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
2564
q__4.i = y[i__6].r * temp2.i + y[i__6].i *
2565
temp2.r;
2566
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2567
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
2568
/* L50: */
2569
}
2570
} else {
2571
i__2 = j + j * a_dim1;
2572
i__3 = j + j * a_dim1;
2573
r__1 = a[i__3].r;
2574
a[i__2].r = r__1, a[i__2].i = 0.f;
2575
}
2576
/* L60: */
2577
}
2578
} else {
2579
i__1 = *n;
2580
for (j = 1; j <= i__1; ++j) {
2581
i__2 = jx;
2582
i__3 = jy;
2583
if (x[i__2].r != 0.f || x[i__2].i != 0.f || (y[i__3].r != 0.f
2584
|| y[i__3].i != 0.f)) {
2585
r_cnjg(&q__2, &y[jy]);
2586
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
2587
alpha->r * q__2.i + alpha->i * q__2.r;
2588
temp1.r = q__1.r, temp1.i = q__1.i;
2589
i__2 = jx;
2590
q__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
2591
q__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
2592
.r;
2593
r_cnjg(&q__1, &q__2);
2594
temp2.r = q__1.r, temp2.i = q__1.i;
2595
i__2 = j + j * a_dim1;
2596
i__3 = j + j * a_dim1;
2597
i__4 = jx;
2598
q__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
2599
q__2.i = x[i__4].r * temp1.i + x[i__4].i *
2600
temp1.r;
2601
i__5 = jy;
2602
q__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
2603
q__3.i = y[i__5].r * temp2.i + y[i__5].i *
2604
temp2.r;
2605
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
2606
r__1 = a[i__3].r + q__1.r;
2607
a[i__2].r = r__1, a[i__2].i = 0.f;
2608
ix = jx;
2609
iy = jy;
2610
i__2 = *n;
2611
for (i__ = j + 1; i__ <= i__2; ++i__) {
2612
ix += *incx;
2613
iy += *incy;
2614
i__3 = i__ + j * a_dim1;
2615
i__4 = i__ + j * a_dim1;
2616
i__5 = ix;
2617
q__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
2618
q__3.i = x[i__5].r * temp1.i + x[i__5].i *
2619
temp1.r;
2620
q__2.r = a[i__4].r + q__3.r, q__2.i = a[i__4].i +
2621
q__3.i;
2622
i__6 = iy;
2623
q__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
2624
q__4.i = y[i__6].r * temp2.i + y[i__6].i *
2625
temp2.r;
2626
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
2627
a[i__3].r = q__1.r, a[i__3].i = q__1.i;
2628
/* L70: */
2629
}
2630
} else {
2631
i__2 = j + j * a_dim1;
2632
i__3 = j + j * a_dim1;
2633
r__1 = a[i__3].r;
2634
a[i__2].r = r__1, a[i__2].i = 0.f;
2635
}
2636
jx += *incx;
2637
jy += *incy;
2638
/* L80: */
2639
}
2640
}
2641
}
2642
2643
return 0;
2644
2645
/* End of CHER2 . */
2646
2647
} /* cher2_ */
2648
2649
/* Subroutine */ int cher2k_(char *uplo, char *trans, integer *n, integer *k,
2650
singlecomplex *alpha, singlecomplex *a, integer *lda, singlecomplex *b, integer *ldb,
2651
real *beta, singlecomplex *c__, integer *ldc)
2652
{
2653
/* System generated locals */
2654
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
2655
i__3, i__4, i__5, i__6, i__7;
2656
real r__1;
2657
singlecomplex q__1, q__2, q__3, q__4, q__5, q__6;
2658
2659
/* Local variables */
2660
static integer i__, j, l, info;
2661
static singlecomplex temp1, temp2;
2662
extern logical lsame_(char *, char *);
2663
static integer nrowa;
2664
static logical upper;
2665
extern /* Subroutine */ int xerbla_(char *, integer *);
2666
2667
2668
/*
2669
Purpose
2670
=======
2671
2672
CHER2K performs one of the hermitian rank 2k operations
2673
2674
C := alpha*A*conjg( B' ) + conjg( alpha )*B*conjg( A' ) + beta*C,
2675
2676
or
2677
2678
C := alpha*conjg( A' )*B + conjg( alpha )*conjg( B' )*A + beta*C,
2679
2680
where alpha and beta are scalars with beta real, C is an n by n
2681
hermitian matrix and A and B are n by k matrices in the first case
2682
and k by n matrices in the second case.
2683
2684
Arguments
2685
==========
2686
2687
UPLO - CHARACTER*1.
2688
On entry, UPLO specifies whether the upper or lower
2689
triangular part of the array C is to be referenced as
2690
follows:
2691
2692
UPLO = 'U' or 'u' Only the upper triangular part of C
2693
is to be referenced.
2694
2695
UPLO = 'L' or 'l' Only the lower triangular part of C
2696
is to be referenced.
2697
2698
Unchanged on exit.
2699
2700
TRANS - CHARACTER*1.
2701
On entry, TRANS specifies the operation to be performed as
2702
follows:
2703
2704
TRANS = 'N' or 'n' C := alpha*A*conjg( B' ) +
2705
conjg( alpha )*B*conjg( A' ) +
2706
beta*C.
2707
2708
TRANS = 'C' or 'c' C := alpha*conjg( A' )*B +
2709
conjg( alpha )*conjg( B' )*A +
2710
beta*C.
2711
2712
Unchanged on exit.
2713
2714
N - INTEGER.
2715
On entry, N specifies the order of the matrix C. N must be
2716
at least zero.
2717
Unchanged on exit.
2718
2719
K - INTEGER.
2720
On entry with TRANS = 'N' or 'n', K specifies the number
2721
of columns of the matrices A and B, and on entry with
2722
TRANS = 'C' or 'c', K specifies the number of rows of the
2723
matrices A and B. K must be at least zero.
2724
Unchanged on exit.
2725
2726
ALPHA - COMPLEX .
2727
On entry, ALPHA specifies the scalar alpha.
2728
Unchanged on exit.
2729
2730
A - COMPLEX array of DIMENSION ( LDA, ka ), where ka is
2731
k when TRANS = 'N' or 'n', and is n otherwise.
2732
Before entry with TRANS = 'N' or 'n', the leading n by k
2733
part of the array A must contain the matrix A, otherwise
2734
the leading k by n part of the array A must contain the
2735
matrix A.
2736
Unchanged on exit.
2737
2738
LDA - INTEGER.
2739
On entry, LDA specifies the first dimension of A as declared
2740
in the calling (sub) program. When TRANS = 'N' or 'n'
2741
then LDA must be at least max( 1, n ), otherwise LDA must
2742
be at least max( 1, k ).
2743
Unchanged on exit.
2744
2745
B - COMPLEX array of DIMENSION ( LDB, kb ), where kb is
2746
k when TRANS = 'N' or 'n', and is n otherwise.
2747
Before entry with TRANS = 'N' or 'n', the leading n by k
2748
part of the array B must contain the matrix B, otherwise
2749
the leading k by n part of the array B must contain the
2750
matrix B.
2751
Unchanged on exit.
2752
2753
LDB - INTEGER.
2754
On entry, LDB specifies the first dimension of B as declared
2755
in the calling (sub) program. When TRANS = 'N' or 'n'
2756
then LDB must be at least max( 1, n ), otherwise LDB must
2757
be at least max( 1, k ).
2758
Unchanged on exit.
2759
2760
BETA - REAL .
2761
On entry, BETA specifies the scalar beta.
2762
Unchanged on exit.
2763
2764
C - COMPLEX array of DIMENSION ( LDC, n ).
2765
Before entry with UPLO = 'U' or 'u', the leading n by n
2766
upper triangular part of the array C must contain the upper
2767
triangular part of the hermitian matrix and the strictly
2768
lower triangular part of C is not referenced. On exit, the
2769
upper triangular part of the array C is overwritten by the
2770
upper triangular part of the updated matrix.
2771
Before entry with UPLO = 'L' or 'l', the leading n by n
2772
lower triangular part of the array C must contain the lower
2773
triangular part of the hermitian matrix and the strictly
2774
upper triangular part of C is not referenced. On exit, the
2775
lower triangular part of the array C is overwritten by the
2776
lower triangular part of the updated matrix.
2777
Note that the imaginary parts of the diagonal elements need
2778
not be set, they are assumed to be zero, and on exit they
2779
are set to zero.
2780
2781
LDC - INTEGER.
2782
On entry, LDC specifies the first dimension of C as declared
2783
in the calling (sub) program. LDC must be at least
2784
max( 1, n ).
2785
Unchanged on exit.
2786
2787
Further Details
2788
===============
2789
2790
Level 3 Blas routine.
2791
2792
-- Written on 8-February-1989.
2793
Jack Dongarra, Argonne National Laboratory.
2794
Iain Duff, AERE Harwell.
2795
Jeremy Du Croz, Numerical Algorithms Group Ltd.
2796
Sven Hammarling, Numerical Algorithms Group Ltd.
2797
2798
-- Modified 8-Nov-93 to set C(J,J) to REAL( C(J,J) ) when BETA = 1.
2799
Ed Anderson, Cray Research Inc.
2800
2801
=====================================================================
2802
2803
2804
Test the input parameters.
2805
*/
2806
2807
/* Parameter adjustments */
2808
a_dim1 = *lda;
2809
a_offset = 1 + a_dim1;
2810
a -= a_offset;
2811
b_dim1 = *ldb;
2812
b_offset = 1 + b_dim1;
2813
b -= b_offset;
2814
c_dim1 = *ldc;
2815
c_offset = 1 + c_dim1;
2816
c__ -= c_offset;
2817
2818
/* Function Body */
2819
if (lsame_(trans, "N")) {
2820
nrowa = *n;
2821
} else {
2822
nrowa = *k;
2823
}
2824
upper = lsame_(uplo, "U");
2825
2826
info = 0;
2827
if (! upper && ! lsame_(uplo, "L")) {
2828
info = 1;
2829
} else if (! lsame_(trans, "N") && ! lsame_(trans,
2830
"C")) {
2831
info = 2;
2832
} else if (*n < 0) {
2833
info = 3;
2834
} else if (*k < 0) {
2835
info = 4;
2836
} else if (*lda < max(1,nrowa)) {
2837
info = 7;
2838
} else if (*ldb < max(1,nrowa)) {
2839
info = 9;
2840
} else if (*ldc < max(1,*n)) {
2841
info = 12;
2842
}
2843
if (info != 0) {
2844
xerbla_("CHER2K", &info);
2845
return 0;
2846
}
2847
2848
/* Quick return if possible. */
2849
2850
if (*n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0) && *beta ==
2851
1.f) {
2852
return 0;
2853
}
2854
2855
/* And when alpha.eq.zero. */
2856
2857
if (alpha->r == 0.f && alpha->i == 0.f) {
2858
if (upper) {
2859
if (*beta == 0.f) {
2860
i__1 = *n;
2861
for (j = 1; j <= i__1; ++j) {
2862
i__2 = j;
2863
for (i__ = 1; i__ <= i__2; ++i__) {
2864
i__3 = i__ + j * c_dim1;
2865
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
2866
/* L10: */
2867
}
2868
/* L20: */
2869
}
2870
} else {
2871
i__1 = *n;
2872
for (j = 1; j <= i__1; ++j) {
2873
i__2 = j - 1;
2874
for (i__ = 1; i__ <= i__2; ++i__) {
2875
i__3 = i__ + j * c_dim1;
2876
i__4 = i__ + j * c_dim1;
2877
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
2878
i__4].i;
2879
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
2880
/* L30: */
2881
}
2882
i__2 = j + j * c_dim1;
2883
i__3 = j + j * c_dim1;
2884
r__1 = *beta * c__[i__3].r;
2885
c__[i__2].r = r__1, c__[i__2].i = 0.f;
2886
/* L40: */
2887
}
2888
}
2889
} else {
2890
if (*beta == 0.f) {
2891
i__1 = *n;
2892
for (j = 1; j <= i__1; ++j) {
2893
i__2 = *n;
2894
for (i__ = j; i__ <= i__2; ++i__) {
2895
i__3 = i__ + j * c_dim1;
2896
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
2897
/* L50: */
2898
}
2899
/* L60: */
2900
}
2901
} else {
2902
i__1 = *n;
2903
for (j = 1; j <= i__1; ++j) {
2904
i__2 = j + j * c_dim1;
2905
i__3 = j + j * c_dim1;
2906
r__1 = *beta * c__[i__3].r;
2907
c__[i__2].r = r__1, c__[i__2].i = 0.f;
2908
i__2 = *n;
2909
for (i__ = j + 1; i__ <= i__2; ++i__) {
2910
i__3 = i__ + j * c_dim1;
2911
i__4 = i__ + j * c_dim1;
2912
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
2913
i__4].i;
2914
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
2915
/* L70: */
2916
}
2917
/* L80: */
2918
}
2919
}
2920
}
2921
return 0;
2922
}
2923
2924
/* Start the operations. */
2925
2926
if (lsame_(trans, "N")) {
2927
2928
/*
2929
Form C := alpha*A*conjg( B' ) + conjg( alpha )*B*conjg( A' ) +
2930
C.
2931
*/
2932
2933
if (upper) {
2934
i__1 = *n;
2935
for (j = 1; j <= i__1; ++j) {
2936
if (*beta == 0.f) {
2937
i__2 = j;
2938
for (i__ = 1; i__ <= i__2; ++i__) {
2939
i__3 = i__ + j * c_dim1;
2940
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
2941
/* L90: */
2942
}
2943
} else if (*beta != 1.f) {
2944
i__2 = j - 1;
2945
for (i__ = 1; i__ <= i__2; ++i__) {
2946
i__3 = i__ + j * c_dim1;
2947
i__4 = i__ + j * c_dim1;
2948
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
2949
i__4].i;
2950
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
2951
/* L100: */
2952
}
2953
i__2 = j + j * c_dim1;
2954
i__3 = j + j * c_dim1;
2955
r__1 = *beta * c__[i__3].r;
2956
c__[i__2].r = r__1, c__[i__2].i = 0.f;
2957
} else {
2958
i__2 = j + j * c_dim1;
2959
i__3 = j + j * c_dim1;
2960
r__1 = c__[i__3].r;
2961
c__[i__2].r = r__1, c__[i__2].i = 0.f;
2962
}
2963
i__2 = *k;
2964
for (l = 1; l <= i__2; ++l) {
2965
i__3 = j + l * a_dim1;
2966
i__4 = j + l * b_dim1;
2967
if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
2968
0.f || b[i__4].i != 0.f)) {
2969
r_cnjg(&q__2, &b[j + l * b_dim1]);
2970
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
2971
q__1.i = alpha->r * q__2.i + alpha->i *
2972
q__2.r;
2973
temp1.r = q__1.r, temp1.i = q__1.i;
2974
i__3 = j + l * a_dim1;
2975
q__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
2976
q__2.i = alpha->r * a[i__3].i + alpha->i * a[
2977
i__3].r;
2978
r_cnjg(&q__1, &q__2);
2979
temp2.r = q__1.r, temp2.i = q__1.i;
2980
i__3 = j - 1;
2981
for (i__ = 1; i__ <= i__3; ++i__) {
2982
i__4 = i__ + j * c_dim1;
2983
i__5 = i__ + j * c_dim1;
2984
i__6 = i__ + l * a_dim1;
2985
q__3.r = a[i__6].r * temp1.r - a[i__6].i *
2986
temp1.i, q__3.i = a[i__6].r * temp1.i + a[
2987
i__6].i * temp1.r;
2988
q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
2989
.i + q__3.i;
2990
i__7 = i__ + l * b_dim1;
2991
q__4.r = b[i__7].r * temp2.r - b[i__7].i *
2992
temp2.i, q__4.i = b[i__7].r * temp2.i + b[
2993
i__7].i * temp2.r;
2994
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
2995
q__4.i;
2996
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
2997
/* L110: */
2998
}
2999
i__3 = j + j * c_dim1;
3000
i__4 = j + j * c_dim1;
3001
i__5 = j + l * a_dim1;
3002
q__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
3003
q__2.i = a[i__5].r * temp1.i + a[i__5].i *
3004
temp1.r;
3005
i__6 = j + l * b_dim1;
3006
q__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
3007
q__3.i = b[i__6].r * temp2.i + b[i__6].i *
3008
temp2.r;
3009
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3010
r__1 = c__[i__4].r + q__1.r;
3011
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3012
}
3013
/* L120: */
3014
}
3015
/* L130: */
3016
}
3017
} else {
3018
i__1 = *n;
3019
for (j = 1; j <= i__1; ++j) {
3020
if (*beta == 0.f) {
3021
i__2 = *n;
3022
for (i__ = j; i__ <= i__2; ++i__) {
3023
i__3 = i__ + j * c_dim1;
3024
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
3025
/* L140: */
3026
}
3027
} else if (*beta != 1.f) {
3028
i__2 = *n;
3029
for (i__ = j + 1; i__ <= i__2; ++i__) {
3030
i__3 = i__ + j * c_dim1;
3031
i__4 = i__ + j * c_dim1;
3032
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
3033
i__4].i;
3034
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3035
/* L150: */
3036
}
3037
i__2 = j + j * c_dim1;
3038
i__3 = j + j * c_dim1;
3039
r__1 = *beta * c__[i__3].r;
3040
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3041
} else {
3042
i__2 = j + j * c_dim1;
3043
i__3 = j + j * c_dim1;
3044
r__1 = c__[i__3].r;
3045
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3046
}
3047
i__2 = *k;
3048
for (l = 1; l <= i__2; ++l) {
3049
i__3 = j + l * a_dim1;
3050
i__4 = j + l * b_dim1;
3051
if (a[i__3].r != 0.f || a[i__3].i != 0.f || (b[i__4].r !=
3052
0.f || b[i__4].i != 0.f)) {
3053
r_cnjg(&q__2, &b[j + l * b_dim1]);
3054
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i,
3055
q__1.i = alpha->r * q__2.i + alpha->i *
3056
q__2.r;
3057
temp1.r = q__1.r, temp1.i = q__1.i;
3058
i__3 = j + l * a_dim1;
3059
q__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
3060
q__2.i = alpha->r * a[i__3].i + alpha->i * a[
3061
i__3].r;
3062
r_cnjg(&q__1, &q__2);
3063
temp2.r = q__1.r, temp2.i = q__1.i;
3064
i__3 = *n;
3065
for (i__ = j + 1; i__ <= i__3; ++i__) {
3066
i__4 = i__ + j * c_dim1;
3067
i__5 = i__ + j * c_dim1;
3068
i__6 = i__ + l * a_dim1;
3069
q__3.r = a[i__6].r * temp1.r - a[i__6].i *
3070
temp1.i, q__3.i = a[i__6].r * temp1.i + a[
3071
i__6].i * temp1.r;
3072
q__2.r = c__[i__5].r + q__3.r, q__2.i = c__[i__5]
3073
.i + q__3.i;
3074
i__7 = i__ + l * b_dim1;
3075
q__4.r = b[i__7].r * temp2.r - b[i__7].i *
3076
temp2.i, q__4.i = b[i__7].r * temp2.i + b[
3077
i__7].i * temp2.r;
3078
q__1.r = q__2.r + q__4.r, q__1.i = q__2.i +
3079
q__4.i;
3080
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
3081
/* L160: */
3082
}
3083
i__3 = j + j * c_dim1;
3084
i__4 = j + j * c_dim1;
3085
i__5 = j + l * a_dim1;
3086
q__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
3087
q__2.i = a[i__5].r * temp1.i + a[i__5].i *
3088
temp1.r;
3089
i__6 = j + l * b_dim1;
3090
q__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
3091
q__3.i = b[i__6].r * temp2.i + b[i__6].i *
3092
temp2.r;
3093
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3094
r__1 = c__[i__4].r + q__1.r;
3095
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3096
}
3097
/* L170: */
3098
}
3099
/* L180: */
3100
}
3101
}
3102
} else {
3103
3104
/*
3105
Form C := alpha*conjg( A' )*B + conjg( alpha )*conjg( B' )*A +
3106
C.
3107
*/
3108
3109
if (upper) {
3110
i__1 = *n;
3111
for (j = 1; j <= i__1; ++j) {
3112
i__2 = j;
3113
for (i__ = 1; i__ <= i__2; ++i__) {
3114
temp1.r = 0.f, temp1.i = 0.f;
3115
temp2.r = 0.f, temp2.i = 0.f;
3116
i__3 = *k;
3117
for (l = 1; l <= i__3; ++l) {
3118
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
3119
i__4 = l + j * b_dim1;
3120
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
3121
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
3122
.r;
3123
q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
3124
temp1.r = q__1.r, temp1.i = q__1.i;
3125
r_cnjg(&q__3, &b[l + i__ * b_dim1]);
3126
i__4 = l + j * a_dim1;
3127
q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
3128
q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
3129
.r;
3130
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
3131
temp2.r = q__1.r, temp2.i = q__1.i;
3132
/* L190: */
3133
}
3134
if (i__ == j) {
3135
if (*beta == 0.f) {
3136
i__3 = j + j * c_dim1;
3137
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3138
q__2.i = alpha->r * temp1.i + alpha->i *
3139
temp1.r;
3140
r_cnjg(&q__4, alpha);
3141
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3142
q__3.i = q__4.r * temp2.i + q__4.i *
3143
temp2.r;
3144
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3145
q__3.i;
3146
r__1 = q__1.r;
3147
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3148
} else {
3149
i__3 = j + j * c_dim1;
3150
i__4 = j + j * c_dim1;
3151
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3152
q__2.i = alpha->r * temp1.i + alpha->i *
3153
temp1.r;
3154
r_cnjg(&q__4, alpha);
3155
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3156
q__3.i = q__4.r * temp2.i + q__4.i *
3157
temp2.r;
3158
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3159
q__3.i;
3160
r__1 = *beta * c__[i__4].r + q__1.r;
3161
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3162
}
3163
} else {
3164
if (*beta == 0.f) {
3165
i__3 = i__ + j * c_dim1;
3166
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3167
q__2.i = alpha->r * temp1.i + alpha->i *
3168
temp1.r;
3169
r_cnjg(&q__4, alpha);
3170
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3171
q__3.i = q__4.r * temp2.i + q__4.i *
3172
temp2.r;
3173
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3174
q__3.i;
3175
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3176
} else {
3177
i__3 = i__ + j * c_dim1;
3178
i__4 = i__ + j * c_dim1;
3179
q__3.r = *beta * c__[i__4].r, q__3.i = *beta *
3180
c__[i__4].i;
3181
q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
3182
q__4.i = alpha->r * temp1.i + alpha->i *
3183
temp1.r;
3184
q__2.r = q__3.r + q__4.r, q__2.i = q__3.i +
3185
q__4.i;
3186
r_cnjg(&q__6, alpha);
3187
q__5.r = q__6.r * temp2.r - q__6.i * temp2.i,
3188
q__5.i = q__6.r * temp2.i + q__6.i *
3189
temp2.r;
3190
q__1.r = q__2.r + q__5.r, q__1.i = q__2.i +
3191
q__5.i;
3192
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3193
}
3194
}
3195
/* L200: */
3196
}
3197
/* L210: */
3198
}
3199
} else {
3200
i__1 = *n;
3201
for (j = 1; j <= i__1; ++j) {
3202
i__2 = *n;
3203
for (i__ = j; i__ <= i__2; ++i__) {
3204
temp1.r = 0.f, temp1.i = 0.f;
3205
temp2.r = 0.f, temp2.i = 0.f;
3206
i__3 = *k;
3207
for (l = 1; l <= i__3; ++l) {
3208
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
3209
i__4 = l + j * b_dim1;
3210
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
3211
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
3212
.r;
3213
q__1.r = temp1.r + q__2.r, q__1.i = temp1.i + q__2.i;
3214
temp1.r = q__1.r, temp1.i = q__1.i;
3215
r_cnjg(&q__3, &b[l + i__ * b_dim1]);
3216
i__4 = l + j * a_dim1;
3217
q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
3218
q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
3219
.r;
3220
q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
3221
temp2.r = q__1.r, temp2.i = q__1.i;
3222
/* L220: */
3223
}
3224
if (i__ == j) {
3225
if (*beta == 0.f) {
3226
i__3 = j + j * c_dim1;
3227
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3228
q__2.i = alpha->r * temp1.i + alpha->i *
3229
temp1.r;
3230
r_cnjg(&q__4, alpha);
3231
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3232
q__3.i = q__4.r * temp2.i + q__4.i *
3233
temp2.r;
3234
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3235
q__3.i;
3236
r__1 = q__1.r;
3237
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3238
} else {
3239
i__3 = j + j * c_dim1;
3240
i__4 = j + j * c_dim1;
3241
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3242
q__2.i = alpha->r * temp1.i + alpha->i *
3243
temp1.r;
3244
r_cnjg(&q__4, alpha);
3245
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3246
q__3.i = q__4.r * temp2.i + q__4.i *
3247
temp2.r;
3248
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3249
q__3.i;
3250
r__1 = *beta * c__[i__4].r + q__1.r;
3251
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3252
}
3253
} else {
3254
if (*beta == 0.f) {
3255
i__3 = i__ + j * c_dim1;
3256
q__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
3257
q__2.i = alpha->r * temp1.i + alpha->i *
3258
temp1.r;
3259
r_cnjg(&q__4, alpha);
3260
q__3.r = q__4.r * temp2.r - q__4.i * temp2.i,
3261
q__3.i = q__4.r * temp2.i + q__4.i *
3262
temp2.r;
3263
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i +
3264
q__3.i;
3265
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3266
} else {
3267
i__3 = i__ + j * c_dim1;
3268
i__4 = i__ + j * c_dim1;
3269
q__3.r = *beta * c__[i__4].r, q__3.i = *beta *
3270
c__[i__4].i;
3271
q__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
3272
q__4.i = alpha->r * temp1.i + alpha->i *
3273
temp1.r;
3274
q__2.r = q__3.r + q__4.r, q__2.i = q__3.i +
3275
q__4.i;
3276
r_cnjg(&q__6, alpha);
3277
q__5.r = q__6.r * temp2.r - q__6.i * temp2.i,
3278
q__5.i = q__6.r * temp2.i + q__6.i *
3279
temp2.r;
3280
q__1.r = q__2.r + q__5.r, q__1.i = q__2.i +
3281
q__5.i;
3282
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3283
}
3284
}
3285
/* L230: */
3286
}
3287
/* L240: */
3288
}
3289
}
3290
}
3291
3292
return 0;
3293
3294
/* End of CHER2K. */
3295
3296
} /* cher2k_ */
3297
3298
/* Subroutine */ int cherk_(char *uplo, char *trans, integer *n, integer *k,
3299
real *alpha, singlecomplex *a, integer *lda, real *beta, singlecomplex *c__,
3300
integer *ldc)
3301
{
3302
/* System generated locals */
3303
integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3, i__4, i__5,
3304
i__6;
3305
real r__1;
3306
singlecomplex q__1, q__2, q__3;
3307
3308
/* Local variables */
3309
static integer i__, j, l, info;
3310
static singlecomplex temp;
3311
extern logical lsame_(char *, char *);
3312
static integer nrowa;
3313
static real rtemp;
3314
static logical upper;
3315
extern /* Subroutine */ int xerbla_(char *, integer *);
3316
3317
3318
/*
3319
Purpose
3320
=======
3321
3322
CHERK performs one of the hermitian rank k operations
3323
3324
C := alpha*A*conjg( A' ) + beta*C,
3325
3326
or
3327
3328
C := alpha*conjg( A' )*A + beta*C,
3329
3330
where alpha and beta are real scalars, C is an n by n hermitian
3331
matrix and A is an n by k matrix in the first case and a k by n
3332
matrix in the second case.
3333
3334
Arguments
3335
==========
3336
3337
UPLO - CHARACTER*1.
3338
On entry, UPLO specifies whether the upper or lower
3339
triangular part of the array C is to be referenced as
3340
follows:
3341
3342
UPLO = 'U' or 'u' Only the upper triangular part of C
3343
is to be referenced.
3344
3345
UPLO = 'L' or 'l' Only the lower triangular part of C
3346
is to be referenced.
3347
3348
Unchanged on exit.
3349
3350
TRANS - CHARACTER*1.
3351
On entry, TRANS specifies the operation to be performed as
3352
follows:
3353
3354
TRANS = 'N' or 'n' C := alpha*A*conjg( A' ) + beta*C.
3355
3356
TRANS = 'C' or 'c' C := alpha*conjg( A' )*A + beta*C.
3357
3358
Unchanged on exit.
3359
3360
N - INTEGER.
3361
On entry, N specifies the order of the matrix C. N must be
3362
at least zero.
3363
Unchanged on exit.
3364
3365
K - INTEGER.
3366
On entry with TRANS = 'N' or 'n', K specifies the number
3367
of columns of the matrix A, and on entry with
3368
TRANS = 'C' or 'c', K specifies the number of rows of the
3369
matrix A. K must be at least zero.
3370
Unchanged on exit.
3371
3372
ALPHA - REAL .
3373
On entry, ALPHA specifies the scalar alpha.
3374
Unchanged on exit.
3375
3376
A - COMPLEX array of DIMENSION ( LDA, ka ), where ka is
3377
k when TRANS = 'N' or 'n', and is n otherwise.
3378
Before entry with TRANS = 'N' or 'n', the leading n by k
3379
part of the array A must contain the matrix A, otherwise
3380
the leading k by n part of the array A must contain the
3381
matrix A.
3382
Unchanged on exit.
3383
3384
LDA - INTEGER.
3385
On entry, LDA specifies the first dimension of A as declared
3386
in the calling (sub) program. When TRANS = 'N' or 'n'
3387
then LDA must be at least max( 1, n ), otherwise LDA must
3388
be at least max( 1, k ).
3389
Unchanged on exit.
3390
3391
BETA - REAL .
3392
On entry, BETA specifies the scalar beta.
3393
Unchanged on exit.
3394
3395
C - COMPLEX array of DIMENSION ( LDC, n ).
3396
Before entry with UPLO = 'U' or 'u', the leading n by n
3397
upper triangular part of the array C must contain the upper
3398
triangular part of the hermitian matrix and the strictly
3399
lower triangular part of C is not referenced. On exit, the
3400
upper triangular part of the array C is overwritten by the
3401
upper triangular part of the updated matrix.
3402
Before entry with UPLO = 'L' or 'l', the leading n by n
3403
lower triangular part of the array C must contain the lower
3404
triangular part of the hermitian matrix and the strictly
3405
upper triangular part of C is not referenced. On exit, the
3406
lower triangular part of the array C is overwritten by the
3407
lower triangular part of the updated matrix.
3408
Note that the imaginary parts of the diagonal elements need
3409
not be set, they are assumed to be zero, and on exit they
3410
are set to zero.
3411
3412
LDC - INTEGER.
3413
On entry, LDC specifies the first dimension of C as declared
3414
in the calling (sub) program. LDC must be at least
3415
max( 1, n ).
3416
Unchanged on exit.
3417
3418
Further Details
3419
===============
3420
3421
Level 3 Blas routine.
3422
3423
-- Written on 8-February-1989.
3424
Jack Dongarra, Argonne National Laboratory.
3425
Iain Duff, AERE Harwell.
3426
Jeremy Du Croz, Numerical Algorithms Group Ltd.
3427
Sven Hammarling, Numerical Algorithms Group Ltd.
3428
3429
-- Modified 8-Nov-93 to set C(J,J) to REAL( C(J,J) ) when BETA = 1.
3430
Ed Anderson, Cray Research Inc.
3431
3432
=====================================================================
3433
3434
3435
Test the input parameters.
3436
*/
3437
3438
/* Parameter adjustments */
3439
a_dim1 = *lda;
3440
a_offset = 1 + a_dim1;
3441
a -= a_offset;
3442
c_dim1 = *ldc;
3443
c_offset = 1 + c_dim1;
3444
c__ -= c_offset;
3445
3446
/* Function Body */
3447
if (lsame_(trans, "N")) {
3448
nrowa = *n;
3449
} else {
3450
nrowa = *k;
3451
}
3452
upper = lsame_(uplo, "U");
3453
3454
info = 0;
3455
if (! upper && ! lsame_(uplo, "L")) {
3456
info = 1;
3457
} else if (! lsame_(trans, "N") && ! lsame_(trans,
3458
"C")) {
3459
info = 2;
3460
} else if (*n < 0) {
3461
info = 3;
3462
} else if (*k < 0) {
3463
info = 4;
3464
} else if (*lda < max(1,nrowa)) {
3465
info = 7;
3466
} else if (*ldc < max(1,*n)) {
3467
info = 10;
3468
}
3469
if (info != 0) {
3470
xerbla_("CHERK ", &info);
3471
return 0;
3472
}
3473
3474
/* Quick return if possible. */
3475
3476
if (*n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
3477
return 0;
3478
}
3479
3480
/* And when alpha.eq.zero. */
3481
3482
if (*alpha == 0.f) {
3483
if (upper) {
3484
if (*beta == 0.f) {
3485
i__1 = *n;
3486
for (j = 1; j <= i__1; ++j) {
3487
i__2 = j;
3488
for (i__ = 1; i__ <= i__2; ++i__) {
3489
i__3 = i__ + j * c_dim1;
3490
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
3491
/* L10: */
3492
}
3493
/* L20: */
3494
}
3495
} else {
3496
i__1 = *n;
3497
for (j = 1; j <= i__1; ++j) {
3498
i__2 = j - 1;
3499
for (i__ = 1; i__ <= i__2; ++i__) {
3500
i__3 = i__ + j * c_dim1;
3501
i__4 = i__ + j * c_dim1;
3502
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
3503
i__4].i;
3504
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3505
/* L30: */
3506
}
3507
i__2 = j + j * c_dim1;
3508
i__3 = j + j * c_dim1;
3509
r__1 = *beta * c__[i__3].r;
3510
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3511
/* L40: */
3512
}
3513
}
3514
} else {
3515
if (*beta == 0.f) {
3516
i__1 = *n;
3517
for (j = 1; j <= i__1; ++j) {
3518
i__2 = *n;
3519
for (i__ = j; i__ <= i__2; ++i__) {
3520
i__3 = i__ + j * c_dim1;
3521
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
3522
/* L50: */
3523
}
3524
/* L60: */
3525
}
3526
} else {
3527
i__1 = *n;
3528
for (j = 1; j <= i__1; ++j) {
3529
i__2 = j + j * c_dim1;
3530
i__3 = j + j * c_dim1;
3531
r__1 = *beta * c__[i__3].r;
3532
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3533
i__2 = *n;
3534
for (i__ = j + 1; i__ <= i__2; ++i__) {
3535
i__3 = i__ + j * c_dim1;
3536
i__4 = i__ + j * c_dim1;
3537
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
3538
i__4].i;
3539
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3540
/* L70: */
3541
}
3542
/* L80: */
3543
}
3544
}
3545
}
3546
return 0;
3547
}
3548
3549
/* Start the operations. */
3550
3551
if (lsame_(trans, "N")) {
3552
3553
/* Form C := alpha*A*conjg( A' ) + beta*C. */
3554
3555
if (upper) {
3556
i__1 = *n;
3557
for (j = 1; j <= i__1; ++j) {
3558
if (*beta == 0.f) {
3559
i__2 = j;
3560
for (i__ = 1; i__ <= i__2; ++i__) {
3561
i__3 = i__ + j * c_dim1;
3562
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
3563
/* L90: */
3564
}
3565
} else if (*beta != 1.f) {
3566
i__2 = j - 1;
3567
for (i__ = 1; i__ <= i__2; ++i__) {
3568
i__3 = i__ + j * c_dim1;
3569
i__4 = i__ + j * c_dim1;
3570
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
3571
i__4].i;
3572
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3573
/* L100: */
3574
}
3575
i__2 = j + j * c_dim1;
3576
i__3 = j + j * c_dim1;
3577
r__1 = *beta * c__[i__3].r;
3578
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3579
} else {
3580
i__2 = j + j * c_dim1;
3581
i__3 = j + j * c_dim1;
3582
r__1 = c__[i__3].r;
3583
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3584
}
3585
i__2 = *k;
3586
for (l = 1; l <= i__2; ++l) {
3587
i__3 = j + l * a_dim1;
3588
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
3589
r_cnjg(&q__2, &a[j + l * a_dim1]);
3590
q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
3591
temp.r = q__1.r, temp.i = q__1.i;
3592
i__3 = j - 1;
3593
for (i__ = 1; i__ <= i__3; ++i__) {
3594
i__4 = i__ + j * c_dim1;
3595
i__5 = i__ + j * c_dim1;
3596
i__6 = i__ + l * a_dim1;
3597
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
3598
q__2.i = temp.r * a[i__6].i + temp.i * a[
3599
i__6].r;
3600
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
3601
.i + q__2.i;
3602
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
3603
/* L110: */
3604
}
3605
i__3 = j + j * c_dim1;
3606
i__4 = j + j * c_dim1;
3607
i__5 = i__ + l * a_dim1;
3608
q__1.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
3609
q__1.i = temp.r * a[i__5].i + temp.i * a[i__5]
3610
.r;
3611
r__1 = c__[i__4].r + q__1.r;
3612
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3613
}
3614
/* L120: */
3615
}
3616
/* L130: */
3617
}
3618
} else {
3619
i__1 = *n;
3620
for (j = 1; j <= i__1; ++j) {
3621
if (*beta == 0.f) {
3622
i__2 = *n;
3623
for (i__ = j; i__ <= i__2; ++i__) {
3624
i__3 = i__ + j * c_dim1;
3625
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
3626
/* L140: */
3627
}
3628
} else if (*beta != 1.f) {
3629
i__2 = j + j * c_dim1;
3630
i__3 = j + j * c_dim1;
3631
r__1 = *beta * c__[i__3].r;
3632
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3633
i__2 = *n;
3634
for (i__ = j + 1; i__ <= i__2; ++i__) {
3635
i__3 = i__ + j * c_dim1;
3636
i__4 = i__ + j * c_dim1;
3637
q__1.r = *beta * c__[i__4].r, q__1.i = *beta * c__[
3638
i__4].i;
3639
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3640
/* L150: */
3641
}
3642
} else {
3643
i__2 = j + j * c_dim1;
3644
i__3 = j + j * c_dim1;
3645
r__1 = c__[i__3].r;
3646
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3647
}
3648
i__2 = *k;
3649
for (l = 1; l <= i__2; ++l) {
3650
i__3 = j + l * a_dim1;
3651
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
3652
r_cnjg(&q__2, &a[j + l * a_dim1]);
3653
q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
3654
temp.r = q__1.r, temp.i = q__1.i;
3655
i__3 = j + j * c_dim1;
3656
i__4 = j + j * c_dim1;
3657
i__5 = j + l * a_dim1;
3658
q__1.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
3659
q__1.i = temp.r * a[i__5].i + temp.i * a[i__5]
3660
.r;
3661
r__1 = c__[i__4].r + q__1.r;
3662
c__[i__3].r = r__1, c__[i__3].i = 0.f;
3663
i__3 = *n;
3664
for (i__ = j + 1; i__ <= i__3; ++i__) {
3665
i__4 = i__ + j * c_dim1;
3666
i__5 = i__ + j * c_dim1;
3667
i__6 = i__ + l * a_dim1;
3668
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
3669
q__2.i = temp.r * a[i__6].i + temp.i * a[
3670
i__6].r;
3671
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5]
3672
.i + q__2.i;
3673
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
3674
/* L160: */
3675
}
3676
}
3677
/* L170: */
3678
}
3679
/* L180: */
3680
}
3681
}
3682
} else {
3683
3684
/* Form C := alpha*conjg( A' )*A + beta*C. */
3685
3686
if (upper) {
3687
i__1 = *n;
3688
for (j = 1; j <= i__1; ++j) {
3689
i__2 = j - 1;
3690
for (i__ = 1; i__ <= i__2; ++i__) {
3691
temp.r = 0.f, temp.i = 0.f;
3692
i__3 = *k;
3693
for (l = 1; l <= i__3; ++l) {
3694
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
3695
i__4 = l + j * a_dim1;
3696
q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
3697
q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
3698
.r;
3699
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
3700
temp.r = q__1.r, temp.i = q__1.i;
3701
/* L190: */
3702
}
3703
if (*beta == 0.f) {
3704
i__3 = i__ + j * c_dim1;
3705
q__1.r = *alpha * temp.r, q__1.i = *alpha * temp.i;
3706
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3707
} else {
3708
i__3 = i__ + j * c_dim1;
3709
q__2.r = *alpha * temp.r, q__2.i = *alpha * temp.i;
3710
i__4 = i__ + j * c_dim1;
3711
q__3.r = *beta * c__[i__4].r, q__3.i = *beta * c__[
3712
i__4].i;
3713
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3714
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3715
}
3716
/* L200: */
3717
}
3718
rtemp = 0.f;
3719
i__2 = *k;
3720
for (l = 1; l <= i__2; ++l) {
3721
r_cnjg(&q__3, &a[l + j * a_dim1]);
3722
i__3 = l + j * a_dim1;
3723
q__2.r = q__3.r * a[i__3].r - q__3.i * a[i__3].i, q__2.i =
3724
q__3.r * a[i__3].i + q__3.i * a[i__3].r;
3725
q__1.r = rtemp + q__2.r, q__1.i = q__2.i;
3726
rtemp = q__1.r;
3727
/* L210: */
3728
}
3729
if (*beta == 0.f) {
3730
i__2 = j + j * c_dim1;
3731
r__1 = *alpha * rtemp;
3732
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3733
} else {
3734
i__2 = j + j * c_dim1;
3735
i__3 = j + j * c_dim1;
3736
r__1 = *alpha * rtemp + *beta * c__[i__3].r;
3737
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3738
}
3739
/* L220: */
3740
}
3741
} else {
3742
i__1 = *n;
3743
for (j = 1; j <= i__1; ++j) {
3744
rtemp = 0.f;
3745
i__2 = *k;
3746
for (l = 1; l <= i__2; ++l) {
3747
r_cnjg(&q__3, &a[l + j * a_dim1]);
3748
i__3 = l + j * a_dim1;
3749
q__2.r = q__3.r * a[i__3].r - q__3.i * a[i__3].i, q__2.i =
3750
q__3.r * a[i__3].i + q__3.i * a[i__3].r;
3751
q__1.r = rtemp + q__2.r, q__1.i = q__2.i;
3752
rtemp = q__1.r;
3753
/* L230: */
3754
}
3755
if (*beta == 0.f) {
3756
i__2 = j + j * c_dim1;
3757
r__1 = *alpha * rtemp;
3758
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3759
} else {
3760
i__2 = j + j * c_dim1;
3761
i__3 = j + j * c_dim1;
3762
r__1 = *alpha * rtemp + *beta * c__[i__3].r;
3763
c__[i__2].r = r__1, c__[i__2].i = 0.f;
3764
}
3765
i__2 = *n;
3766
for (i__ = j + 1; i__ <= i__2; ++i__) {
3767
temp.r = 0.f, temp.i = 0.f;
3768
i__3 = *k;
3769
for (l = 1; l <= i__3; ++l) {
3770
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
3771
i__4 = l + j * a_dim1;
3772
q__2.r = q__3.r * a[i__4].r - q__3.i * a[i__4].i,
3773
q__2.i = q__3.r * a[i__4].i + q__3.i * a[i__4]
3774
.r;
3775
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
3776
temp.r = q__1.r, temp.i = q__1.i;
3777
/* L240: */
3778
}
3779
if (*beta == 0.f) {
3780
i__3 = i__ + j * c_dim1;
3781
q__1.r = *alpha * temp.r, q__1.i = *alpha * temp.i;
3782
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3783
} else {
3784
i__3 = i__ + j * c_dim1;
3785
q__2.r = *alpha * temp.r, q__2.i = *alpha * temp.i;
3786
i__4 = i__ + j * c_dim1;
3787
q__3.r = *beta * c__[i__4].r, q__3.i = *beta * c__[
3788
i__4].i;
3789
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3790
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
3791
}
3792
/* L250: */
3793
}
3794
/* L260: */
3795
}
3796
}
3797
}
3798
3799
return 0;
3800
3801
/* End of CHERK . */
3802
3803
} /* cherk_ */
3804
3805
/* Subroutine */ int cscal_(integer *n, singlecomplex *ca, singlecomplex *cx, integer *
3806
incx)
3807
{
3808
/* System generated locals */
3809
integer i__1, i__2, i__3, i__4;
3810
singlecomplex q__1;
3811
3812
/* Local variables */
3813
static integer i__, nincx;
3814
3815
3816
/*
3817
Purpose
3818
=======
3819
3820
CSCAL scales a vector by a constant.
3821
3822
Further Details
3823
===============
3824
3825
jack dongarra, linpack, 3/11/78.
3826
modified 3/93 to return if incx .le. 0.
3827
modified 12/3/93, array(1) declarations changed to array(*)
3828
3829
=====================================================================
3830
*/
3831
3832
/* Parameter adjustments */
3833
--cx;
3834
3835
/* Function Body */
3836
if (*n <= 0 || *incx <= 0) {
3837
return 0;
3838
}
3839
if (*incx == 1) {
3840
goto L20;
3841
}
3842
3843
/* code for increment not equal to 1 */
3844
3845
nincx = *n * *incx;
3846
i__1 = nincx;
3847
i__2 = *incx;
3848
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
3849
i__3 = i__;
3850
i__4 = i__;
3851
q__1.r = ca->r * cx[i__4].r - ca->i * cx[i__4].i, q__1.i = ca->r * cx[
3852
i__4].i + ca->i * cx[i__4].r;
3853
cx[i__3].r = q__1.r, cx[i__3].i = q__1.i;
3854
/* L10: */
3855
}
3856
return 0;
3857
3858
/* code for increment equal to 1 */
3859
3860
L20:
3861
i__2 = *n;
3862
for (i__ = 1; i__ <= i__2; ++i__) {
3863
i__1 = i__;
3864
i__3 = i__;
3865
q__1.r = ca->r * cx[i__3].r - ca->i * cx[i__3].i, q__1.i = ca->r * cx[
3866
i__3].i + ca->i * cx[i__3].r;
3867
cx[i__1].r = q__1.r, cx[i__1].i = q__1.i;
3868
/* L30: */
3869
}
3870
return 0;
3871
} /* cscal_ */
3872
3873
/* Subroutine */ int csrot_(integer *n, singlecomplex *cx, integer *incx, singlecomplex *
3874
cy, integer *incy, real *c__, real *s)
3875
{
3876
/* System generated locals */
3877
integer i__1, i__2, i__3, i__4;
3878
singlecomplex q__1, q__2, q__3;
3879
3880
/* Local variables */
3881
static integer i__, ix, iy;
3882
static singlecomplex ctemp;
3883
3884
3885
/*
3886
Purpose
3887
=======
3888
3889
CSROT applies a plane rotation, where the cos and sin (c and s) are real
3890
and the vectors cx and cy are singlecomplex.
3891
jack dongarra, linpack, 3/11/78.
3892
3893
Arguments
3894
==========
3895
3896
N (input) INTEGER
3897
On entry, N specifies the order of the vectors cx and cy.
3898
N must be at least zero.
3899
Unchanged on exit.
3900
3901
CX (input) COMPLEX array, dimension at least
3902
( 1 + ( N - 1 )*abs( INCX ) ).
3903
Before entry, the incremented array CX must contain the n
3904
element vector cx. On exit, CX is overwritten by the updated
3905
vector cx.
3906
3907
INCX (input) INTEGER
3908
On entry, INCX specifies the increment for the elements of
3909
CX. INCX must not be zero.
3910
Unchanged on exit.
3911
3912
CY (input) COMPLEX array, dimension at least
3913
( 1 + ( N - 1 )*abs( INCY ) ).
3914
Before entry, the incremented array CY must contain the n
3915
element vector cy. On exit, CY is overwritten by the updated
3916
vector cy.
3917
3918
INCY (input) INTEGER
3919
On entry, INCY specifies the increment for the elements of
3920
CY. INCY must not be zero.
3921
Unchanged on exit.
3922
3923
C (input) REAL
3924
On entry, C specifies the cosine, cos.
3925
Unchanged on exit.
3926
3927
S (input) REAL
3928
On entry, S specifies the sine, sin.
3929
Unchanged on exit.
3930
3931
=====================================================================
3932
*/
3933
3934
3935
/* Parameter adjustments */
3936
--cy;
3937
--cx;
3938
3939
/* Function Body */
3940
if (*n <= 0) {
3941
return 0;
3942
}
3943
if (*incx == 1 && *incy == 1) {
3944
goto L20;
3945
}
3946
3947
/*
3948
code for unequal increments or equal increments not equal
3949
to 1
3950
*/
3951
3952
ix = 1;
3953
iy = 1;
3954
if (*incx < 0) {
3955
ix = (-(*n) + 1) * *incx + 1;
3956
}
3957
if (*incy < 0) {
3958
iy = (-(*n) + 1) * *incy + 1;
3959
}
3960
i__1 = *n;
3961
for (i__ = 1; i__ <= i__1; ++i__) {
3962
i__2 = ix;
3963
q__2.r = *c__ * cx[i__2].r, q__2.i = *c__ * cx[i__2].i;
3964
i__3 = iy;
3965
q__3.r = *s * cy[i__3].r, q__3.i = *s * cy[i__3].i;
3966
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3967
ctemp.r = q__1.r, ctemp.i = q__1.i;
3968
i__2 = iy;
3969
i__3 = iy;
3970
q__2.r = *c__ * cy[i__3].r, q__2.i = *c__ * cy[i__3].i;
3971
i__4 = ix;
3972
q__3.r = *s * cx[i__4].r, q__3.i = *s * cx[i__4].i;
3973
q__1.r = q__2.r - q__3.r, q__1.i = q__2.i - q__3.i;
3974
cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
3975
i__2 = ix;
3976
cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
3977
ix += *incx;
3978
iy += *incy;
3979
/* L10: */
3980
}
3981
return 0;
3982
3983
/* code for both increments equal to 1 */
3984
3985
L20:
3986
i__1 = *n;
3987
for (i__ = 1; i__ <= i__1; ++i__) {
3988
i__2 = i__;
3989
q__2.r = *c__ * cx[i__2].r, q__2.i = *c__ * cx[i__2].i;
3990
i__3 = i__;
3991
q__3.r = *s * cy[i__3].r, q__3.i = *s * cy[i__3].i;
3992
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
3993
ctemp.r = q__1.r, ctemp.i = q__1.i;
3994
i__2 = i__;
3995
i__3 = i__;
3996
q__2.r = *c__ * cy[i__3].r, q__2.i = *c__ * cy[i__3].i;
3997
i__4 = i__;
3998
q__3.r = *s * cx[i__4].r, q__3.i = *s * cx[i__4].i;
3999
q__1.r = q__2.r - q__3.r, q__1.i = q__2.i - q__3.i;
4000
cy[i__2].r = q__1.r, cy[i__2].i = q__1.i;
4001
i__2 = i__;
4002
cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
4003
/* L30: */
4004
}
4005
return 0;
4006
} /* csrot_ */
4007
4008
/* Subroutine */ int csscal_(integer *n, real *sa, singlecomplex *cx, integer *incx)
4009
{
4010
/* System generated locals */
4011
integer i__1, i__2, i__3, i__4;
4012
real r__1, r__2;
4013
singlecomplex q__1;
4014
4015
/* Local variables */
4016
static integer i__, nincx;
4017
4018
4019
/*
4020
Purpose
4021
=======
4022
4023
CSSCAL scales a complex vector by a real constant.
4024
4025
Further Details
4026
===============
4027
4028
jack dongarra, linpack, 3/11/78.
4029
modified 3/93 to return if incx .le. 0.
4030
modified 12/3/93, array(1) declarations changed to array(*)
4031
4032
=====================================================================
4033
*/
4034
4035
/* Parameter adjustments */
4036
--cx;
4037
4038
/* Function Body */
4039
if (*n <= 0 || *incx <= 0) {
4040
return 0;
4041
}
4042
if (*incx == 1) {
4043
goto L20;
4044
}
4045
4046
/* code for increment not equal to 1 */
4047
4048
nincx = *n * *incx;
4049
i__1 = nincx;
4050
i__2 = *incx;
4051
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
4052
i__3 = i__;
4053
i__4 = i__;
4054
r__1 = *sa * cx[i__4].r;
4055
r__2 = *sa * r_imag(&cx[i__]);
4056
q__1.r = r__1, q__1.i = r__2;
4057
cx[i__3].r = q__1.r, cx[i__3].i = q__1.i;
4058
/* L10: */
4059
}
4060
return 0;
4061
4062
/* code for increment equal to 1 */
4063
4064
L20:
4065
i__2 = *n;
4066
for (i__ = 1; i__ <= i__2; ++i__) {
4067
i__1 = i__;
4068
i__3 = i__;
4069
r__1 = *sa * cx[i__3].r;
4070
r__2 = *sa * r_imag(&cx[i__]);
4071
q__1.r = r__1, q__1.i = r__2;
4072
cx[i__1].r = q__1.r, cx[i__1].i = q__1.i;
4073
/* L30: */
4074
}
4075
return 0;
4076
} /* csscal_ */
4077
4078
/* Subroutine */ int cswap_(integer *n, singlecomplex *cx, integer *incx, singlecomplex *
4079
cy, integer *incy)
4080
{
4081
/* System generated locals */
4082
integer i__1, i__2, i__3;
4083
4084
/* Local variables */
4085
static integer i__, ix, iy;
4086
static singlecomplex ctemp;
4087
4088
4089
/*
4090
Purpose
4091
=======
4092
4093
CSWAP interchanges two vectors.
4094
4095
Further Details
4096
===============
4097
4098
jack dongarra, linpack, 3/11/78.
4099
modified 12/3/93, array(1) declarations changed to array(*)
4100
4101
=====================================================================
4102
*/
4103
4104
/* Parameter adjustments */
4105
--cy;
4106
--cx;
4107
4108
/* Function Body */
4109
if (*n <= 0) {
4110
return 0;
4111
}
4112
if (*incx == 1 && *incy == 1) {
4113
goto L20;
4114
}
4115
4116
/*
4117
code for unequal increments or equal increments not equal
4118
to 1
4119
*/
4120
4121
ix = 1;
4122
iy = 1;
4123
if (*incx < 0) {
4124
ix = (-(*n) + 1) * *incx + 1;
4125
}
4126
if (*incy < 0) {
4127
iy = (-(*n) + 1) * *incy + 1;
4128
}
4129
i__1 = *n;
4130
for (i__ = 1; i__ <= i__1; ++i__) {
4131
i__2 = ix;
4132
ctemp.r = cx[i__2].r, ctemp.i = cx[i__2].i;
4133
i__2 = ix;
4134
i__3 = iy;
4135
cx[i__2].r = cy[i__3].r, cx[i__2].i = cy[i__3].i;
4136
i__2 = iy;
4137
cy[i__2].r = ctemp.r, cy[i__2].i = ctemp.i;
4138
ix += *incx;
4139
iy += *incy;
4140
/* L10: */
4141
}
4142
return 0;
4143
4144
/* code for both increments equal to 1 */
4145
L20:
4146
i__1 = *n;
4147
for (i__ = 1; i__ <= i__1; ++i__) {
4148
i__2 = i__;
4149
ctemp.r = cx[i__2].r, ctemp.i = cx[i__2].i;
4150
i__2 = i__;
4151
i__3 = i__;
4152
cx[i__2].r = cy[i__3].r, cx[i__2].i = cy[i__3].i;
4153
i__2 = i__;
4154
cy[i__2].r = ctemp.r, cy[i__2].i = ctemp.i;
4155
/* L30: */
4156
}
4157
return 0;
4158
} /* cswap_ */
4159
4160
/* Subroutine */ int ctrmm_(char *side, char *uplo, char *transa, char *diag,
4161
integer *m, integer *n, singlecomplex *alpha, singlecomplex *a, integer *lda,
4162
singlecomplex *b, integer *ldb)
4163
{
4164
/* System generated locals */
4165
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4, i__5,
4166
i__6;
4167
singlecomplex q__1, q__2, q__3;
4168
4169
/* Local variables */
4170
static integer i__, j, k, info;
4171
static singlecomplex temp;
4172
extern logical lsame_(char *, char *);
4173
static logical lside;
4174
static integer nrowa;
4175
static logical upper;
4176
extern /* Subroutine */ int xerbla_(char *, integer *);
4177
static logical noconj, nounit;
4178
4179
4180
/*
4181
Purpose
4182
=======
4183
4184
CTRMM performs one of the matrix-matrix operations
4185
4186
B := alpha*op( A )*B, or B := alpha*B*op( A )
4187
4188
where alpha is a scalar, B is an m by n matrix, A is a unit, or
4189
non-unit, upper or lower triangular matrix and op( A ) is one of
4190
4191
op( A ) = A or op( A ) = A' or op( A ) = conjg( A' ).
4192
4193
Arguments
4194
==========
4195
4196
SIDE - CHARACTER*1.
4197
On entry, SIDE specifies whether op( A ) multiplies B from
4198
the left or right as follows:
4199
4200
SIDE = 'L' or 'l' B := alpha*op( A )*B.
4201
4202
SIDE = 'R' or 'r' B := alpha*B*op( A ).
4203
4204
Unchanged on exit.
4205
4206
UPLO - CHARACTER*1.
4207
On entry, UPLO specifies whether the matrix A is an upper or
4208
lower triangular matrix as follows:
4209
4210
UPLO = 'U' or 'u' A is an upper triangular matrix.
4211
4212
UPLO = 'L' or 'l' A is a lower triangular matrix.
4213
4214
Unchanged on exit.
4215
4216
TRANSA - CHARACTER*1.
4217
On entry, TRANSA specifies the form of op( A ) to be used in
4218
the matrix multiplication as follows:
4219
4220
TRANSA = 'N' or 'n' op( A ) = A.
4221
4222
TRANSA = 'T' or 't' op( A ) = A'.
4223
4224
TRANSA = 'C' or 'c' op( A ) = conjg( A' ).
4225
4226
Unchanged on exit.
4227
4228
DIAG - CHARACTER*1.
4229
On entry, DIAG specifies whether or not A is unit triangular
4230
as follows:
4231
4232
DIAG = 'U' or 'u' A is assumed to be unit triangular.
4233
4234
DIAG = 'N' or 'n' A is not assumed to be unit
4235
triangular.
4236
4237
Unchanged on exit.
4238
4239
M - INTEGER.
4240
On entry, M specifies the number of rows of B. M must be at
4241
least zero.
4242
Unchanged on exit.
4243
4244
N - INTEGER.
4245
On entry, N specifies the number of columns of B. N must be
4246
at least zero.
4247
Unchanged on exit.
4248
4249
ALPHA - COMPLEX .
4250
On entry, ALPHA specifies the scalar alpha. When alpha is
4251
zero then A is not referenced and B need not be set before
4252
entry.
4253
Unchanged on exit.
4254
4255
A - COMPLEX array of DIMENSION ( LDA, k ), where k is m
4256
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
4257
Before entry with UPLO = 'U' or 'u', the leading k by k
4258
upper triangular part of the array A must contain the upper
4259
triangular matrix and the strictly lower triangular part of
4260
A is not referenced.
4261
Before entry with UPLO = 'L' or 'l', the leading k by k
4262
lower triangular part of the array A must contain the lower
4263
triangular matrix and the strictly upper triangular part of
4264
A is not referenced.
4265
Note that when DIAG = 'U' or 'u', the diagonal elements of
4266
A are not referenced either, but are assumed to be unity.
4267
Unchanged on exit.
4268
4269
LDA - INTEGER.
4270
On entry, LDA specifies the first dimension of A as declared
4271
in the calling (sub) program. When SIDE = 'L' or 'l' then
4272
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
4273
then LDA must be at least max( 1, n ).
4274
Unchanged on exit.
4275
4276
B - COMPLEX array of DIMENSION ( LDB, n ).
4277
Before entry, the leading m by n part of the array B must
4278
contain the matrix B, and on exit is overwritten by the
4279
transformed matrix.
4280
4281
LDB - INTEGER.
4282
On entry, LDB specifies the first dimension of B as declared
4283
in the calling (sub) program. LDB must be at least
4284
max( 1, m ).
4285
Unchanged on exit.
4286
4287
Further Details
4288
===============
4289
4290
Level 3 Blas routine.
4291
4292
-- Written on 8-February-1989.
4293
Jack Dongarra, Argonne National Laboratory.
4294
Iain Duff, AERE Harwell.
4295
Jeremy Du Croz, Numerical Algorithms Group Ltd.
4296
Sven Hammarling, Numerical Algorithms Group Ltd.
4297
4298
=====================================================================
4299
4300
4301
Test the input parameters.
4302
*/
4303
4304
/* Parameter adjustments */
4305
a_dim1 = *lda;
4306
a_offset = 1 + a_dim1;
4307
a -= a_offset;
4308
b_dim1 = *ldb;
4309
b_offset = 1 + b_dim1;
4310
b -= b_offset;
4311
4312
/* Function Body */
4313
lside = lsame_(side, "L");
4314
if (lside) {
4315
nrowa = *m;
4316
} else {
4317
nrowa = *n;
4318
}
4319
noconj = lsame_(transa, "T");
4320
nounit = lsame_(diag, "N");
4321
upper = lsame_(uplo, "U");
4322
4323
info = 0;
4324
if (! lside && ! lsame_(side, "R")) {
4325
info = 1;
4326
} else if (! upper && ! lsame_(uplo, "L")) {
4327
info = 2;
4328
} else if (! lsame_(transa, "N") && ! lsame_(transa,
4329
"T") && ! lsame_(transa, "C")) {
4330
info = 3;
4331
} else if (! lsame_(diag, "U") && ! lsame_(diag,
4332
"N")) {
4333
info = 4;
4334
} else if (*m < 0) {
4335
info = 5;
4336
} else if (*n < 0) {
4337
info = 6;
4338
} else if (*lda < max(1,nrowa)) {
4339
info = 9;
4340
} else if (*ldb < max(1,*m)) {
4341
info = 11;
4342
}
4343
if (info != 0) {
4344
xerbla_("CTRMM ", &info);
4345
return 0;
4346
}
4347
4348
/* Quick return if possible. */
4349
4350
if (*m == 0 || *n == 0) {
4351
return 0;
4352
}
4353
4354
/* And when alpha.eq.zero. */
4355
4356
if (alpha->r == 0.f && alpha->i == 0.f) {
4357
i__1 = *n;
4358
for (j = 1; j <= i__1; ++j) {
4359
i__2 = *m;
4360
for (i__ = 1; i__ <= i__2; ++i__) {
4361
i__3 = i__ + j * b_dim1;
4362
b[i__3].r = 0.f, b[i__3].i = 0.f;
4363
/* L10: */
4364
}
4365
/* L20: */
4366
}
4367
return 0;
4368
}
4369
4370
/* Start the operations. */
4371
4372
if (lside) {
4373
if (lsame_(transa, "N")) {
4374
4375
/* Form B := alpha*A*B. */
4376
4377
if (upper) {
4378
i__1 = *n;
4379
for (j = 1; j <= i__1; ++j) {
4380
i__2 = *m;
4381
for (k = 1; k <= i__2; ++k) {
4382
i__3 = k + j * b_dim1;
4383
if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
4384
i__3 = k + j * b_dim1;
4385
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
4386
.i, q__1.i = alpha->r * b[i__3].i +
4387
alpha->i * b[i__3].r;
4388
temp.r = q__1.r, temp.i = q__1.i;
4389
i__3 = k - 1;
4390
for (i__ = 1; i__ <= i__3; ++i__) {
4391
i__4 = i__ + j * b_dim1;
4392
i__5 = i__ + j * b_dim1;
4393
i__6 = i__ + k * a_dim1;
4394
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6]
4395
.i, q__2.i = temp.r * a[i__6].i +
4396
temp.i * a[i__6].r;
4397
q__1.r = b[i__5].r + q__2.r, q__1.i = b[i__5]
4398
.i + q__2.i;
4399
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
4400
/* L30: */
4401
}
4402
if (nounit) {
4403
i__3 = k + k * a_dim1;
4404
q__1.r = temp.r * a[i__3].r - temp.i * a[i__3]
4405
.i, q__1.i = temp.r * a[i__3].i +
4406
temp.i * a[i__3].r;
4407
temp.r = q__1.r, temp.i = q__1.i;
4408
}
4409
i__3 = k + j * b_dim1;
4410
b[i__3].r = temp.r, b[i__3].i = temp.i;
4411
}
4412
/* L40: */
4413
}
4414
/* L50: */
4415
}
4416
} else {
4417
i__1 = *n;
4418
for (j = 1; j <= i__1; ++j) {
4419
for (k = *m; k >= 1; --k) {
4420
i__2 = k + j * b_dim1;
4421
if (b[i__2].r != 0.f || b[i__2].i != 0.f) {
4422
i__2 = k + j * b_dim1;
4423
q__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2]
4424
.i, q__1.i = alpha->r * b[i__2].i +
4425
alpha->i * b[i__2].r;
4426
temp.r = q__1.r, temp.i = q__1.i;
4427
i__2 = k + j * b_dim1;
4428
b[i__2].r = temp.r, b[i__2].i = temp.i;
4429
if (nounit) {
4430
i__2 = k + j * b_dim1;
4431
i__3 = k + j * b_dim1;
4432
i__4 = k + k * a_dim1;
4433
q__1.r = b[i__3].r * a[i__4].r - b[i__3].i *
4434
a[i__4].i, q__1.i = b[i__3].r * a[
4435
i__4].i + b[i__3].i * a[i__4].r;
4436
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
4437
}
4438
i__2 = *m;
4439
for (i__ = k + 1; i__ <= i__2; ++i__) {
4440
i__3 = i__ + j * b_dim1;
4441
i__4 = i__ + j * b_dim1;
4442
i__5 = i__ + k * a_dim1;
4443
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5]
4444
.i, q__2.i = temp.r * a[i__5].i +
4445
temp.i * a[i__5].r;
4446
q__1.r = b[i__4].r + q__2.r, q__1.i = b[i__4]
4447
.i + q__2.i;
4448
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4449
/* L60: */
4450
}
4451
}
4452
/* L70: */
4453
}
4454
/* L80: */
4455
}
4456
}
4457
} else {
4458
4459
/* Form B := alpha*A'*B or B := alpha*conjg( A' )*B. */
4460
4461
if (upper) {
4462
i__1 = *n;
4463
for (j = 1; j <= i__1; ++j) {
4464
for (i__ = *m; i__ >= 1; --i__) {
4465
i__2 = i__ + j * b_dim1;
4466
temp.r = b[i__2].r, temp.i = b[i__2].i;
4467
if (noconj) {
4468
if (nounit) {
4469
i__2 = i__ + i__ * a_dim1;
4470
q__1.r = temp.r * a[i__2].r - temp.i * a[i__2]
4471
.i, q__1.i = temp.r * a[i__2].i +
4472
temp.i * a[i__2].r;
4473
temp.r = q__1.r, temp.i = q__1.i;
4474
}
4475
i__2 = i__ - 1;
4476
for (k = 1; k <= i__2; ++k) {
4477
i__3 = k + i__ * a_dim1;
4478
i__4 = k + j * b_dim1;
4479
q__2.r = a[i__3].r * b[i__4].r - a[i__3].i *
4480
b[i__4].i, q__2.i = a[i__3].r * b[
4481
i__4].i + a[i__3].i * b[i__4].r;
4482
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
4483
q__2.i;
4484
temp.r = q__1.r, temp.i = q__1.i;
4485
/* L90: */
4486
}
4487
} else {
4488
if (nounit) {
4489
r_cnjg(&q__2, &a[i__ + i__ * a_dim1]);
4490
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
4491
q__1.i = temp.r * q__2.i + temp.i *
4492
q__2.r;
4493
temp.r = q__1.r, temp.i = q__1.i;
4494
}
4495
i__2 = i__ - 1;
4496
for (k = 1; k <= i__2; ++k) {
4497
r_cnjg(&q__3, &a[k + i__ * a_dim1]);
4498
i__3 = k + j * b_dim1;
4499
q__2.r = q__3.r * b[i__3].r - q__3.i * b[i__3]
4500
.i, q__2.i = q__3.r * b[i__3].i +
4501
q__3.i * b[i__3].r;
4502
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
4503
q__2.i;
4504
temp.r = q__1.r, temp.i = q__1.i;
4505
/* L100: */
4506
}
4507
}
4508
i__2 = i__ + j * b_dim1;
4509
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
4510
q__1.i = alpha->r * temp.i + alpha->i *
4511
temp.r;
4512
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
4513
/* L110: */
4514
}
4515
/* L120: */
4516
}
4517
} else {
4518
i__1 = *n;
4519
for (j = 1; j <= i__1; ++j) {
4520
i__2 = *m;
4521
for (i__ = 1; i__ <= i__2; ++i__) {
4522
i__3 = i__ + j * b_dim1;
4523
temp.r = b[i__3].r, temp.i = b[i__3].i;
4524
if (noconj) {
4525
if (nounit) {
4526
i__3 = i__ + i__ * a_dim1;
4527
q__1.r = temp.r * a[i__3].r - temp.i * a[i__3]
4528
.i, q__1.i = temp.r * a[i__3].i +
4529
temp.i * a[i__3].r;
4530
temp.r = q__1.r, temp.i = q__1.i;
4531
}
4532
i__3 = *m;
4533
for (k = i__ + 1; k <= i__3; ++k) {
4534
i__4 = k + i__ * a_dim1;
4535
i__5 = k + j * b_dim1;
4536
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i *
4537
b[i__5].i, q__2.i = a[i__4].r * b[
4538
i__5].i + a[i__4].i * b[i__5].r;
4539
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
4540
q__2.i;
4541
temp.r = q__1.r, temp.i = q__1.i;
4542
/* L130: */
4543
}
4544
} else {
4545
if (nounit) {
4546
r_cnjg(&q__2, &a[i__ + i__ * a_dim1]);
4547
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
4548
q__1.i = temp.r * q__2.i + temp.i *
4549
q__2.r;
4550
temp.r = q__1.r, temp.i = q__1.i;
4551
}
4552
i__3 = *m;
4553
for (k = i__ + 1; k <= i__3; ++k) {
4554
r_cnjg(&q__3, &a[k + i__ * a_dim1]);
4555
i__4 = k + j * b_dim1;
4556
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4]
4557
.i, q__2.i = q__3.r * b[i__4].i +
4558
q__3.i * b[i__4].r;
4559
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
4560
q__2.i;
4561
temp.r = q__1.r, temp.i = q__1.i;
4562
/* L140: */
4563
}
4564
}
4565
i__3 = i__ + j * b_dim1;
4566
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
4567
q__1.i = alpha->r * temp.i + alpha->i *
4568
temp.r;
4569
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4570
/* L150: */
4571
}
4572
/* L160: */
4573
}
4574
}
4575
}
4576
} else {
4577
if (lsame_(transa, "N")) {
4578
4579
/* Form B := alpha*B*A. */
4580
4581
if (upper) {
4582
for (j = *n; j >= 1; --j) {
4583
temp.r = alpha->r, temp.i = alpha->i;
4584
if (nounit) {
4585
i__1 = j + j * a_dim1;
4586
q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
4587
q__1.i = temp.r * a[i__1].i + temp.i * a[i__1]
4588
.r;
4589
temp.r = q__1.r, temp.i = q__1.i;
4590
}
4591
i__1 = *m;
4592
for (i__ = 1; i__ <= i__1; ++i__) {
4593
i__2 = i__ + j * b_dim1;
4594
i__3 = i__ + j * b_dim1;
4595
q__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
4596
q__1.i = temp.r * b[i__3].i + temp.i * b[i__3]
4597
.r;
4598
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
4599
/* L170: */
4600
}
4601
i__1 = j - 1;
4602
for (k = 1; k <= i__1; ++k) {
4603
i__2 = k + j * a_dim1;
4604
if (a[i__2].r != 0.f || a[i__2].i != 0.f) {
4605
i__2 = k + j * a_dim1;
4606
q__1.r = alpha->r * a[i__2].r - alpha->i * a[i__2]
4607
.i, q__1.i = alpha->r * a[i__2].i +
4608
alpha->i * a[i__2].r;
4609
temp.r = q__1.r, temp.i = q__1.i;
4610
i__2 = *m;
4611
for (i__ = 1; i__ <= i__2; ++i__) {
4612
i__3 = i__ + j * b_dim1;
4613
i__4 = i__ + j * b_dim1;
4614
i__5 = i__ + k * b_dim1;
4615
q__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
4616
.i, q__2.i = temp.r * b[i__5].i +
4617
temp.i * b[i__5].r;
4618
q__1.r = b[i__4].r + q__2.r, q__1.i = b[i__4]
4619
.i + q__2.i;
4620
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4621
/* L180: */
4622
}
4623
}
4624
/* L190: */
4625
}
4626
/* L200: */
4627
}
4628
} else {
4629
i__1 = *n;
4630
for (j = 1; j <= i__1; ++j) {
4631
temp.r = alpha->r, temp.i = alpha->i;
4632
if (nounit) {
4633
i__2 = j + j * a_dim1;
4634
q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
4635
q__1.i = temp.r * a[i__2].i + temp.i * a[i__2]
4636
.r;
4637
temp.r = q__1.r, temp.i = q__1.i;
4638
}
4639
i__2 = *m;
4640
for (i__ = 1; i__ <= i__2; ++i__) {
4641
i__3 = i__ + j * b_dim1;
4642
i__4 = i__ + j * b_dim1;
4643
q__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
4644
q__1.i = temp.r * b[i__4].i + temp.i * b[i__4]
4645
.r;
4646
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4647
/* L210: */
4648
}
4649
i__2 = *n;
4650
for (k = j + 1; k <= i__2; ++k) {
4651
i__3 = k + j * a_dim1;
4652
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
4653
i__3 = k + j * a_dim1;
4654
q__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3]
4655
.i, q__1.i = alpha->r * a[i__3].i +
4656
alpha->i * a[i__3].r;
4657
temp.r = q__1.r, temp.i = q__1.i;
4658
i__3 = *m;
4659
for (i__ = 1; i__ <= i__3; ++i__) {
4660
i__4 = i__ + j * b_dim1;
4661
i__5 = i__ + j * b_dim1;
4662
i__6 = i__ + k * b_dim1;
4663
q__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
4664
.i, q__2.i = temp.r * b[i__6].i +
4665
temp.i * b[i__6].r;
4666
q__1.r = b[i__5].r + q__2.r, q__1.i = b[i__5]
4667
.i + q__2.i;
4668
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
4669
/* L220: */
4670
}
4671
}
4672
/* L230: */
4673
}
4674
/* L240: */
4675
}
4676
}
4677
} else {
4678
4679
/* Form B := alpha*B*A' or B := alpha*B*conjg( A' ). */
4680
4681
if (upper) {
4682
i__1 = *n;
4683
for (k = 1; k <= i__1; ++k) {
4684
i__2 = k - 1;
4685
for (j = 1; j <= i__2; ++j) {
4686
i__3 = j + k * a_dim1;
4687
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
4688
if (noconj) {
4689
i__3 = j + k * a_dim1;
4690
q__1.r = alpha->r * a[i__3].r - alpha->i * a[
4691
i__3].i, q__1.i = alpha->r * a[i__3]
4692
.i + alpha->i * a[i__3].r;
4693
temp.r = q__1.r, temp.i = q__1.i;
4694
} else {
4695
r_cnjg(&q__2, &a[j + k * a_dim1]);
4696
q__1.r = alpha->r * q__2.r - alpha->i *
4697
q__2.i, q__1.i = alpha->r * q__2.i +
4698
alpha->i * q__2.r;
4699
temp.r = q__1.r, temp.i = q__1.i;
4700
}
4701
i__3 = *m;
4702
for (i__ = 1; i__ <= i__3; ++i__) {
4703
i__4 = i__ + j * b_dim1;
4704
i__5 = i__ + j * b_dim1;
4705
i__6 = i__ + k * b_dim1;
4706
q__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
4707
.i, q__2.i = temp.r * b[i__6].i +
4708
temp.i * b[i__6].r;
4709
q__1.r = b[i__5].r + q__2.r, q__1.i = b[i__5]
4710
.i + q__2.i;
4711
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
4712
/* L250: */
4713
}
4714
}
4715
/* L260: */
4716
}
4717
temp.r = alpha->r, temp.i = alpha->i;
4718
if (nounit) {
4719
if (noconj) {
4720
i__2 = k + k * a_dim1;
4721
q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
4722
q__1.i = temp.r * a[i__2].i + temp.i * a[
4723
i__2].r;
4724
temp.r = q__1.r, temp.i = q__1.i;
4725
} else {
4726
r_cnjg(&q__2, &a[k + k * a_dim1]);
4727
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
4728
q__1.i = temp.r * q__2.i + temp.i *
4729
q__2.r;
4730
temp.r = q__1.r, temp.i = q__1.i;
4731
}
4732
}
4733
if (temp.r != 1.f || temp.i != 0.f) {
4734
i__2 = *m;
4735
for (i__ = 1; i__ <= i__2; ++i__) {
4736
i__3 = i__ + k * b_dim1;
4737
i__4 = i__ + k * b_dim1;
4738
q__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
4739
q__1.i = temp.r * b[i__4].i + temp.i * b[
4740
i__4].r;
4741
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4742
/* L270: */
4743
}
4744
}
4745
/* L280: */
4746
}
4747
} else {
4748
for (k = *n; k >= 1; --k) {
4749
i__1 = *n;
4750
for (j = k + 1; j <= i__1; ++j) {
4751
i__2 = j + k * a_dim1;
4752
if (a[i__2].r != 0.f || a[i__2].i != 0.f) {
4753
if (noconj) {
4754
i__2 = j + k * a_dim1;
4755
q__1.r = alpha->r * a[i__2].r - alpha->i * a[
4756
i__2].i, q__1.i = alpha->r * a[i__2]
4757
.i + alpha->i * a[i__2].r;
4758
temp.r = q__1.r, temp.i = q__1.i;
4759
} else {
4760
r_cnjg(&q__2, &a[j + k * a_dim1]);
4761
q__1.r = alpha->r * q__2.r - alpha->i *
4762
q__2.i, q__1.i = alpha->r * q__2.i +
4763
alpha->i * q__2.r;
4764
temp.r = q__1.r, temp.i = q__1.i;
4765
}
4766
i__2 = *m;
4767
for (i__ = 1; i__ <= i__2; ++i__) {
4768
i__3 = i__ + j * b_dim1;
4769
i__4 = i__ + j * b_dim1;
4770
i__5 = i__ + k * b_dim1;
4771
q__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
4772
.i, q__2.i = temp.r * b[i__5].i +
4773
temp.i * b[i__5].r;
4774
q__1.r = b[i__4].r + q__2.r, q__1.i = b[i__4]
4775
.i + q__2.i;
4776
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
4777
/* L290: */
4778
}
4779
}
4780
/* L300: */
4781
}
4782
temp.r = alpha->r, temp.i = alpha->i;
4783
if (nounit) {
4784
if (noconj) {
4785
i__1 = k + k * a_dim1;
4786
q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
4787
q__1.i = temp.r * a[i__1].i + temp.i * a[
4788
i__1].r;
4789
temp.r = q__1.r, temp.i = q__1.i;
4790
} else {
4791
r_cnjg(&q__2, &a[k + k * a_dim1]);
4792
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
4793
q__1.i = temp.r * q__2.i + temp.i *
4794
q__2.r;
4795
temp.r = q__1.r, temp.i = q__1.i;
4796
}
4797
}
4798
if (temp.r != 1.f || temp.i != 0.f) {
4799
i__1 = *m;
4800
for (i__ = 1; i__ <= i__1; ++i__) {
4801
i__2 = i__ + k * b_dim1;
4802
i__3 = i__ + k * b_dim1;
4803
q__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
4804
q__1.i = temp.r * b[i__3].i + temp.i * b[
4805
i__3].r;
4806
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
4807
/* L310: */
4808
}
4809
}
4810
/* L320: */
4811
}
4812
}
4813
}
4814
}
4815
4816
return 0;
4817
4818
/* End of CTRMM . */
4819
4820
} /* ctrmm_ */
4821
4822
/* Subroutine */ int ctrmv_(char *uplo, char *trans, char *diag, integer *n,
4823
singlecomplex *a, integer *lda, singlecomplex *x, integer *incx)
4824
{
4825
/* System generated locals */
4826
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
4827
singlecomplex q__1, q__2, q__3;
4828
4829
/* Local variables */
4830
static integer i__, j, ix, jx, kx, info;
4831
static singlecomplex temp;
4832
extern logical lsame_(char *, char *);
4833
extern /* Subroutine */ int xerbla_(char *, integer *);
4834
static logical noconj, nounit;
4835
4836
4837
/*
4838
Purpose
4839
=======
4840
4841
CTRMV performs one of the matrix-vector operations
4842
4843
x := A*x, or x := A'*x, or x := conjg( A' )*x,
4844
4845
where x is an n element vector and A is an n by n unit, or non-unit,
4846
upper or lower triangular matrix.
4847
4848
Arguments
4849
==========
4850
4851
UPLO - CHARACTER*1.
4852
On entry, UPLO specifies whether the matrix is an upper or
4853
lower triangular matrix as follows:
4854
4855
UPLO = 'U' or 'u' A is an upper triangular matrix.
4856
4857
UPLO = 'L' or 'l' A is a lower triangular matrix.
4858
4859
Unchanged on exit.
4860
4861
TRANS - CHARACTER*1.
4862
On entry, TRANS specifies the operation to be performed as
4863
follows:
4864
4865
TRANS = 'N' or 'n' x := A*x.
4866
4867
TRANS = 'T' or 't' x := A'*x.
4868
4869
TRANS = 'C' or 'c' x := conjg( A' )*x.
4870
4871
Unchanged on exit.
4872
4873
DIAG - CHARACTER*1.
4874
On entry, DIAG specifies whether or not A is unit
4875
triangular as follows:
4876
4877
DIAG = 'U' or 'u' A is assumed to be unit triangular.
4878
4879
DIAG = 'N' or 'n' A is not assumed to be unit
4880
triangular.
4881
4882
Unchanged on exit.
4883
4884
N - INTEGER.
4885
On entry, N specifies the order of the matrix A.
4886
N must be at least zero.
4887
Unchanged on exit.
4888
4889
A - COMPLEX array of DIMENSION ( LDA, n ).
4890
Before entry with UPLO = 'U' or 'u', the leading n by n
4891
upper triangular part of the array A must contain the upper
4892
triangular matrix and the strictly lower triangular part of
4893
A is not referenced.
4894
Before entry with UPLO = 'L' or 'l', the leading n by n
4895
lower triangular part of the array A must contain the lower
4896
triangular matrix and the strictly upper triangular part of
4897
A is not referenced.
4898
Note that when DIAG = 'U' or 'u', the diagonal elements of
4899
A are not referenced either, but are assumed to be unity.
4900
Unchanged on exit.
4901
4902
LDA - INTEGER.
4903
On entry, LDA specifies the first dimension of A as declared
4904
in the calling (sub) program. LDA must be at least
4905
max( 1, n ).
4906
Unchanged on exit.
4907
4908
X - COMPLEX array of dimension at least
4909
( 1 + ( n - 1 )*abs( INCX ) ).
4910
Before entry, the incremented array X must contain the n
4911
element vector x. On exit, X is overwritten with the
4912
tranformed vector x.
4913
4914
INCX - INTEGER.
4915
On entry, INCX specifies the increment for the elements of
4916
X. INCX must not be zero.
4917
Unchanged on exit.
4918
4919
Further Details
4920
===============
4921
4922
Level 2 Blas routine.
4923
4924
-- Written on 22-October-1986.
4925
Jack Dongarra, Argonne National Lab.
4926
Jeremy Du Croz, Nag Central Office.
4927
Sven Hammarling, Nag Central Office.
4928
Richard Hanson, Sandia National Labs.
4929
4930
=====================================================================
4931
4932
4933
Test the input parameters.
4934
*/
4935
4936
/* Parameter adjustments */
4937
a_dim1 = *lda;
4938
a_offset = 1 + a_dim1;
4939
a -= a_offset;
4940
--x;
4941
4942
/* Function Body */
4943
info = 0;
4944
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
4945
info = 1;
4946
} else if (! lsame_(trans, "N") && ! lsame_(trans,
4947
"T") && ! lsame_(trans, "C")) {
4948
info = 2;
4949
} else if (! lsame_(diag, "U") && ! lsame_(diag,
4950
"N")) {
4951
info = 3;
4952
} else if (*n < 0) {
4953
info = 4;
4954
} else if (*lda < max(1,*n)) {
4955
info = 6;
4956
} else if (*incx == 0) {
4957
info = 8;
4958
}
4959
if (info != 0) {
4960
xerbla_("CTRMV ", &info);
4961
return 0;
4962
}
4963
4964
/* Quick return if possible. */
4965
4966
if (*n == 0) {
4967
return 0;
4968
}
4969
4970
noconj = lsame_(trans, "T");
4971
nounit = lsame_(diag, "N");
4972
4973
/*
4974
Set up the start point in X if the increment is not unity. This
4975
will be ( N - 1 )*INCX too small for descending loops.
4976
*/
4977
4978
if (*incx <= 0) {
4979
kx = 1 - (*n - 1) * *incx;
4980
} else if (*incx != 1) {
4981
kx = 1;
4982
}
4983
4984
/*
4985
Start the operations. In this version the elements of A are
4986
accessed sequentially with one pass through A.
4987
*/
4988
4989
if (lsame_(trans, "N")) {
4990
4991
/* Form x := A*x. */
4992
4993
if (lsame_(uplo, "U")) {
4994
if (*incx == 1) {
4995
i__1 = *n;
4996
for (j = 1; j <= i__1; ++j) {
4997
i__2 = j;
4998
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
4999
i__2 = j;
5000
temp.r = x[i__2].r, temp.i = x[i__2].i;
5001
i__2 = j - 1;
5002
for (i__ = 1; i__ <= i__2; ++i__) {
5003
i__3 = i__;
5004
i__4 = i__;
5005
i__5 = i__ + j * a_dim1;
5006
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
5007
q__2.i = temp.r * a[i__5].i + temp.i * a[
5008
i__5].r;
5009
q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i +
5010
q__2.i;
5011
x[i__3].r = q__1.r, x[i__3].i = q__1.i;
5012
/* L10: */
5013
}
5014
if (nounit) {
5015
i__2 = j;
5016
i__3 = j;
5017
i__4 = j + j * a_dim1;
5018
q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
5019
i__4].i, q__1.i = x[i__3].r * a[i__4].i +
5020
x[i__3].i * a[i__4].r;
5021
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
5022
}
5023
}
5024
/* L20: */
5025
}
5026
} else {
5027
jx = kx;
5028
i__1 = *n;
5029
for (j = 1; j <= i__1; ++j) {
5030
i__2 = jx;
5031
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
5032
i__2 = jx;
5033
temp.r = x[i__2].r, temp.i = x[i__2].i;
5034
ix = kx;
5035
i__2 = j - 1;
5036
for (i__ = 1; i__ <= i__2; ++i__) {
5037
i__3 = ix;
5038
i__4 = ix;
5039
i__5 = i__ + j * a_dim1;
5040
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
5041
q__2.i = temp.r * a[i__5].i + temp.i * a[
5042
i__5].r;
5043
q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i +
5044
q__2.i;
5045
x[i__3].r = q__1.r, x[i__3].i = q__1.i;
5046
ix += *incx;
5047
/* L30: */
5048
}
5049
if (nounit) {
5050
i__2 = jx;
5051
i__3 = jx;
5052
i__4 = j + j * a_dim1;
5053
q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
5054
i__4].i, q__1.i = x[i__3].r * a[i__4].i +
5055
x[i__3].i * a[i__4].r;
5056
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
5057
}
5058
}
5059
jx += *incx;
5060
/* L40: */
5061
}
5062
}
5063
} else {
5064
if (*incx == 1) {
5065
for (j = *n; j >= 1; --j) {
5066
i__1 = j;
5067
if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
5068
i__1 = j;
5069
temp.r = x[i__1].r, temp.i = x[i__1].i;
5070
i__1 = j + 1;
5071
for (i__ = *n; i__ >= i__1; --i__) {
5072
i__2 = i__;
5073
i__3 = i__;
5074
i__4 = i__ + j * a_dim1;
5075
q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
5076
q__2.i = temp.r * a[i__4].i + temp.i * a[
5077
i__4].r;
5078
q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i +
5079
q__2.i;
5080
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
5081
/* L50: */
5082
}
5083
if (nounit) {
5084
i__1 = j;
5085
i__2 = j;
5086
i__3 = j + j * a_dim1;
5087
q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
5088
i__3].i, q__1.i = x[i__2].r * a[i__3].i +
5089
x[i__2].i * a[i__3].r;
5090
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
5091
}
5092
}
5093
/* L60: */
5094
}
5095
} else {
5096
kx += (*n - 1) * *incx;
5097
jx = kx;
5098
for (j = *n; j >= 1; --j) {
5099
i__1 = jx;
5100
if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
5101
i__1 = jx;
5102
temp.r = x[i__1].r, temp.i = x[i__1].i;
5103
ix = kx;
5104
i__1 = j + 1;
5105
for (i__ = *n; i__ >= i__1; --i__) {
5106
i__2 = ix;
5107
i__3 = ix;
5108
i__4 = i__ + j * a_dim1;
5109
q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
5110
q__2.i = temp.r * a[i__4].i + temp.i * a[
5111
i__4].r;
5112
q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i +
5113
q__2.i;
5114
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
5115
ix -= *incx;
5116
/* L70: */
5117
}
5118
if (nounit) {
5119
i__1 = jx;
5120
i__2 = jx;
5121
i__3 = j + j * a_dim1;
5122
q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
5123
i__3].i, q__1.i = x[i__2].r * a[i__3].i +
5124
x[i__2].i * a[i__3].r;
5125
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
5126
}
5127
}
5128
jx -= *incx;
5129
/* L80: */
5130
}
5131
}
5132
}
5133
} else {
5134
5135
/* Form x := A'*x or x := conjg( A' )*x. */
5136
5137
if (lsame_(uplo, "U")) {
5138
if (*incx == 1) {
5139
for (j = *n; j >= 1; --j) {
5140
i__1 = j;
5141
temp.r = x[i__1].r, temp.i = x[i__1].i;
5142
if (noconj) {
5143
if (nounit) {
5144
i__1 = j + j * a_dim1;
5145
q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
5146
q__1.i = temp.r * a[i__1].i + temp.i * a[
5147
i__1].r;
5148
temp.r = q__1.r, temp.i = q__1.i;
5149
}
5150
for (i__ = j - 1; i__ >= 1; --i__) {
5151
i__1 = i__ + j * a_dim1;
5152
i__2 = i__;
5153
q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
5154
i__2].i, q__2.i = a[i__1].r * x[i__2].i +
5155
a[i__1].i * x[i__2].r;
5156
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5157
q__2.i;
5158
temp.r = q__1.r, temp.i = q__1.i;
5159
/* L90: */
5160
}
5161
} else {
5162
if (nounit) {
5163
r_cnjg(&q__2, &a[j + j * a_dim1]);
5164
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
5165
q__1.i = temp.r * q__2.i + temp.i *
5166
q__2.r;
5167
temp.r = q__1.r, temp.i = q__1.i;
5168
}
5169
for (i__ = j - 1; i__ >= 1; --i__) {
5170
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
5171
i__1 = i__;
5172
q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i,
5173
q__2.i = q__3.r * x[i__1].i + q__3.i * x[
5174
i__1].r;
5175
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5176
q__2.i;
5177
temp.r = q__1.r, temp.i = q__1.i;
5178
/* L100: */
5179
}
5180
}
5181
i__1 = j;
5182
x[i__1].r = temp.r, x[i__1].i = temp.i;
5183
/* L110: */
5184
}
5185
} else {
5186
jx = kx + (*n - 1) * *incx;
5187
for (j = *n; j >= 1; --j) {
5188
i__1 = jx;
5189
temp.r = x[i__1].r, temp.i = x[i__1].i;
5190
ix = jx;
5191
if (noconj) {
5192
if (nounit) {
5193
i__1 = j + j * a_dim1;
5194
q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
5195
q__1.i = temp.r * a[i__1].i + temp.i * a[
5196
i__1].r;
5197
temp.r = q__1.r, temp.i = q__1.i;
5198
}
5199
for (i__ = j - 1; i__ >= 1; --i__) {
5200
ix -= *incx;
5201
i__1 = i__ + j * a_dim1;
5202
i__2 = ix;
5203
q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
5204
i__2].i, q__2.i = a[i__1].r * x[i__2].i +
5205
a[i__1].i * x[i__2].r;
5206
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5207
q__2.i;
5208
temp.r = q__1.r, temp.i = q__1.i;
5209
/* L120: */
5210
}
5211
} else {
5212
if (nounit) {
5213
r_cnjg(&q__2, &a[j + j * a_dim1]);
5214
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
5215
q__1.i = temp.r * q__2.i + temp.i *
5216
q__2.r;
5217
temp.r = q__1.r, temp.i = q__1.i;
5218
}
5219
for (i__ = j - 1; i__ >= 1; --i__) {
5220
ix -= *incx;
5221
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
5222
i__1 = ix;
5223
q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i,
5224
q__2.i = q__3.r * x[i__1].i + q__3.i * x[
5225
i__1].r;
5226
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5227
q__2.i;
5228
temp.r = q__1.r, temp.i = q__1.i;
5229
/* L130: */
5230
}
5231
}
5232
i__1 = jx;
5233
x[i__1].r = temp.r, x[i__1].i = temp.i;
5234
jx -= *incx;
5235
/* L140: */
5236
}
5237
}
5238
} else {
5239
if (*incx == 1) {
5240
i__1 = *n;
5241
for (j = 1; j <= i__1; ++j) {
5242
i__2 = j;
5243
temp.r = x[i__2].r, temp.i = x[i__2].i;
5244
if (noconj) {
5245
if (nounit) {
5246
i__2 = j + j * a_dim1;
5247
q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
5248
q__1.i = temp.r * a[i__2].i + temp.i * a[
5249
i__2].r;
5250
temp.r = q__1.r, temp.i = q__1.i;
5251
}
5252
i__2 = *n;
5253
for (i__ = j + 1; i__ <= i__2; ++i__) {
5254
i__3 = i__ + j * a_dim1;
5255
i__4 = i__;
5256
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
5257
i__4].i, q__2.i = a[i__3].r * x[i__4].i +
5258
a[i__3].i * x[i__4].r;
5259
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5260
q__2.i;
5261
temp.r = q__1.r, temp.i = q__1.i;
5262
/* L150: */
5263
}
5264
} else {
5265
if (nounit) {
5266
r_cnjg(&q__2, &a[j + j * a_dim1]);
5267
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
5268
q__1.i = temp.r * q__2.i + temp.i *
5269
q__2.r;
5270
temp.r = q__1.r, temp.i = q__1.i;
5271
}
5272
i__2 = *n;
5273
for (i__ = j + 1; i__ <= i__2; ++i__) {
5274
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
5275
i__3 = i__;
5276
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
5277
q__2.i = q__3.r * x[i__3].i + q__3.i * x[
5278
i__3].r;
5279
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5280
q__2.i;
5281
temp.r = q__1.r, temp.i = q__1.i;
5282
/* L160: */
5283
}
5284
}
5285
i__2 = j;
5286
x[i__2].r = temp.r, x[i__2].i = temp.i;
5287
/* L170: */
5288
}
5289
} else {
5290
jx = kx;
5291
i__1 = *n;
5292
for (j = 1; j <= i__1; ++j) {
5293
i__2 = jx;
5294
temp.r = x[i__2].r, temp.i = x[i__2].i;
5295
ix = jx;
5296
if (noconj) {
5297
if (nounit) {
5298
i__2 = j + j * a_dim1;
5299
q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
5300
q__1.i = temp.r * a[i__2].i + temp.i * a[
5301
i__2].r;
5302
temp.r = q__1.r, temp.i = q__1.i;
5303
}
5304
i__2 = *n;
5305
for (i__ = j + 1; i__ <= i__2; ++i__) {
5306
ix += *incx;
5307
i__3 = i__ + j * a_dim1;
5308
i__4 = ix;
5309
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
5310
i__4].i, q__2.i = a[i__3].r * x[i__4].i +
5311
a[i__3].i * x[i__4].r;
5312
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5313
q__2.i;
5314
temp.r = q__1.r, temp.i = q__1.i;
5315
/* L180: */
5316
}
5317
} else {
5318
if (nounit) {
5319
r_cnjg(&q__2, &a[j + j * a_dim1]);
5320
q__1.r = temp.r * q__2.r - temp.i * q__2.i,
5321
q__1.i = temp.r * q__2.i + temp.i *
5322
q__2.r;
5323
temp.r = q__1.r, temp.i = q__1.i;
5324
}
5325
i__2 = *n;
5326
for (i__ = j + 1; i__ <= i__2; ++i__) {
5327
ix += *incx;
5328
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
5329
i__3 = ix;
5330
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
5331
q__2.i = q__3.r * x[i__3].i + q__3.i * x[
5332
i__3].r;
5333
q__1.r = temp.r + q__2.r, q__1.i = temp.i +
5334
q__2.i;
5335
temp.r = q__1.r, temp.i = q__1.i;
5336
/* L190: */
5337
}
5338
}
5339
i__2 = jx;
5340
x[i__2].r = temp.r, x[i__2].i = temp.i;
5341
jx += *incx;
5342
/* L200: */
5343
}
5344
}
5345
}
5346
}
5347
5348
return 0;
5349
5350
/* End of CTRMV . */
5351
5352
} /* ctrmv_ */
5353
5354
/* Subroutine */ int ctrsm_(char *side, char *uplo, char *transa, char *diag,
5355
integer *m, integer *n, singlecomplex *alpha, singlecomplex *a, integer *lda,
5356
singlecomplex *b, integer *ldb)
5357
{
5358
/* System generated locals */
5359
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4, i__5,
5360
i__6, i__7;
5361
singlecomplex q__1, q__2, q__3;
5362
5363
/* Local variables */
5364
static integer i__, j, k, info;
5365
static singlecomplex temp;
5366
extern logical lsame_(char *, char *);
5367
static logical lside;
5368
static integer nrowa;
5369
static logical upper;
5370
extern /* Subroutine */ int xerbla_(char *, integer *);
5371
static logical noconj, nounit;
5372
5373
5374
/*
5375
Purpose
5376
=======
5377
5378
CTRSM solves one of the matrix equations
5379
5380
op( A )*X = alpha*B, or X*op( A ) = alpha*B,
5381
5382
where alpha is a scalar, X and B are m by n matrices, A is a unit, or
5383
non-unit, upper or lower triangular matrix and op( A ) is one of
5384
5385
op( A ) = A or op( A ) = A' or op( A ) = conjg( A' ).
5386
5387
The matrix X is overwritten on B.
5388
5389
Arguments
5390
==========
5391
5392
SIDE - CHARACTER*1.
5393
On entry, SIDE specifies whether op( A ) appears on the left
5394
or right of X as follows:
5395
5396
SIDE = 'L' or 'l' op( A )*X = alpha*B.
5397
5398
SIDE = 'R' or 'r' X*op( A ) = alpha*B.
5399
5400
Unchanged on exit.
5401
5402
UPLO - CHARACTER*1.
5403
On entry, UPLO specifies whether the matrix A is an upper or
5404
lower triangular matrix as follows:
5405
5406
UPLO = 'U' or 'u' A is an upper triangular matrix.
5407
5408
UPLO = 'L' or 'l' A is a lower triangular matrix.
5409
5410
Unchanged on exit.
5411
5412
TRANSA - CHARACTER*1.
5413
On entry, TRANSA specifies the form of op( A ) to be used in
5414
the matrix multiplication as follows:
5415
5416
TRANSA = 'N' or 'n' op( A ) = A.
5417
5418
TRANSA = 'T' or 't' op( A ) = A'.
5419
5420
TRANSA = 'C' or 'c' op( A ) = conjg( A' ).
5421
5422
Unchanged on exit.
5423
5424
DIAG - CHARACTER*1.
5425
On entry, DIAG specifies whether or not A is unit triangular
5426
as follows:
5427
5428
DIAG = 'U' or 'u' A is assumed to be unit triangular.
5429
5430
DIAG = 'N' or 'n' A is not assumed to be unit
5431
triangular.
5432
5433
Unchanged on exit.
5434
5435
M - INTEGER.
5436
On entry, M specifies the number of rows of B. M must be at
5437
least zero.
5438
Unchanged on exit.
5439
5440
N - INTEGER.
5441
On entry, N specifies the number of columns of B. N must be
5442
at least zero.
5443
Unchanged on exit.
5444
5445
ALPHA - COMPLEX .
5446
On entry, ALPHA specifies the scalar alpha. When alpha is
5447
zero then A is not referenced and B need not be set before
5448
entry.
5449
Unchanged on exit.
5450
5451
A - COMPLEX array of DIMENSION ( LDA, k ), where k is m
5452
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
5453
Before entry with UPLO = 'U' or 'u', the leading k by k
5454
upper triangular part of the array A must contain the upper
5455
triangular matrix and the strictly lower triangular part of
5456
A is not referenced.
5457
Before entry with UPLO = 'L' or 'l', the leading k by k
5458
lower triangular part of the array A must contain the lower
5459
triangular matrix and the strictly upper triangular part of
5460
A is not referenced.
5461
Note that when DIAG = 'U' or 'u', the diagonal elements of
5462
A are not referenced either, but are assumed to be unity.
5463
Unchanged on exit.
5464
5465
LDA - INTEGER.
5466
On entry, LDA specifies the first dimension of A as declared
5467
in the calling (sub) program. When SIDE = 'L' or 'l' then
5468
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
5469
then LDA must be at least max( 1, n ).
5470
Unchanged on exit.
5471
5472
B - COMPLEX array of DIMENSION ( LDB, n ).
5473
Before entry, the leading m by n part of the array B must
5474
contain the right-hand side matrix B, and on exit is
5475
overwritten by the solution matrix X.
5476
5477
LDB - INTEGER.
5478
On entry, LDB specifies the first dimension of B as declared
5479
in the calling (sub) program. LDB must be at least
5480
max( 1, m ).
5481
Unchanged on exit.
5482
5483
Further Details
5484
===============
5485
5486
Level 3 Blas routine.
5487
5488
-- Written on 8-February-1989.
5489
Jack Dongarra, Argonne National Laboratory.
5490
Iain Duff, AERE Harwell.
5491
Jeremy Du Croz, Numerical Algorithms Group Ltd.
5492
Sven Hammarling, Numerical Algorithms Group Ltd.
5493
5494
=====================================================================
5495
5496
5497
Test the input parameters.
5498
*/
5499
5500
/* Parameter adjustments */
5501
a_dim1 = *lda;
5502
a_offset = 1 + a_dim1;
5503
a -= a_offset;
5504
b_dim1 = *ldb;
5505
b_offset = 1 + b_dim1;
5506
b -= b_offset;
5507
5508
/* Function Body */
5509
lside = lsame_(side, "L");
5510
if (lside) {
5511
nrowa = *m;
5512
} else {
5513
nrowa = *n;
5514
}
5515
noconj = lsame_(transa, "T");
5516
nounit = lsame_(diag, "N");
5517
upper = lsame_(uplo, "U");
5518
5519
info = 0;
5520
if (! lside && ! lsame_(side, "R")) {
5521
info = 1;
5522
} else if (! upper && ! lsame_(uplo, "L")) {
5523
info = 2;
5524
} else if (! lsame_(transa, "N") && ! lsame_(transa,
5525
"T") && ! lsame_(transa, "C")) {
5526
info = 3;
5527
} else if (! lsame_(diag, "U") && ! lsame_(diag,
5528
"N")) {
5529
info = 4;
5530
} else if (*m < 0) {
5531
info = 5;
5532
} else if (*n < 0) {
5533
info = 6;
5534
} else if (*lda < max(1,nrowa)) {
5535
info = 9;
5536
} else if (*ldb < max(1,*m)) {
5537
info = 11;
5538
}
5539
if (info != 0) {
5540
xerbla_("CTRSM ", &info);
5541
return 0;
5542
}
5543
5544
/* Quick return if possible. */
5545
5546
if (*m == 0 || *n == 0) {
5547
return 0;
5548
}
5549
5550
/* And when alpha.eq.zero. */
5551
5552
if (alpha->r == 0.f && alpha->i == 0.f) {
5553
i__1 = *n;
5554
for (j = 1; j <= i__1; ++j) {
5555
i__2 = *m;
5556
for (i__ = 1; i__ <= i__2; ++i__) {
5557
i__3 = i__ + j * b_dim1;
5558
b[i__3].r = 0.f, b[i__3].i = 0.f;
5559
/* L10: */
5560
}
5561
/* L20: */
5562
}
5563
return 0;
5564
}
5565
5566
/* Start the operations. */
5567
5568
if (lside) {
5569
if (lsame_(transa, "N")) {
5570
5571
/* Form B := alpha*inv( A )*B. */
5572
5573
if (upper) {
5574
i__1 = *n;
5575
for (j = 1; j <= i__1; ++j) {
5576
if (alpha->r != 1.f || alpha->i != 0.f) {
5577
i__2 = *m;
5578
for (i__ = 1; i__ <= i__2; ++i__) {
5579
i__3 = i__ + j * b_dim1;
5580
i__4 = i__ + j * b_dim1;
5581
q__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
5582
.i, q__1.i = alpha->r * b[i__4].i +
5583
alpha->i * b[i__4].r;
5584
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5585
/* L30: */
5586
}
5587
}
5588
for (k = *m; k >= 1; --k) {
5589
i__2 = k + j * b_dim1;
5590
if (b[i__2].r != 0.f || b[i__2].i != 0.f) {
5591
if (nounit) {
5592
i__2 = k + j * b_dim1;
5593
c_div(&q__1, &b[k + j * b_dim1], &a[k + k *
5594
a_dim1]);
5595
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
5596
}
5597
i__2 = k - 1;
5598
for (i__ = 1; i__ <= i__2; ++i__) {
5599
i__3 = i__ + j * b_dim1;
5600
i__4 = i__ + j * b_dim1;
5601
i__5 = k + j * b_dim1;
5602
i__6 = i__ + k * a_dim1;
5603
q__2.r = b[i__5].r * a[i__6].r - b[i__5].i *
5604
a[i__6].i, q__2.i = b[i__5].r * a[
5605
i__6].i + b[i__5].i * a[i__6].r;
5606
q__1.r = b[i__4].r - q__2.r, q__1.i = b[i__4]
5607
.i - q__2.i;
5608
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5609
/* L40: */
5610
}
5611
}
5612
/* L50: */
5613
}
5614
/* L60: */
5615
}
5616
} else {
5617
i__1 = *n;
5618
for (j = 1; j <= i__1; ++j) {
5619
if (alpha->r != 1.f || alpha->i != 0.f) {
5620
i__2 = *m;
5621
for (i__ = 1; i__ <= i__2; ++i__) {
5622
i__3 = i__ + j * b_dim1;
5623
i__4 = i__ + j * b_dim1;
5624
q__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
5625
.i, q__1.i = alpha->r * b[i__4].i +
5626
alpha->i * b[i__4].r;
5627
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5628
/* L70: */
5629
}
5630
}
5631
i__2 = *m;
5632
for (k = 1; k <= i__2; ++k) {
5633
i__3 = k + j * b_dim1;
5634
if (b[i__3].r != 0.f || b[i__3].i != 0.f) {
5635
if (nounit) {
5636
i__3 = k + j * b_dim1;
5637
c_div(&q__1, &b[k + j * b_dim1], &a[k + k *
5638
a_dim1]);
5639
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5640
}
5641
i__3 = *m;
5642
for (i__ = k + 1; i__ <= i__3; ++i__) {
5643
i__4 = i__ + j * b_dim1;
5644
i__5 = i__ + j * b_dim1;
5645
i__6 = k + j * b_dim1;
5646
i__7 = i__ + k * a_dim1;
5647
q__2.r = b[i__6].r * a[i__7].r - b[i__6].i *
5648
a[i__7].i, q__2.i = b[i__6].r * a[
5649
i__7].i + b[i__6].i * a[i__7].r;
5650
q__1.r = b[i__5].r - q__2.r, q__1.i = b[i__5]
5651
.i - q__2.i;
5652
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
5653
/* L80: */
5654
}
5655
}
5656
/* L90: */
5657
}
5658
/* L100: */
5659
}
5660
}
5661
} else {
5662
5663
/*
5664
Form B := alpha*inv( A' )*B
5665
or B := alpha*inv( conjg( A' ) )*B.
5666
*/
5667
5668
if (upper) {
5669
i__1 = *n;
5670
for (j = 1; j <= i__1; ++j) {
5671
i__2 = *m;
5672
for (i__ = 1; i__ <= i__2; ++i__) {
5673
i__3 = i__ + j * b_dim1;
5674
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
5675
q__1.i = alpha->r * b[i__3].i + alpha->i * b[
5676
i__3].r;
5677
temp.r = q__1.r, temp.i = q__1.i;
5678
if (noconj) {
5679
i__3 = i__ - 1;
5680
for (k = 1; k <= i__3; ++k) {
5681
i__4 = k + i__ * a_dim1;
5682
i__5 = k + j * b_dim1;
5683
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i *
5684
b[i__5].i, q__2.i = a[i__4].r * b[
5685
i__5].i + a[i__4].i * b[i__5].r;
5686
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
5687
q__2.i;
5688
temp.r = q__1.r, temp.i = q__1.i;
5689
/* L110: */
5690
}
5691
if (nounit) {
5692
c_div(&q__1, &temp, &a[i__ + i__ * a_dim1]);
5693
temp.r = q__1.r, temp.i = q__1.i;
5694
}
5695
} else {
5696
i__3 = i__ - 1;
5697
for (k = 1; k <= i__3; ++k) {
5698
r_cnjg(&q__3, &a[k + i__ * a_dim1]);
5699
i__4 = k + j * b_dim1;
5700
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4]
5701
.i, q__2.i = q__3.r * b[i__4].i +
5702
q__3.i * b[i__4].r;
5703
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
5704
q__2.i;
5705
temp.r = q__1.r, temp.i = q__1.i;
5706
/* L120: */
5707
}
5708
if (nounit) {
5709
r_cnjg(&q__2, &a[i__ + i__ * a_dim1]);
5710
c_div(&q__1, &temp, &q__2);
5711
temp.r = q__1.r, temp.i = q__1.i;
5712
}
5713
}
5714
i__3 = i__ + j * b_dim1;
5715
b[i__3].r = temp.r, b[i__3].i = temp.i;
5716
/* L130: */
5717
}
5718
/* L140: */
5719
}
5720
} else {
5721
i__1 = *n;
5722
for (j = 1; j <= i__1; ++j) {
5723
for (i__ = *m; i__ >= 1; --i__) {
5724
i__2 = i__ + j * b_dim1;
5725
q__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2].i,
5726
q__1.i = alpha->r * b[i__2].i + alpha->i * b[
5727
i__2].r;
5728
temp.r = q__1.r, temp.i = q__1.i;
5729
if (noconj) {
5730
i__2 = *m;
5731
for (k = i__ + 1; k <= i__2; ++k) {
5732
i__3 = k + i__ * a_dim1;
5733
i__4 = k + j * b_dim1;
5734
q__2.r = a[i__3].r * b[i__4].r - a[i__3].i *
5735
b[i__4].i, q__2.i = a[i__3].r * b[
5736
i__4].i + a[i__3].i * b[i__4].r;
5737
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
5738
q__2.i;
5739
temp.r = q__1.r, temp.i = q__1.i;
5740
/* L150: */
5741
}
5742
if (nounit) {
5743
c_div(&q__1, &temp, &a[i__ + i__ * a_dim1]);
5744
temp.r = q__1.r, temp.i = q__1.i;
5745
}
5746
} else {
5747
i__2 = *m;
5748
for (k = i__ + 1; k <= i__2; ++k) {
5749
r_cnjg(&q__3, &a[k + i__ * a_dim1]);
5750
i__3 = k + j * b_dim1;
5751
q__2.r = q__3.r * b[i__3].r - q__3.i * b[i__3]
5752
.i, q__2.i = q__3.r * b[i__3].i +
5753
q__3.i * b[i__3].r;
5754
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
5755
q__2.i;
5756
temp.r = q__1.r, temp.i = q__1.i;
5757
/* L160: */
5758
}
5759
if (nounit) {
5760
r_cnjg(&q__2, &a[i__ + i__ * a_dim1]);
5761
c_div(&q__1, &temp, &q__2);
5762
temp.r = q__1.r, temp.i = q__1.i;
5763
}
5764
}
5765
i__2 = i__ + j * b_dim1;
5766
b[i__2].r = temp.r, b[i__2].i = temp.i;
5767
/* L170: */
5768
}
5769
/* L180: */
5770
}
5771
}
5772
}
5773
} else {
5774
if (lsame_(transa, "N")) {
5775
5776
/* Form B := alpha*B*inv( A ). */
5777
5778
if (upper) {
5779
i__1 = *n;
5780
for (j = 1; j <= i__1; ++j) {
5781
if (alpha->r != 1.f || alpha->i != 0.f) {
5782
i__2 = *m;
5783
for (i__ = 1; i__ <= i__2; ++i__) {
5784
i__3 = i__ + j * b_dim1;
5785
i__4 = i__ + j * b_dim1;
5786
q__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
5787
.i, q__1.i = alpha->r * b[i__4].i +
5788
alpha->i * b[i__4].r;
5789
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5790
/* L190: */
5791
}
5792
}
5793
i__2 = j - 1;
5794
for (k = 1; k <= i__2; ++k) {
5795
i__3 = k + j * a_dim1;
5796
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
5797
i__3 = *m;
5798
for (i__ = 1; i__ <= i__3; ++i__) {
5799
i__4 = i__ + j * b_dim1;
5800
i__5 = i__ + j * b_dim1;
5801
i__6 = k + j * a_dim1;
5802
i__7 = i__ + k * b_dim1;
5803
q__2.r = a[i__6].r * b[i__7].r - a[i__6].i *
5804
b[i__7].i, q__2.i = a[i__6].r * b[
5805
i__7].i + a[i__6].i * b[i__7].r;
5806
q__1.r = b[i__5].r - q__2.r, q__1.i = b[i__5]
5807
.i - q__2.i;
5808
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
5809
/* L200: */
5810
}
5811
}
5812
/* L210: */
5813
}
5814
if (nounit) {
5815
c_div(&q__1, &c_b21, &a[j + j * a_dim1]);
5816
temp.r = q__1.r, temp.i = q__1.i;
5817
i__2 = *m;
5818
for (i__ = 1; i__ <= i__2; ++i__) {
5819
i__3 = i__ + j * b_dim1;
5820
i__4 = i__ + j * b_dim1;
5821
q__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
5822
q__1.i = temp.r * b[i__4].i + temp.i * b[
5823
i__4].r;
5824
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5825
/* L220: */
5826
}
5827
}
5828
/* L230: */
5829
}
5830
} else {
5831
for (j = *n; j >= 1; --j) {
5832
if (alpha->r != 1.f || alpha->i != 0.f) {
5833
i__1 = *m;
5834
for (i__ = 1; i__ <= i__1; ++i__) {
5835
i__2 = i__ + j * b_dim1;
5836
i__3 = i__ + j * b_dim1;
5837
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
5838
.i, q__1.i = alpha->r * b[i__3].i +
5839
alpha->i * b[i__3].r;
5840
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
5841
/* L240: */
5842
}
5843
}
5844
i__1 = *n;
5845
for (k = j + 1; k <= i__1; ++k) {
5846
i__2 = k + j * a_dim1;
5847
if (a[i__2].r != 0.f || a[i__2].i != 0.f) {
5848
i__2 = *m;
5849
for (i__ = 1; i__ <= i__2; ++i__) {
5850
i__3 = i__ + j * b_dim1;
5851
i__4 = i__ + j * b_dim1;
5852
i__5 = k + j * a_dim1;
5853
i__6 = i__ + k * b_dim1;
5854
q__2.r = a[i__5].r * b[i__6].r - a[i__5].i *
5855
b[i__6].i, q__2.i = a[i__5].r * b[
5856
i__6].i + a[i__5].i * b[i__6].r;
5857
q__1.r = b[i__4].r - q__2.r, q__1.i = b[i__4]
5858
.i - q__2.i;
5859
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5860
/* L250: */
5861
}
5862
}
5863
/* L260: */
5864
}
5865
if (nounit) {
5866
c_div(&q__1, &c_b21, &a[j + j * a_dim1]);
5867
temp.r = q__1.r, temp.i = q__1.i;
5868
i__1 = *m;
5869
for (i__ = 1; i__ <= i__1; ++i__) {
5870
i__2 = i__ + j * b_dim1;
5871
i__3 = i__ + j * b_dim1;
5872
q__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
5873
q__1.i = temp.r * b[i__3].i + temp.i * b[
5874
i__3].r;
5875
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
5876
/* L270: */
5877
}
5878
}
5879
/* L280: */
5880
}
5881
}
5882
} else {
5883
5884
/*
5885
Form B := alpha*B*inv( A' )
5886
or B := alpha*B*inv( conjg( A' ) ).
5887
*/
5888
5889
if (upper) {
5890
for (k = *n; k >= 1; --k) {
5891
if (nounit) {
5892
if (noconj) {
5893
c_div(&q__1, &c_b21, &a[k + k * a_dim1]);
5894
temp.r = q__1.r, temp.i = q__1.i;
5895
} else {
5896
r_cnjg(&q__2, &a[k + k * a_dim1]);
5897
c_div(&q__1, &c_b21, &q__2);
5898
temp.r = q__1.r, temp.i = q__1.i;
5899
}
5900
i__1 = *m;
5901
for (i__ = 1; i__ <= i__1; ++i__) {
5902
i__2 = i__ + k * b_dim1;
5903
i__3 = i__ + k * b_dim1;
5904
q__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
5905
q__1.i = temp.r * b[i__3].i + temp.i * b[
5906
i__3].r;
5907
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
5908
/* L290: */
5909
}
5910
}
5911
i__1 = k - 1;
5912
for (j = 1; j <= i__1; ++j) {
5913
i__2 = j + k * a_dim1;
5914
if (a[i__2].r != 0.f || a[i__2].i != 0.f) {
5915
if (noconj) {
5916
i__2 = j + k * a_dim1;
5917
temp.r = a[i__2].r, temp.i = a[i__2].i;
5918
} else {
5919
r_cnjg(&q__1, &a[j + k * a_dim1]);
5920
temp.r = q__1.r, temp.i = q__1.i;
5921
}
5922
i__2 = *m;
5923
for (i__ = 1; i__ <= i__2; ++i__) {
5924
i__3 = i__ + j * b_dim1;
5925
i__4 = i__ + j * b_dim1;
5926
i__5 = i__ + k * b_dim1;
5927
q__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
5928
.i, q__2.i = temp.r * b[i__5].i +
5929
temp.i * b[i__5].r;
5930
q__1.r = b[i__4].r - q__2.r, q__1.i = b[i__4]
5931
.i - q__2.i;
5932
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5933
/* L300: */
5934
}
5935
}
5936
/* L310: */
5937
}
5938
if (alpha->r != 1.f || alpha->i != 0.f) {
5939
i__1 = *m;
5940
for (i__ = 1; i__ <= i__1; ++i__) {
5941
i__2 = i__ + k * b_dim1;
5942
i__3 = i__ + k * b_dim1;
5943
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
5944
.i, q__1.i = alpha->r * b[i__3].i +
5945
alpha->i * b[i__3].r;
5946
b[i__2].r = q__1.r, b[i__2].i = q__1.i;
5947
/* L320: */
5948
}
5949
}
5950
/* L330: */
5951
}
5952
} else {
5953
i__1 = *n;
5954
for (k = 1; k <= i__1; ++k) {
5955
if (nounit) {
5956
if (noconj) {
5957
c_div(&q__1, &c_b21, &a[k + k * a_dim1]);
5958
temp.r = q__1.r, temp.i = q__1.i;
5959
} else {
5960
r_cnjg(&q__2, &a[k + k * a_dim1]);
5961
c_div(&q__1, &c_b21, &q__2);
5962
temp.r = q__1.r, temp.i = q__1.i;
5963
}
5964
i__2 = *m;
5965
for (i__ = 1; i__ <= i__2; ++i__) {
5966
i__3 = i__ + k * b_dim1;
5967
i__4 = i__ + k * b_dim1;
5968
q__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
5969
q__1.i = temp.r * b[i__4].i + temp.i * b[
5970
i__4].r;
5971
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
5972
/* L340: */
5973
}
5974
}
5975
i__2 = *n;
5976
for (j = k + 1; j <= i__2; ++j) {
5977
i__3 = j + k * a_dim1;
5978
if (a[i__3].r != 0.f || a[i__3].i != 0.f) {
5979
if (noconj) {
5980
i__3 = j + k * a_dim1;
5981
temp.r = a[i__3].r, temp.i = a[i__3].i;
5982
} else {
5983
r_cnjg(&q__1, &a[j + k * a_dim1]);
5984
temp.r = q__1.r, temp.i = q__1.i;
5985
}
5986
i__3 = *m;
5987
for (i__ = 1; i__ <= i__3; ++i__) {
5988
i__4 = i__ + j * b_dim1;
5989
i__5 = i__ + j * b_dim1;
5990
i__6 = i__ + k * b_dim1;
5991
q__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
5992
.i, q__2.i = temp.r * b[i__6].i +
5993
temp.i * b[i__6].r;
5994
q__1.r = b[i__5].r - q__2.r, q__1.i = b[i__5]
5995
.i - q__2.i;
5996
b[i__4].r = q__1.r, b[i__4].i = q__1.i;
5997
/* L350: */
5998
}
5999
}
6000
/* L360: */
6001
}
6002
if (alpha->r != 1.f || alpha->i != 0.f) {
6003
i__2 = *m;
6004
for (i__ = 1; i__ <= i__2; ++i__) {
6005
i__3 = i__ + k * b_dim1;
6006
i__4 = i__ + k * b_dim1;
6007
q__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
6008
.i, q__1.i = alpha->r * b[i__4].i +
6009
alpha->i * b[i__4].r;
6010
b[i__3].r = q__1.r, b[i__3].i = q__1.i;
6011
/* L370: */
6012
}
6013
}
6014
/* L380: */
6015
}
6016
}
6017
}
6018
}
6019
6020
return 0;
6021
6022
/* End of CTRSM . */
6023
6024
} /* ctrsm_ */
6025
6026
/* Subroutine */ int ctrsv_(char *uplo, char *trans, char *diag, integer *n,
6027
singlecomplex *a, integer *lda, singlecomplex *x, integer *incx)
6028
{
6029
/* System generated locals */
6030
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
6031
singlecomplex q__1, q__2, q__3;
6032
6033
/* Local variables */
6034
static integer i__, j, ix, jx, kx, info;
6035
static singlecomplex temp;
6036
extern logical lsame_(char *, char *);
6037
extern /* Subroutine */ int xerbla_(char *, integer *);
6038
static logical noconj, nounit;
6039
6040
6041
/*
6042
Purpose
6043
=======
6044
6045
CTRSV solves one of the systems of equations
6046
6047
A*x = b, or A'*x = b, or conjg( A' )*x = b,
6048
6049
where b and x are n element vectors and A is an n by n unit, or
6050
non-unit, upper or lower triangular matrix.
6051
6052
No test for singularity or near-singularity is included in this
6053
routine. Such tests must be performed before calling this routine.
6054
6055
Arguments
6056
==========
6057
6058
UPLO - CHARACTER*1.
6059
On entry, UPLO specifies whether the matrix is an upper or
6060
lower triangular matrix as follows:
6061
6062
UPLO = 'U' or 'u' A is an upper triangular matrix.
6063
6064
UPLO = 'L' or 'l' A is a lower triangular matrix.
6065
6066
Unchanged on exit.
6067
6068
TRANS - CHARACTER*1.
6069
On entry, TRANS specifies the equations to be solved as
6070
follows:
6071
6072
TRANS = 'N' or 'n' A*x = b.
6073
6074
TRANS = 'T' or 't' A'*x = b.
6075
6076
TRANS = 'C' or 'c' conjg( A' )*x = b.
6077
6078
Unchanged on exit.
6079
6080
DIAG - CHARACTER*1.
6081
On entry, DIAG specifies whether or not A is unit
6082
triangular as follows:
6083
6084
DIAG = 'U' or 'u' A is assumed to be unit triangular.
6085
6086
DIAG = 'N' or 'n' A is not assumed to be unit
6087
triangular.
6088
6089
Unchanged on exit.
6090
6091
N - INTEGER.
6092
On entry, N specifies the order of the matrix A.
6093
N must be at least zero.
6094
Unchanged on exit.
6095
6096
A - COMPLEX array of DIMENSION ( LDA, n ).
6097
Before entry with UPLO = 'U' or 'u', the leading n by n
6098
upper triangular part of the array A must contain the upper
6099
triangular matrix and the strictly lower triangular part of
6100
A is not referenced.
6101
Before entry with UPLO = 'L' or 'l', the leading n by n
6102
lower triangular part of the array A must contain the lower
6103
triangular matrix and the strictly upper triangular part of
6104
A is not referenced.
6105
Note that when DIAG = 'U' or 'u', the diagonal elements of
6106
A are not referenced either, but are assumed to be unity.
6107
Unchanged on exit.
6108
6109
LDA - INTEGER.
6110
On entry, LDA specifies the first dimension of A as declared
6111
in the calling (sub) program. LDA must be at least
6112
max( 1, n ).
6113
Unchanged on exit.
6114
6115
X - COMPLEX array of dimension at least
6116
( 1 + ( n - 1 )*abs( INCX ) ).
6117
Before entry, the incremented array X must contain the n
6118
element right-hand side vector b. On exit, X is overwritten
6119
with the solution vector x.
6120
6121
INCX - INTEGER.
6122
On entry, INCX specifies the increment for the elements of
6123
X. INCX must not be zero.
6124
Unchanged on exit.
6125
6126
Further Details
6127
===============
6128
6129
Level 2 Blas routine.
6130
6131
-- Written on 22-October-1986.
6132
Jack Dongarra, Argonne National Lab.
6133
Jeremy Du Croz, Nag Central Office.
6134
Sven Hammarling, Nag Central Office.
6135
Richard Hanson, Sandia National Labs.
6136
6137
=====================================================================
6138
6139
6140
Test the input parameters.
6141
*/
6142
6143
/* Parameter adjustments */
6144
a_dim1 = *lda;
6145
a_offset = 1 + a_dim1;
6146
a -= a_offset;
6147
--x;
6148
6149
/* Function Body */
6150
info = 0;
6151
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
6152
info = 1;
6153
} else if (! lsame_(trans, "N") && ! lsame_(trans,
6154
"T") && ! lsame_(trans, "C")) {
6155
info = 2;
6156
} else if (! lsame_(diag, "U") && ! lsame_(diag,
6157
"N")) {
6158
info = 3;
6159
} else if (*n < 0) {
6160
info = 4;
6161
} else if (*lda < max(1,*n)) {
6162
info = 6;
6163
} else if (*incx == 0) {
6164
info = 8;
6165
}
6166
if (info != 0) {
6167
xerbla_("CTRSV ", &info);
6168
return 0;
6169
}
6170
6171
/* Quick return if possible. */
6172
6173
if (*n == 0) {
6174
return 0;
6175
}
6176
6177
noconj = lsame_(trans, "T");
6178
nounit = lsame_(diag, "N");
6179
6180
/*
6181
Set up the start point in X if the increment is not unity. This
6182
will be ( N - 1 )*INCX too small for descending loops.
6183
*/
6184
6185
if (*incx <= 0) {
6186
kx = 1 - (*n - 1) * *incx;
6187
} else if (*incx != 1) {
6188
kx = 1;
6189
}
6190
6191
/*
6192
Start the operations. In this version the elements of A are
6193
accessed sequentially with one pass through A.
6194
*/
6195
6196
if (lsame_(trans, "N")) {
6197
6198
/* Form x := inv( A )*x. */
6199
6200
if (lsame_(uplo, "U")) {
6201
if (*incx == 1) {
6202
for (j = *n; j >= 1; --j) {
6203
i__1 = j;
6204
if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
6205
if (nounit) {
6206
i__1 = j;
6207
c_div(&q__1, &x[j], &a[j + j * a_dim1]);
6208
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
6209
}
6210
i__1 = j;
6211
temp.r = x[i__1].r, temp.i = x[i__1].i;
6212
for (i__ = j - 1; i__ >= 1; --i__) {
6213
i__1 = i__;
6214
i__2 = i__;
6215
i__3 = i__ + j * a_dim1;
6216
q__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
6217
q__2.i = temp.r * a[i__3].i + temp.i * a[
6218
i__3].r;
6219
q__1.r = x[i__2].r - q__2.r, q__1.i = x[i__2].i -
6220
q__2.i;
6221
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
6222
/* L10: */
6223
}
6224
}
6225
/* L20: */
6226
}
6227
} else {
6228
jx = kx + (*n - 1) * *incx;
6229
for (j = *n; j >= 1; --j) {
6230
i__1 = jx;
6231
if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
6232
if (nounit) {
6233
i__1 = jx;
6234
c_div(&q__1, &x[jx], &a[j + j * a_dim1]);
6235
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
6236
}
6237
i__1 = jx;
6238
temp.r = x[i__1].r, temp.i = x[i__1].i;
6239
ix = jx;
6240
for (i__ = j - 1; i__ >= 1; --i__) {
6241
ix -= *incx;
6242
i__1 = ix;
6243
i__2 = ix;
6244
i__3 = i__ + j * a_dim1;
6245
q__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
6246
q__2.i = temp.r * a[i__3].i + temp.i * a[
6247
i__3].r;
6248
q__1.r = x[i__2].r - q__2.r, q__1.i = x[i__2].i -
6249
q__2.i;
6250
x[i__1].r = q__1.r, x[i__1].i = q__1.i;
6251
/* L30: */
6252
}
6253
}
6254
jx -= *incx;
6255
/* L40: */
6256
}
6257
}
6258
} else {
6259
if (*incx == 1) {
6260
i__1 = *n;
6261
for (j = 1; j <= i__1; ++j) {
6262
i__2 = j;
6263
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
6264
if (nounit) {
6265
i__2 = j;
6266
c_div(&q__1, &x[j], &a[j + j * a_dim1]);
6267
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
6268
}
6269
i__2 = j;
6270
temp.r = x[i__2].r, temp.i = x[i__2].i;
6271
i__2 = *n;
6272
for (i__ = j + 1; i__ <= i__2; ++i__) {
6273
i__3 = i__;
6274
i__4 = i__;
6275
i__5 = i__ + j * a_dim1;
6276
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
6277
q__2.i = temp.r * a[i__5].i + temp.i * a[
6278
i__5].r;
6279
q__1.r = x[i__4].r - q__2.r, q__1.i = x[i__4].i -
6280
q__2.i;
6281
x[i__3].r = q__1.r, x[i__3].i = q__1.i;
6282
/* L50: */
6283
}
6284
}
6285
/* L60: */
6286
}
6287
} else {
6288
jx = kx;
6289
i__1 = *n;
6290
for (j = 1; j <= i__1; ++j) {
6291
i__2 = jx;
6292
if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
6293
if (nounit) {
6294
i__2 = jx;
6295
c_div(&q__1, &x[jx], &a[j + j * a_dim1]);
6296
x[i__2].r = q__1.r, x[i__2].i = q__1.i;
6297
}
6298
i__2 = jx;
6299
temp.r = x[i__2].r, temp.i = x[i__2].i;
6300
ix = jx;
6301
i__2 = *n;
6302
for (i__ = j + 1; i__ <= i__2; ++i__) {
6303
ix += *incx;
6304
i__3 = ix;
6305
i__4 = ix;
6306
i__5 = i__ + j * a_dim1;
6307
q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
6308
q__2.i = temp.r * a[i__5].i + temp.i * a[
6309
i__5].r;
6310
q__1.r = x[i__4].r - q__2.r, q__1.i = x[i__4].i -
6311
q__2.i;
6312
x[i__3].r = q__1.r, x[i__3].i = q__1.i;
6313
/* L70: */
6314
}
6315
}
6316
jx += *incx;
6317
/* L80: */
6318
}
6319
}
6320
}
6321
} else {
6322
6323
/* Form x := inv( A' )*x or x := inv( conjg( A' ) )*x. */
6324
6325
if (lsame_(uplo, "U")) {
6326
if (*incx == 1) {
6327
i__1 = *n;
6328
for (j = 1; j <= i__1; ++j) {
6329
i__2 = j;
6330
temp.r = x[i__2].r, temp.i = x[i__2].i;
6331
if (noconj) {
6332
i__2 = j - 1;
6333
for (i__ = 1; i__ <= i__2; ++i__) {
6334
i__3 = i__ + j * a_dim1;
6335
i__4 = i__;
6336
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
6337
i__4].i, q__2.i = a[i__3].r * x[i__4].i +
6338
a[i__3].i * x[i__4].r;
6339
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6340
q__2.i;
6341
temp.r = q__1.r, temp.i = q__1.i;
6342
/* L90: */
6343
}
6344
if (nounit) {
6345
c_div(&q__1, &temp, &a[j + j * a_dim1]);
6346
temp.r = q__1.r, temp.i = q__1.i;
6347
}
6348
} else {
6349
i__2 = j - 1;
6350
for (i__ = 1; i__ <= i__2; ++i__) {
6351
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
6352
i__3 = i__;
6353
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
6354
q__2.i = q__3.r * x[i__3].i + q__3.i * x[
6355
i__3].r;
6356
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6357
q__2.i;
6358
temp.r = q__1.r, temp.i = q__1.i;
6359
/* L100: */
6360
}
6361
if (nounit) {
6362
r_cnjg(&q__2, &a[j + j * a_dim1]);
6363
c_div(&q__1, &temp, &q__2);
6364
temp.r = q__1.r, temp.i = q__1.i;
6365
}
6366
}
6367
i__2 = j;
6368
x[i__2].r = temp.r, x[i__2].i = temp.i;
6369
/* L110: */
6370
}
6371
} else {
6372
jx = kx;
6373
i__1 = *n;
6374
for (j = 1; j <= i__1; ++j) {
6375
ix = kx;
6376
i__2 = jx;
6377
temp.r = x[i__2].r, temp.i = x[i__2].i;
6378
if (noconj) {
6379
i__2 = j - 1;
6380
for (i__ = 1; i__ <= i__2; ++i__) {
6381
i__3 = i__ + j * a_dim1;
6382
i__4 = ix;
6383
q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
6384
i__4].i, q__2.i = a[i__3].r * x[i__4].i +
6385
a[i__3].i * x[i__4].r;
6386
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6387
q__2.i;
6388
temp.r = q__1.r, temp.i = q__1.i;
6389
ix += *incx;
6390
/* L120: */
6391
}
6392
if (nounit) {
6393
c_div(&q__1, &temp, &a[j + j * a_dim1]);
6394
temp.r = q__1.r, temp.i = q__1.i;
6395
}
6396
} else {
6397
i__2 = j - 1;
6398
for (i__ = 1; i__ <= i__2; ++i__) {
6399
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
6400
i__3 = ix;
6401
q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
6402
q__2.i = q__3.r * x[i__3].i + q__3.i * x[
6403
i__3].r;
6404
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6405
q__2.i;
6406
temp.r = q__1.r, temp.i = q__1.i;
6407
ix += *incx;
6408
/* L130: */
6409
}
6410
if (nounit) {
6411
r_cnjg(&q__2, &a[j + j * a_dim1]);
6412
c_div(&q__1, &temp, &q__2);
6413
temp.r = q__1.r, temp.i = q__1.i;
6414
}
6415
}
6416
i__2 = jx;
6417
x[i__2].r = temp.r, x[i__2].i = temp.i;
6418
jx += *incx;
6419
/* L140: */
6420
}
6421
}
6422
} else {
6423
if (*incx == 1) {
6424
for (j = *n; j >= 1; --j) {
6425
i__1 = j;
6426
temp.r = x[i__1].r, temp.i = x[i__1].i;
6427
if (noconj) {
6428
i__1 = j + 1;
6429
for (i__ = *n; i__ >= i__1; --i__) {
6430
i__2 = i__ + j * a_dim1;
6431
i__3 = i__;
6432
q__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
6433
i__3].i, q__2.i = a[i__2].r * x[i__3].i +
6434
a[i__2].i * x[i__3].r;
6435
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6436
q__2.i;
6437
temp.r = q__1.r, temp.i = q__1.i;
6438
/* L150: */
6439
}
6440
if (nounit) {
6441
c_div(&q__1, &temp, &a[j + j * a_dim1]);
6442
temp.r = q__1.r, temp.i = q__1.i;
6443
}
6444
} else {
6445
i__1 = j + 1;
6446
for (i__ = *n; i__ >= i__1; --i__) {
6447
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
6448
i__2 = i__;
6449
q__2.r = q__3.r * x[i__2].r - q__3.i * x[i__2].i,
6450
q__2.i = q__3.r * x[i__2].i + q__3.i * x[
6451
i__2].r;
6452
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6453
q__2.i;
6454
temp.r = q__1.r, temp.i = q__1.i;
6455
/* L160: */
6456
}
6457
if (nounit) {
6458
r_cnjg(&q__2, &a[j + j * a_dim1]);
6459
c_div(&q__1, &temp, &q__2);
6460
temp.r = q__1.r, temp.i = q__1.i;
6461
}
6462
}
6463
i__1 = j;
6464
x[i__1].r = temp.r, x[i__1].i = temp.i;
6465
/* L170: */
6466
}
6467
} else {
6468
kx += (*n - 1) * *incx;
6469
jx = kx;
6470
for (j = *n; j >= 1; --j) {
6471
ix = kx;
6472
i__1 = jx;
6473
temp.r = x[i__1].r, temp.i = x[i__1].i;
6474
if (noconj) {
6475
i__1 = j + 1;
6476
for (i__ = *n; i__ >= i__1; --i__) {
6477
i__2 = i__ + j * a_dim1;
6478
i__3 = ix;
6479
q__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
6480
i__3].i, q__2.i = a[i__2].r * x[i__3].i +
6481
a[i__2].i * x[i__3].r;
6482
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6483
q__2.i;
6484
temp.r = q__1.r, temp.i = q__1.i;
6485
ix -= *incx;
6486
/* L180: */
6487
}
6488
if (nounit) {
6489
c_div(&q__1, &temp, &a[j + j * a_dim1]);
6490
temp.r = q__1.r, temp.i = q__1.i;
6491
}
6492
} else {
6493
i__1 = j + 1;
6494
for (i__ = *n; i__ >= i__1; --i__) {
6495
r_cnjg(&q__3, &a[i__ + j * a_dim1]);
6496
i__2 = ix;
6497
q__2.r = q__3.r * x[i__2].r - q__3.i * x[i__2].i,
6498
q__2.i = q__3.r * x[i__2].i + q__3.i * x[
6499
i__2].r;
6500
q__1.r = temp.r - q__2.r, q__1.i = temp.i -
6501
q__2.i;
6502
temp.r = q__1.r, temp.i = q__1.i;
6503
ix -= *incx;
6504
/* L190: */
6505
}
6506
if (nounit) {
6507
r_cnjg(&q__2, &a[j + j * a_dim1]);
6508
c_div(&q__1, &temp, &q__2);
6509
temp.r = q__1.r, temp.i = q__1.i;
6510
}
6511
}
6512
i__1 = jx;
6513
x[i__1].r = temp.r, x[i__1].i = temp.i;
6514
jx -= *incx;
6515
/* L200: */
6516
}
6517
}
6518
}
6519
}
6520
6521
return 0;
6522
6523
/* End of CTRSV . */
6524
6525
} /* ctrsv_ */
6526
6527
/* Subroutine */ int daxpy_(integer *n, doublereal *da, doublereal *dx,
6528
integer *incx, doublereal *dy, integer *incy)
6529
{
6530
/* System generated locals */
6531
integer i__1;
6532
6533
/* Local variables */
6534
static integer i__, m, ix, iy, mp1;
6535
6536
6537
/*
6538
Purpose
6539
=======
6540
6541
DAXPY constant times a vector plus a vector.
6542
uses unrolled loops for increments equal to one.
6543
6544
Further Details
6545
===============
6546
6547
jack dongarra, linpack, 3/11/78.
6548
modified 12/3/93, array(1) declarations changed to array(*)
6549
6550
=====================================================================
6551
*/
6552
6553
/* Parameter adjustments */
6554
--dy;
6555
--dx;
6556
6557
/* Function Body */
6558
if (*n <= 0) {
6559
return 0;
6560
}
6561
if (*da == 0.) {
6562
return 0;
6563
}
6564
if (*incx == 1 && *incy == 1) {
6565
goto L20;
6566
}
6567
6568
/*
6569
code for unequal increments or equal increments
6570
not equal to 1
6571
*/
6572
6573
ix = 1;
6574
iy = 1;
6575
if (*incx < 0) {
6576
ix = (-(*n) + 1) * *incx + 1;
6577
}
6578
if (*incy < 0) {
6579
iy = (-(*n) + 1) * *incy + 1;
6580
}
6581
i__1 = *n;
6582
for (i__ = 1; i__ <= i__1; ++i__) {
6583
dy[iy] += *da * dx[ix];
6584
ix += *incx;
6585
iy += *incy;
6586
/* L10: */
6587
}
6588
return 0;
6589
6590
/*
6591
code for both increments equal to 1
6592
6593
6594
clean-up loop
6595
*/
6596
6597
L20:
6598
m = *n % 4;
6599
if (m == 0) {
6600
goto L40;
6601
}
6602
i__1 = m;
6603
for (i__ = 1; i__ <= i__1; ++i__) {
6604
dy[i__] += *da * dx[i__];
6605
/* L30: */
6606
}
6607
if (*n < 4) {
6608
return 0;
6609
}
6610
L40:
6611
mp1 = m + 1;
6612
i__1 = *n;
6613
for (i__ = mp1; i__ <= i__1; i__ += 4) {
6614
dy[i__] += *da * dx[i__];
6615
dy[i__ + 1] += *da * dx[i__ + 1];
6616
dy[i__ + 2] += *da * dx[i__ + 2];
6617
dy[i__ + 3] += *da * dx[i__ + 3];
6618
/* L50: */
6619
}
6620
return 0;
6621
} /* daxpy_ */
6622
6623
doublereal dcabs1_(doublecomplex *z__)
6624
{
6625
/* System generated locals */
6626
doublereal ret_val, d__1, d__2;
6627
6628
/*
6629
Purpose
6630
=======
6631
6632
DCABS1 computes absolute value of a double singlecomplex number
6633
6634
=====================================================================
6635
*/
6636
6637
6638
ret_val = (d__1 = z__->r, abs(d__1)) + (d__2 = d_imag(z__), abs(d__2));
6639
return ret_val;
6640
} /* dcabs1_ */
6641
6642
/* Subroutine */ int dcopy_(integer *n, doublereal *dx, integer *incx,
6643
doublereal *dy, integer *incy)
6644
{
6645
/* System generated locals */
6646
integer i__1;
6647
6648
/* Local variables */
6649
static integer i__, m, ix, iy, mp1;
6650
6651
6652
/*
6653
Purpose
6654
=======
6655
6656
DCOPY copies a vector, x, to a vector, y.
6657
uses unrolled loops for increments equal to one.
6658
6659
Further Details
6660
===============
6661
6662
jack dongarra, linpack, 3/11/78.
6663
modified 12/3/93, array(1) declarations changed to array(*)
6664
6665
=====================================================================
6666
*/
6667
6668
/* Parameter adjustments */
6669
--dy;
6670
--dx;
6671
6672
/* Function Body */
6673
if (*n <= 0) {
6674
return 0;
6675
}
6676
if (*incx == 1 && *incy == 1) {
6677
goto L20;
6678
}
6679
6680
/*
6681
code for unequal increments or equal increments
6682
not equal to 1
6683
*/
6684
6685
ix = 1;
6686
iy = 1;
6687
if (*incx < 0) {
6688
ix = (-(*n) + 1) * *incx + 1;
6689
}
6690
if (*incy < 0) {
6691
iy = (-(*n) + 1) * *incy + 1;
6692
}
6693
i__1 = *n;
6694
for (i__ = 1; i__ <= i__1; ++i__) {
6695
dy[iy] = dx[ix];
6696
ix += *incx;
6697
iy += *incy;
6698
/* L10: */
6699
}
6700
return 0;
6701
6702
/*
6703
code for both increments equal to 1
6704
6705
6706
clean-up loop
6707
*/
6708
6709
L20:
6710
m = *n % 7;
6711
if (m == 0) {
6712
goto L40;
6713
}
6714
i__1 = m;
6715
for (i__ = 1; i__ <= i__1; ++i__) {
6716
dy[i__] = dx[i__];
6717
/* L30: */
6718
}
6719
if (*n < 7) {
6720
return 0;
6721
}
6722
L40:
6723
mp1 = m + 1;
6724
i__1 = *n;
6725
for (i__ = mp1; i__ <= i__1; i__ += 7) {
6726
dy[i__] = dx[i__];
6727
dy[i__ + 1] = dx[i__ + 1];
6728
dy[i__ + 2] = dx[i__ + 2];
6729
dy[i__ + 3] = dx[i__ + 3];
6730
dy[i__ + 4] = dx[i__ + 4];
6731
dy[i__ + 5] = dx[i__ + 5];
6732
dy[i__ + 6] = dx[i__ + 6];
6733
/* L50: */
6734
}
6735
return 0;
6736
} /* dcopy_ */
6737
6738
doublereal ddot_(integer *n, doublereal *dx, integer *incx, doublereal *dy,
6739
integer *incy)
6740
{
6741
/* System generated locals */
6742
integer i__1;
6743
doublereal ret_val;
6744
6745
/* Local variables */
6746
static integer i__, m, ix, iy, mp1;
6747
static doublereal dtemp;
6748
6749
6750
/*
6751
Purpose
6752
=======
6753
6754
DDOT forms the dot product of two vectors.
6755
uses unrolled loops for increments equal to one.
6756
6757
Further Details
6758
===============
6759
6760
jack dongarra, linpack, 3/11/78.
6761
modified 12/3/93, array(1) declarations changed to array(*)
6762
6763
=====================================================================
6764
*/
6765
6766
/* Parameter adjustments */
6767
--dy;
6768
--dx;
6769
6770
/* Function Body */
6771
ret_val = 0.;
6772
dtemp = 0.;
6773
if (*n <= 0) {
6774
return ret_val;
6775
}
6776
if (*incx == 1 && *incy == 1) {
6777
goto L20;
6778
}
6779
6780
/*
6781
code for unequal increments or equal increments
6782
not equal to 1
6783
*/
6784
6785
ix = 1;
6786
iy = 1;
6787
if (*incx < 0) {
6788
ix = (-(*n) + 1) * *incx + 1;
6789
}
6790
if (*incy < 0) {
6791
iy = (-(*n) + 1) * *incy + 1;
6792
}
6793
i__1 = *n;
6794
for (i__ = 1; i__ <= i__1; ++i__) {
6795
dtemp += dx[ix] * dy[iy];
6796
ix += *incx;
6797
iy += *incy;
6798
/* L10: */
6799
}
6800
ret_val = dtemp;
6801
return ret_val;
6802
6803
/*
6804
code for both increments equal to 1
6805
6806
6807
clean-up loop
6808
*/
6809
6810
L20:
6811
m = *n % 5;
6812
if (m == 0) {
6813
goto L40;
6814
}
6815
i__1 = m;
6816
for (i__ = 1; i__ <= i__1; ++i__) {
6817
dtemp += dx[i__] * dy[i__];
6818
/* L30: */
6819
}
6820
if (*n < 5) {
6821
goto L60;
6822
}
6823
L40:
6824
mp1 = m + 1;
6825
i__1 = *n;
6826
for (i__ = mp1; i__ <= i__1; i__ += 5) {
6827
dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1] + dx[
6828
i__ + 2] * dy[i__ + 2] + dx[i__ + 3] * dy[i__ + 3] + dx[i__ +
6829
4] * dy[i__ + 4];
6830
/* L50: */
6831
}
6832
L60:
6833
ret_val = dtemp;
6834
return ret_val;
6835
} /* ddot_ */
6836
6837
/* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer *
6838
n, integer *k, doublereal *alpha, doublereal *a, integer *lda,
6839
doublereal *b, integer *ldb, doublereal *beta, doublereal *c__,
6840
integer *ldc)
6841
{
6842
/* System generated locals */
6843
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
6844
i__3;
6845
6846
/* Local variables */
6847
static integer i__, j, l, info;
6848
static logical nota, notb;
6849
static doublereal temp;
6850
extern logical lsame_(char *, char *);
6851
static integer nrowa, nrowb;
6852
extern /* Subroutine */ int xerbla_(char *, integer *);
6853
6854
6855
/*
6856
Purpose
6857
=======
6858
6859
DGEMM performs one of the matrix-matrix operations
6860
6861
C := alpha*op( A )*op( B ) + beta*C,
6862
6863
where op( X ) is one of
6864
6865
op( X ) = X or op( X ) = X',
6866
6867
alpha and beta are scalars, and A, B and C are matrices, with op( A )
6868
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
6869
6870
Arguments
6871
==========
6872
6873
TRANSA - CHARACTER*1.
6874
On entry, TRANSA specifies the form of op( A ) to be used in
6875
the matrix multiplication as follows:
6876
6877
TRANSA = 'N' or 'n', op( A ) = A.
6878
6879
TRANSA = 'T' or 't', op( A ) = A'.
6880
6881
TRANSA = 'C' or 'c', op( A ) = A'.
6882
6883
Unchanged on exit.
6884
6885
TRANSB - CHARACTER*1.
6886
On entry, TRANSB specifies the form of op( B ) to be used in
6887
the matrix multiplication as follows:
6888
6889
TRANSB = 'N' or 'n', op( B ) = B.
6890
6891
TRANSB = 'T' or 't', op( B ) = B'.
6892
6893
TRANSB = 'C' or 'c', op( B ) = B'.
6894
6895
Unchanged on exit.
6896
6897
M - INTEGER.
6898
On entry, M specifies the number of rows of the matrix
6899
op( A ) and of the matrix C. M must be at least zero.
6900
Unchanged on exit.
6901
6902
N - INTEGER.
6903
On entry, N specifies the number of columns of the matrix
6904
op( B ) and the number of columns of the matrix C. N must be
6905
at least zero.
6906
Unchanged on exit.
6907
6908
K - INTEGER.
6909
On entry, K specifies the number of columns of the matrix
6910
op( A ) and the number of rows of the matrix op( B ). K must
6911
be at least zero.
6912
Unchanged on exit.
6913
6914
ALPHA - DOUBLE PRECISION.
6915
On entry, ALPHA specifies the scalar alpha.
6916
Unchanged on exit.
6917
6918
A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is
6919
k when TRANSA = 'N' or 'n', and is m otherwise.
6920
Before entry with TRANSA = 'N' or 'n', the leading m by k
6921
part of the array A must contain the matrix A, otherwise
6922
the leading k by m part of the array A must contain the
6923
matrix A.
6924
Unchanged on exit.
6925
6926
LDA - INTEGER.
6927
On entry, LDA specifies the first dimension of A as declared
6928
in the calling (sub) program. When TRANSA = 'N' or 'n' then
6929
LDA must be at least max( 1, m ), otherwise LDA must be at
6930
least max( 1, k ).
6931
Unchanged on exit.
6932
6933
B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is
6934
n when TRANSB = 'N' or 'n', and is k otherwise.
6935
Before entry with TRANSB = 'N' or 'n', the leading k by n
6936
part of the array B must contain the matrix B, otherwise
6937
the leading n by k part of the array B must contain the
6938
matrix B.
6939
Unchanged on exit.
6940
6941
LDB - INTEGER.
6942
On entry, LDB specifies the first dimension of B as declared
6943
in the calling (sub) program. When TRANSB = 'N' or 'n' then
6944
LDB must be at least max( 1, k ), otherwise LDB must be at
6945
least max( 1, n ).
6946
Unchanged on exit.
6947
6948
BETA - DOUBLE PRECISION.
6949
On entry, BETA specifies the scalar beta. When BETA is
6950
supplied as zero then C need not be set on input.
6951
Unchanged on exit.
6952
6953
C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
6954
Before entry, the leading m by n part of the array C must
6955
contain the matrix C, except when beta is zero, in which
6956
case C need not be set on entry.
6957
On exit, the array C is overwritten by the m by n matrix
6958
( alpha*op( A )*op( B ) + beta*C ).
6959
6960
LDC - INTEGER.
6961
On entry, LDC specifies the first dimension of C as declared
6962
in the calling (sub) program. LDC must be at least
6963
max( 1, m ).
6964
Unchanged on exit.
6965
6966
Further Details
6967
===============
6968
6969
Level 3 Blas routine.
6970
6971
-- Written on 8-February-1989.
6972
Jack Dongarra, Argonne National Laboratory.
6973
Iain Duff, AERE Harwell.
6974
Jeremy Du Croz, Numerical Algorithms Group Ltd.
6975
Sven Hammarling, Numerical Algorithms Group Ltd.
6976
6977
=====================================================================
6978
6979
6980
Set NOTA and NOTB as true if A and B respectively are not
6981
transposed and set NROWA and NROWB as the number of rows
6982
and columns of A and the number of rows of B respectively.
6983
*/
6984
6985
/* Parameter adjustments */
6986
a_dim1 = *lda;
6987
a_offset = 1 + a_dim1;
6988
a -= a_offset;
6989
b_dim1 = *ldb;
6990
b_offset = 1 + b_dim1;
6991
b -= b_offset;
6992
c_dim1 = *ldc;
6993
c_offset = 1 + c_dim1;
6994
c__ -= c_offset;
6995
6996
/* Function Body */
6997
nota = lsame_(transa, "N");
6998
notb = lsame_(transb, "N");
6999
if (nota) {
7000
nrowa = *m;
7001
} else {
7002
nrowa = *k;
7003
}
7004
if (notb) {
7005
nrowb = *k;
7006
} else {
7007
nrowb = *n;
7008
}
7009
7010
/* Test the input parameters. */
7011
7012
info = 0;
7013
if (! nota && ! lsame_(transa, "C") && ! lsame_(
7014
transa, "T")) {
7015
info = 1;
7016
} else if (! notb && ! lsame_(transb, "C") && !
7017
lsame_(transb, "T")) {
7018
info = 2;
7019
} else if (*m < 0) {
7020
info = 3;
7021
} else if (*n < 0) {
7022
info = 4;
7023
} else if (*k < 0) {
7024
info = 5;
7025
} else if (*lda < max(1,nrowa)) {
7026
info = 8;
7027
} else if (*ldb < max(1,nrowb)) {
7028
info = 10;
7029
} else if (*ldc < max(1,*m)) {
7030
info = 13;
7031
}
7032
if (info != 0) {
7033
xerbla_("DGEMM ", &info);
7034
return 0;
7035
}
7036
7037
/* Quick return if possible. */
7038
7039
if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
7040
return 0;
7041
}
7042
7043
/* And if alpha.eq.zero. */
7044
7045
if (*alpha == 0.) {
7046
if (*beta == 0.) {
7047
i__1 = *n;
7048
for (j = 1; j <= i__1; ++j) {
7049
i__2 = *m;
7050
for (i__ = 1; i__ <= i__2; ++i__) {
7051
c__[i__ + j * c_dim1] = 0.;
7052
/* L10: */
7053
}
7054
/* L20: */
7055
}
7056
} else {
7057
i__1 = *n;
7058
for (j = 1; j <= i__1; ++j) {
7059
i__2 = *m;
7060
for (i__ = 1; i__ <= i__2; ++i__) {
7061
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
7062
/* L30: */
7063
}
7064
/* L40: */
7065
}
7066
}
7067
return 0;
7068
}
7069
7070
/* Start the operations. */
7071
7072
if (notb) {
7073
if (nota) {
7074
7075
/* Form C := alpha*A*B + beta*C. */
7076
7077
i__1 = *n;
7078
for (j = 1; j <= i__1; ++j) {
7079
if (*beta == 0.) {
7080
i__2 = *m;
7081
for (i__ = 1; i__ <= i__2; ++i__) {
7082
c__[i__ + j * c_dim1] = 0.;
7083
/* L50: */
7084
}
7085
} else if (*beta != 1.) {
7086
i__2 = *m;
7087
for (i__ = 1; i__ <= i__2; ++i__) {
7088
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
7089
/* L60: */
7090
}
7091
}
7092
i__2 = *k;
7093
for (l = 1; l <= i__2; ++l) {
7094
if (b[l + j * b_dim1] != 0.) {
7095
temp = *alpha * b[l + j * b_dim1];
7096
i__3 = *m;
7097
for (i__ = 1; i__ <= i__3; ++i__) {
7098
c__[i__ + j * c_dim1] += temp * a[i__ + l *
7099
a_dim1];
7100
/* L70: */
7101
}
7102
}
7103
/* L80: */
7104
}
7105
/* L90: */
7106
}
7107
} else {
7108
7109
/* Form C := alpha*A'*B + beta*C */
7110
7111
i__1 = *n;
7112
for (j = 1; j <= i__1; ++j) {
7113
i__2 = *m;
7114
for (i__ = 1; i__ <= i__2; ++i__) {
7115
temp = 0.;
7116
i__3 = *k;
7117
for (l = 1; l <= i__3; ++l) {
7118
temp += a[l + i__ * a_dim1] * b[l + j * b_dim1];
7119
/* L100: */
7120
}
7121
if (*beta == 0.) {
7122
c__[i__ + j * c_dim1] = *alpha * temp;
7123
} else {
7124
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
7125
i__ + j * c_dim1];
7126
}
7127
/* L110: */
7128
}
7129
/* L120: */
7130
}
7131
}
7132
} else {
7133
if (nota) {
7134
7135
/* Form C := alpha*A*B' + beta*C */
7136
7137
i__1 = *n;
7138
for (j = 1; j <= i__1; ++j) {
7139
if (*beta == 0.) {
7140
i__2 = *m;
7141
for (i__ = 1; i__ <= i__2; ++i__) {
7142
c__[i__ + j * c_dim1] = 0.;
7143
/* L130: */
7144
}
7145
} else if (*beta != 1.) {
7146
i__2 = *m;
7147
for (i__ = 1; i__ <= i__2; ++i__) {
7148
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
7149
/* L140: */
7150
}
7151
}
7152
i__2 = *k;
7153
for (l = 1; l <= i__2; ++l) {
7154
if (b[j + l * b_dim1] != 0.) {
7155
temp = *alpha * b[j + l * b_dim1];
7156
i__3 = *m;
7157
for (i__ = 1; i__ <= i__3; ++i__) {
7158
c__[i__ + j * c_dim1] += temp * a[i__ + l *
7159
a_dim1];
7160
/* L150: */
7161
}
7162
}
7163
/* L160: */
7164
}
7165
/* L170: */
7166
}
7167
} else {
7168
7169
/* Form C := alpha*A'*B' + beta*C */
7170
7171
i__1 = *n;
7172
for (j = 1; j <= i__1; ++j) {
7173
i__2 = *m;
7174
for (i__ = 1; i__ <= i__2; ++i__) {
7175
temp = 0.;
7176
i__3 = *k;
7177
for (l = 1; l <= i__3; ++l) {
7178
temp += a[l + i__ * a_dim1] * b[j + l * b_dim1];
7179
/* L180: */
7180
}
7181
if (*beta == 0.) {
7182
c__[i__ + j * c_dim1] = *alpha * temp;
7183
} else {
7184
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
7185
i__ + j * c_dim1];
7186
}
7187
/* L190: */
7188
}
7189
/* L200: */
7190
}
7191
}
7192
}
7193
7194
return 0;
7195
7196
/* End of DGEMM . */
7197
7198
} /* dgemm_ */
7199
7200
/* Subroutine */ int dgemv_(char *trans, integer *m, integer *n, doublereal *
7201
alpha, doublereal *a, integer *lda, doublereal *x, integer *incx,
7202
doublereal *beta, doublereal *y, integer *incy)
7203
{
7204
/* System generated locals */
7205
integer a_dim1, a_offset, i__1, i__2;
7206
7207
/* Local variables */
7208
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
7209
static doublereal temp;
7210
static integer lenx, leny;
7211
extern logical lsame_(char *, char *);
7212
extern /* Subroutine */ int xerbla_(char *, integer *);
7213
7214
7215
/*
7216
Purpose
7217
=======
7218
7219
DGEMV performs one of the matrix-vector operations
7220
7221
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
7222
7223
where alpha and beta are scalars, x and y are vectors and A is an
7224
m by n matrix.
7225
7226
Arguments
7227
==========
7228
7229
TRANS - CHARACTER*1.
7230
On entry, TRANS specifies the operation to be performed as
7231
follows:
7232
7233
TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
7234
7235
TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
7236
7237
TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
7238
7239
Unchanged on exit.
7240
7241
M - INTEGER.
7242
On entry, M specifies the number of rows of the matrix A.
7243
M must be at least zero.
7244
Unchanged on exit.
7245
7246
N - INTEGER.
7247
On entry, N specifies the number of columns of the matrix A.
7248
N must be at least zero.
7249
Unchanged on exit.
7250
7251
ALPHA - DOUBLE PRECISION.
7252
On entry, ALPHA specifies the scalar alpha.
7253
Unchanged on exit.
7254
7255
A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
7256
Before entry, the leading m by n part of the array A must
7257
contain the matrix of coefficients.
7258
Unchanged on exit.
7259
7260
LDA - INTEGER.
7261
On entry, LDA specifies the first dimension of A as declared
7262
in the calling (sub) program. LDA must be at least
7263
max( 1, m ).
7264
Unchanged on exit.
7265
7266
X - DOUBLE PRECISION array of DIMENSION at least
7267
( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
7268
and at least
7269
( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
7270
Before entry, the incremented array X must contain the
7271
vector x.
7272
Unchanged on exit.
7273
7274
INCX - INTEGER.
7275
On entry, INCX specifies the increment for the elements of
7276
X. INCX must not be zero.
7277
Unchanged on exit.
7278
7279
BETA - DOUBLE PRECISION.
7280
On entry, BETA specifies the scalar beta. When BETA is
7281
supplied as zero then Y need not be set on input.
7282
Unchanged on exit.
7283
7284
Y - DOUBLE PRECISION array of DIMENSION at least
7285
( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
7286
and at least
7287
( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
7288
Before entry with BETA non-zero, the incremented array Y
7289
must contain the vector y. On exit, Y is overwritten by the
7290
updated vector y.
7291
7292
INCY - INTEGER.
7293
On entry, INCY specifies the increment for the elements of
7294
Y. INCY must not be zero.
7295
Unchanged on exit.
7296
7297
Further Details
7298
===============
7299
7300
Level 2 Blas routine.
7301
7302
-- Written on 22-October-1986.
7303
Jack Dongarra, Argonne National Lab.
7304
Jeremy Du Croz, Nag Central Office.
7305
Sven Hammarling, Nag Central Office.
7306
Richard Hanson, Sandia National Labs.
7307
7308
=====================================================================
7309
7310
7311
Test the input parameters.
7312
*/
7313
7314
/* Parameter adjustments */
7315
a_dim1 = *lda;
7316
a_offset = 1 + a_dim1;
7317
a -= a_offset;
7318
--x;
7319
--y;
7320
7321
/* Function Body */
7322
info = 0;
7323
if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
7324
) {
7325
info = 1;
7326
} else if (*m < 0) {
7327
info = 2;
7328
} else if (*n < 0) {
7329
info = 3;
7330
} else if (*lda < max(1,*m)) {
7331
info = 6;
7332
} else if (*incx == 0) {
7333
info = 8;
7334
} else if (*incy == 0) {
7335
info = 11;
7336
}
7337
if (info != 0) {
7338
xerbla_("DGEMV ", &info);
7339
return 0;
7340
}
7341
7342
/* Quick return if possible. */
7343
7344
if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
7345
return 0;
7346
}
7347
7348
/*
7349
Set LENX and LENY, the lengths of the vectors x and y, and set
7350
up the start points in X and Y.
7351
*/
7352
7353
if (lsame_(trans, "N")) {
7354
lenx = *n;
7355
leny = *m;
7356
} else {
7357
lenx = *m;
7358
leny = *n;
7359
}
7360
if (*incx > 0) {
7361
kx = 1;
7362
} else {
7363
kx = 1 - (lenx - 1) * *incx;
7364
}
7365
if (*incy > 0) {
7366
ky = 1;
7367
} else {
7368
ky = 1 - (leny - 1) * *incy;
7369
}
7370
7371
/*
7372
Start the operations. In this version the elements of A are
7373
accessed sequentially with one pass through A.
7374
7375
First form y := beta*y.
7376
*/
7377
7378
if (*beta != 1.) {
7379
if (*incy == 1) {
7380
if (*beta == 0.) {
7381
i__1 = leny;
7382
for (i__ = 1; i__ <= i__1; ++i__) {
7383
y[i__] = 0.;
7384
/* L10: */
7385
}
7386
} else {
7387
i__1 = leny;
7388
for (i__ = 1; i__ <= i__1; ++i__) {
7389
y[i__] = *beta * y[i__];
7390
/* L20: */
7391
}
7392
}
7393
} else {
7394
iy = ky;
7395
if (*beta == 0.) {
7396
i__1 = leny;
7397
for (i__ = 1; i__ <= i__1; ++i__) {
7398
y[iy] = 0.;
7399
iy += *incy;
7400
/* L30: */
7401
}
7402
} else {
7403
i__1 = leny;
7404
for (i__ = 1; i__ <= i__1; ++i__) {
7405
y[iy] = *beta * y[iy];
7406
iy += *incy;
7407
/* L40: */
7408
}
7409
}
7410
}
7411
}
7412
if (*alpha == 0.) {
7413
return 0;
7414
}
7415
if (lsame_(trans, "N")) {
7416
7417
/* Form y := alpha*A*x + y. */
7418
7419
jx = kx;
7420
if (*incy == 1) {
7421
i__1 = *n;
7422
for (j = 1; j <= i__1; ++j) {
7423
if (x[jx] != 0.) {
7424
temp = *alpha * x[jx];
7425
i__2 = *m;
7426
for (i__ = 1; i__ <= i__2; ++i__) {
7427
y[i__] += temp * a[i__ + j * a_dim1];
7428
/* L50: */
7429
}
7430
}
7431
jx += *incx;
7432
/* L60: */
7433
}
7434
} else {
7435
i__1 = *n;
7436
for (j = 1; j <= i__1; ++j) {
7437
if (x[jx] != 0.) {
7438
temp = *alpha * x[jx];
7439
iy = ky;
7440
i__2 = *m;
7441
for (i__ = 1; i__ <= i__2; ++i__) {
7442
y[iy] += temp * a[i__ + j * a_dim1];
7443
iy += *incy;
7444
/* L70: */
7445
}
7446
}
7447
jx += *incx;
7448
/* L80: */
7449
}
7450
}
7451
} else {
7452
7453
/* Form y := alpha*A'*x + y. */
7454
7455
jy = ky;
7456
if (*incx == 1) {
7457
i__1 = *n;
7458
for (j = 1; j <= i__1; ++j) {
7459
temp = 0.;
7460
i__2 = *m;
7461
for (i__ = 1; i__ <= i__2; ++i__) {
7462
temp += a[i__ + j * a_dim1] * x[i__];
7463
/* L90: */
7464
}
7465
y[jy] += *alpha * temp;
7466
jy += *incy;
7467
/* L100: */
7468
}
7469
} else {
7470
i__1 = *n;
7471
for (j = 1; j <= i__1; ++j) {
7472
temp = 0.;
7473
ix = kx;
7474
i__2 = *m;
7475
for (i__ = 1; i__ <= i__2; ++i__) {
7476
temp += a[i__ + j * a_dim1] * x[ix];
7477
ix += *incx;
7478
/* L110: */
7479
}
7480
y[jy] += *alpha * temp;
7481
jy += *incy;
7482
/* L120: */
7483
}
7484
}
7485
}
7486
7487
return 0;
7488
7489
/* End of DGEMV . */
7490
7491
} /* dgemv_ */
7492
7493
/* Subroutine */ int dger_(integer *m, integer *n, doublereal *alpha,
7494
doublereal *x, integer *incx, doublereal *y, integer *incy,
7495
doublereal *a, integer *lda)
7496
{
7497
/* System generated locals */
7498
integer a_dim1, a_offset, i__1, i__2;
7499
7500
/* Local variables */
7501
static integer i__, j, ix, jy, kx, info;
7502
static doublereal temp;
7503
extern /* Subroutine */ int xerbla_(char *, integer *);
7504
7505
7506
/*
7507
Purpose
7508
=======
7509
7510
DGER performs the rank 1 operation
7511
7512
A := alpha*x*y' + A,
7513
7514
where alpha is a scalar, x is an m element vector, y is an n element
7515
vector and A is an m by n matrix.
7516
7517
Arguments
7518
==========
7519
7520
M - INTEGER.
7521
On entry, M specifies the number of rows of the matrix A.
7522
M must be at least zero.
7523
Unchanged on exit.
7524
7525
N - INTEGER.
7526
On entry, N specifies the number of columns of the matrix A.
7527
N must be at least zero.
7528
Unchanged on exit.
7529
7530
ALPHA - DOUBLE PRECISION.
7531
On entry, ALPHA specifies the scalar alpha.
7532
Unchanged on exit.
7533
7534
X - DOUBLE PRECISION array of dimension at least
7535
( 1 + ( m - 1 )*abs( INCX ) ).
7536
Before entry, the incremented array X must contain the m
7537
element vector x.
7538
Unchanged on exit.
7539
7540
INCX - INTEGER.
7541
On entry, INCX specifies the increment for the elements of
7542
X. INCX must not be zero.
7543
Unchanged on exit.
7544
7545
Y - DOUBLE PRECISION array of dimension at least
7546
( 1 + ( n - 1 )*abs( INCY ) ).
7547
Before entry, the incremented array Y must contain the n
7548
element vector y.
7549
Unchanged on exit.
7550
7551
INCY - INTEGER.
7552
On entry, INCY specifies the increment for the elements of
7553
Y. INCY must not be zero.
7554
Unchanged on exit.
7555
7556
A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
7557
Before entry, the leading m by n part of the array A must
7558
contain the matrix of coefficients. On exit, A is
7559
overwritten by the updated matrix.
7560
7561
LDA - INTEGER.
7562
On entry, LDA specifies the first dimension of A as declared
7563
in the calling (sub) program. LDA must be at least
7564
max( 1, m ).
7565
Unchanged on exit.
7566
7567
Further Details
7568
===============
7569
7570
Level 2 Blas routine.
7571
7572
-- Written on 22-October-1986.
7573
Jack Dongarra, Argonne National Lab.
7574
Jeremy Du Croz, Nag Central Office.
7575
Sven Hammarling, Nag Central Office.
7576
Richard Hanson, Sandia National Labs.
7577
7578
=====================================================================
7579
7580
7581
Test the input parameters.
7582
*/
7583
7584
/* Parameter adjustments */
7585
--x;
7586
--y;
7587
a_dim1 = *lda;
7588
a_offset = 1 + a_dim1;
7589
a -= a_offset;
7590
7591
/* Function Body */
7592
info = 0;
7593
if (*m < 0) {
7594
info = 1;
7595
} else if (*n < 0) {
7596
info = 2;
7597
} else if (*incx == 0) {
7598
info = 5;
7599
} else if (*incy == 0) {
7600
info = 7;
7601
} else if (*lda < max(1,*m)) {
7602
info = 9;
7603
}
7604
if (info != 0) {
7605
xerbla_("DGER ", &info);
7606
return 0;
7607
}
7608
7609
/* Quick return if possible. */
7610
7611
if (*m == 0 || *n == 0 || *alpha == 0.) {
7612
return 0;
7613
}
7614
7615
/*
7616
Start the operations. In this version the elements of A are
7617
accessed sequentially with one pass through A.
7618
*/
7619
7620
if (*incy > 0) {
7621
jy = 1;
7622
} else {
7623
jy = 1 - (*n - 1) * *incy;
7624
}
7625
if (*incx == 1) {
7626
i__1 = *n;
7627
for (j = 1; j <= i__1; ++j) {
7628
if (y[jy] != 0.) {
7629
temp = *alpha * y[jy];
7630
i__2 = *m;
7631
for (i__ = 1; i__ <= i__2; ++i__) {
7632
a[i__ + j * a_dim1] += x[i__] * temp;
7633
/* L10: */
7634
}
7635
}
7636
jy += *incy;
7637
/* L20: */
7638
}
7639
} else {
7640
if (*incx > 0) {
7641
kx = 1;
7642
} else {
7643
kx = 1 - (*m - 1) * *incx;
7644
}
7645
i__1 = *n;
7646
for (j = 1; j <= i__1; ++j) {
7647
if (y[jy] != 0.) {
7648
temp = *alpha * y[jy];
7649
ix = kx;
7650
i__2 = *m;
7651
for (i__ = 1; i__ <= i__2; ++i__) {
7652
a[i__ + j * a_dim1] += x[ix] * temp;
7653
ix += *incx;
7654
/* L30: */
7655
}
7656
}
7657
jy += *incy;
7658
/* L40: */
7659
}
7660
}
7661
7662
return 0;
7663
7664
/* End of DGER . */
7665
7666
} /* dger_ */
7667
7668
doublereal dnrm2_(integer *n, doublereal *x, integer *incx)
7669
{
7670
/* System generated locals */
7671
integer i__1, i__2;
7672
doublereal ret_val, d__1;
7673
7674
/* Local variables */
7675
static integer ix;
7676
static doublereal ssq, norm, scale, absxi;
7677
7678
7679
/*
7680
Purpose
7681
=======
7682
7683
DNRM2 returns the euclidean norm of a vector via the function
7684
name, so that
7685
7686
DNRM2 := sqrt( x'*x )
7687
7688
Further Details
7689
===============
7690
7691
-- This version written on 25-October-1982.
7692
Modified on 14-October-1993 to inline the call to DLASSQ.
7693
Sven Hammarling, Nag Ltd.
7694
7695
=====================================================================
7696
*/
7697
7698
/* Parameter adjustments */
7699
--x;
7700
7701
/* Function Body */
7702
if (*n < 1 || *incx < 1) {
7703
norm = 0.;
7704
} else if (*n == 1) {
7705
norm = abs(x[1]);
7706
} else {
7707
scale = 0.;
7708
ssq = 1.;
7709
/*
7710
The following loop is equivalent to this call to the LAPACK
7711
auxiliary routine:
7712
CALL DLASSQ( N, X, INCX, SCALE, SSQ )
7713
*/
7714
7715
i__1 = (*n - 1) * *incx + 1;
7716
i__2 = *incx;
7717
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
7718
if (x[ix] != 0.) {
7719
absxi = (d__1 = x[ix], abs(d__1));
7720
if (scale < absxi) {
7721
/* Computing 2nd power */
7722
d__1 = scale / absxi;
7723
ssq = ssq * (d__1 * d__1) + 1.;
7724
scale = absxi;
7725
} else {
7726
/* Computing 2nd power */
7727
d__1 = absxi / scale;
7728
ssq += d__1 * d__1;
7729
}
7730
}
7731
/* L10: */
7732
}
7733
norm = scale * sqrt(ssq);
7734
}
7735
7736
ret_val = norm;
7737
return ret_val;
7738
7739
/* End of DNRM2. */
7740
7741
} /* dnrm2_ */
7742
7743
/* Subroutine */ int drot_(integer *n, doublereal *dx, integer *incx,
7744
doublereal *dy, integer *incy, doublereal *c__, doublereal *s)
7745
{
7746
/* System generated locals */
7747
integer i__1;
7748
7749
/* Local variables */
7750
static integer i__, ix, iy;
7751
static doublereal dtemp;
7752
7753
7754
/*
7755
Purpose
7756
=======
7757
7758
DROT applies a plane rotation.
7759
7760
Further Details
7761
===============
7762
7763
jack dongarra, linpack, 3/11/78.
7764
modified 12/3/93, array(1) declarations changed to array(*)
7765
7766
=====================================================================
7767
*/
7768
7769
/* Parameter adjustments */
7770
--dy;
7771
--dx;
7772
7773
/* Function Body */
7774
if (*n <= 0) {
7775
return 0;
7776
}
7777
if (*incx == 1 && *incy == 1) {
7778
goto L20;
7779
}
7780
7781
/*
7782
code for unequal increments or equal increments not equal
7783
to 1
7784
*/
7785
7786
ix = 1;
7787
iy = 1;
7788
if (*incx < 0) {
7789
ix = (-(*n) + 1) * *incx + 1;
7790
}
7791
if (*incy < 0) {
7792
iy = (-(*n) + 1) * *incy + 1;
7793
}
7794
i__1 = *n;
7795
for (i__ = 1; i__ <= i__1; ++i__) {
7796
dtemp = *c__ * dx[ix] + *s * dy[iy];
7797
dy[iy] = *c__ * dy[iy] - *s * dx[ix];
7798
dx[ix] = dtemp;
7799
ix += *incx;
7800
iy += *incy;
7801
/* L10: */
7802
}
7803
return 0;
7804
7805
/* code for both increments equal to 1 */
7806
7807
L20:
7808
i__1 = *n;
7809
for (i__ = 1; i__ <= i__1; ++i__) {
7810
dtemp = *c__ * dx[i__] + *s * dy[i__];
7811
dy[i__] = *c__ * dy[i__] - *s * dx[i__];
7812
dx[i__] = dtemp;
7813
/* L30: */
7814
}
7815
return 0;
7816
} /* drot_ */
7817
7818
/* Subroutine */ int dscal_(integer *n, doublereal *da, doublereal *dx,
7819
integer *incx)
7820
{
7821
/* System generated locals */
7822
integer i__1, i__2;
7823
7824
/* Local variables */
7825
static integer i__, m, mp1, nincx;
7826
7827
7828
/*
7829
Purpose
7830
=======
7831
7832
DSCAL scales a vector by a constant.
7833
uses unrolled loops for increment equal to one.
7834
7835
Further Details
7836
===============
7837
7838
jack dongarra, linpack, 3/11/78.
7839
modified 3/93 to return if incx .le. 0.
7840
modified 12/3/93, array(1) declarations changed to array(*)
7841
7842
=====================================================================
7843
*/
7844
7845
/* Parameter adjustments */
7846
--dx;
7847
7848
/* Function Body */
7849
if (*n <= 0 || *incx <= 0) {
7850
return 0;
7851
}
7852
if (*incx == 1) {
7853
goto L20;
7854
}
7855
7856
/* code for increment not equal to 1 */
7857
7858
nincx = *n * *incx;
7859
i__1 = nincx;
7860
i__2 = *incx;
7861
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
7862
dx[i__] = *da * dx[i__];
7863
/* L10: */
7864
}
7865
return 0;
7866
7867
/*
7868
code for increment equal to 1
7869
7870
7871
clean-up loop
7872
*/
7873
7874
L20:
7875
m = *n % 5;
7876
if (m == 0) {
7877
goto L40;
7878
}
7879
i__2 = m;
7880
for (i__ = 1; i__ <= i__2; ++i__) {
7881
dx[i__] = *da * dx[i__];
7882
/* L30: */
7883
}
7884
if (*n < 5) {
7885
return 0;
7886
}
7887
L40:
7888
mp1 = m + 1;
7889
i__2 = *n;
7890
for (i__ = mp1; i__ <= i__2; i__ += 5) {
7891
dx[i__] = *da * dx[i__];
7892
dx[i__ + 1] = *da * dx[i__ + 1];
7893
dx[i__ + 2] = *da * dx[i__ + 2];
7894
dx[i__ + 3] = *da * dx[i__ + 3];
7895
dx[i__ + 4] = *da * dx[i__ + 4];
7896
/* L50: */
7897
}
7898
return 0;
7899
} /* dscal_ */
7900
7901
/* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx,
7902
doublereal *dy, integer *incy)
7903
{
7904
/* System generated locals */
7905
integer i__1;
7906
7907
/* Local variables */
7908
static integer i__, m, ix, iy, mp1;
7909
static doublereal dtemp;
7910
7911
7912
/*
7913
Purpose
7914
=======
7915
7916
interchanges two vectors.
7917
uses unrolled loops for increments equal one.
7918
7919
Further Details
7920
===============
7921
7922
jack dongarra, linpack, 3/11/78.
7923
modified 12/3/93, array(1) declarations changed to array(*)
7924
7925
=====================================================================
7926
*/
7927
7928
/* Parameter adjustments */
7929
--dy;
7930
--dx;
7931
7932
/* Function Body */
7933
if (*n <= 0) {
7934
return 0;
7935
}
7936
if (*incx == 1 && *incy == 1) {
7937
goto L20;
7938
}
7939
7940
/*
7941
code for unequal increments or equal increments not equal
7942
to 1
7943
*/
7944
7945
ix = 1;
7946
iy = 1;
7947
if (*incx < 0) {
7948
ix = (-(*n) + 1) * *incx + 1;
7949
}
7950
if (*incy < 0) {
7951
iy = (-(*n) + 1) * *incy + 1;
7952
}
7953
i__1 = *n;
7954
for (i__ = 1; i__ <= i__1; ++i__) {
7955
dtemp = dx[ix];
7956
dx[ix] = dy[iy];
7957
dy[iy] = dtemp;
7958
ix += *incx;
7959
iy += *incy;
7960
/* L10: */
7961
}
7962
return 0;
7963
7964
/*
7965
code for both increments equal to 1
7966
7967
7968
clean-up loop
7969
*/
7970
7971
L20:
7972
m = *n % 3;
7973
if (m == 0) {
7974
goto L40;
7975
}
7976
i__1 = m;
7977
for (i__ = 1; i__ <= i__1; ++i__) {
7978
dtemp = dx[i__];
7979
dx[i__] = dy[i__];
7980
dy[i__] = dtemp;
7981
/* L30: */
7982
}
7983
if (*n < 3) {
7984
return 0;
7985
}
7986
L40:
7987
mp1 = m + 1;
7988
i__1 = *n;
7989
for (i__ = mp1; i__ <= i__1; i__ += 3) {
7990
dtemp = dx[i__];
7991
dx[i__] = dy[i__];
7992
dy[i__] = dtemp;
7993
dtemp = dx[i__ + 1];
7994
dx[i__ + 1] = dy[i__ + 1];
7995
dy[i__ + 1] = dtemp;
7996
dtemp = dx[i__ + 2];
7997
dx[i__ + 2] = dy[i__ + 2];
7998
dy[i__ + 2] = dtemp;
7999
/* L50: */
8000
}
8001
return 0;
8002
} /* dswap_ */
8003
8004
/* Subroutine */ int dsymv_(char *uplo, integer *n, doublereal *alpha,
8005
doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal
8006
*beta, doublereal *y, integer *incy)
8007
{
8008
/* System generated locals */
8009
integer a_dim1, a_offset, i__1, i__2;
8010
8011
/* Local variables */
8012
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
8013
static doublereal temp1, temp2;
8014
extern logical lsame_(char *, char *);
8015
extern /* Subroutine */ int xerbla_(char *, integer *);
8016
8017
8018
/*
8019
Purpose
8020
=======
8021
8022
DSYMV performs the matrix-vector operation
8023
8024
y := alpha*A*x + beta*y,
8025
8026
where alpha and beta are scalars, x and y are n element vectors and
8027
A is an n by n symmetric matrix.
8028
8029
Arguments
8030
==========
8031
8032
UPLO - CHARACTER*1.
8033
On entry, UPLO specifies whether the upper or lower
8034
triangular part of the array A is to be referenced as
8035
follows:
8036
8037
UPLO = 'U' or 'u' Only the upper triangular part of A
8038
is to be referenced.
8039
8040
UPLO = 'L' or 'l' Only the lower triangular part of A
8041
is to be referenced.
8042
8043
Unchanged on exit.
8044
8045
N - INTEGER.
8046
On entry, N specifies the order of the matrix A.
8047
N must be at least zero.
8048
Unchanged on exit.
8049
8050
ALPHA - DOUBLE PRECISION.
8051
On entry, ALPHA specifies the scalar alpha.
8052
Unchanged on exit.
8053
8054
A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
8055
Before entry with UPLO = 'U' or 'u', the leading n by n
8056
upper triangular part of the array A must contain the upper
8057
triangular part of the symmetric matrix and the strictly
8058
lower triangular part of A is not referenced.
8059
Before entry with UPLO = 'L' or 'l', the leading n by n
8060
lower triangular part of the array A must contain the lower
8061
triangular part of the symmetric matrix and the strictly
8062
upper triangular part of A is not referenced.
8063
Unchanged on exit.
8064
8065
LDA - INTEGER.
8066
On entry, LDA specifies the first dimension of A as declared
8067
in the calling (sub) program. LDA must be at least
8068
max( 1, n ).
8069
Unchanged on exit.
8070
8071
X - DOUBLE PRECISION array of dimension at least
8072
( 1 + ( n - 1 )*abs( INCX ) ).
8073
Before entry, the incremented array X must contain the n
8074
element vector x.
8075
Unchanged on exit.
8076
8077
INCX - INTEGER.
8078
On entry, INCX specifies the increment for the elements of
8079
X. INCX must not be zero.
8080
Unchanged on exit.
8081
8082
BETA - DOUBLE PRECISION.
8083
On entry, BETA specifies the scalar beta. When BETA is
8084
supplied as zero then Y need not be set on input.
8085
Unchanged on exit.
8086
8087
Y - DOUBLE PRECISION array of dimension at least
8088
( 1 + ( n - 1 )*abs( INCY ) ).
8089
Before entry, the incremented array Y must contain the n
8090
element vector y. On exit, Y is overwritten by the updated
8091
vector y.
8092
8093
INCY - INTEGER.
8094
On entry, INCY specifies the increment for the elements of
8095
Y. INCY must not be zero.
8096
Unchanged on exit.
8097
8098
Further Details
8099
===============
8100
8101
Level 2 Blas routine.
8102
8103
-- Written on 22-October-1986.
8104
Jack Dongarra, Argonne National Lab.
8105
Jeremy Du Croz, Nag Central Office.
8106
Sven Hammarling, Nag Central Office.
8107
Richard Hanson, Sandia National Labs.
8108
8109
=====================================================================
8110
8111
8112
Test the input parameters.
8113
*/
8114
8115
/* Parameter adjustments */
8116
a_dim1 = *lda;
8117
a_offset = 1 + a_dim1;
8118
a -= a_offset;
8119
--x;
8120
--y;
8121
8122
/* Function Body */
8123
info = 0;
8124
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
8125
info = 1;
8126
} else if (*n < 0) {
8127
info = 2;
8128
} else if (*lda < max(1,*n)) {
8129
info = 5;
8130
} else if (*incx == 0) {
8131
info = 7;
8132
} else if (*incy == 0) {
8133
info = 10;
8134
}
8135
if (info != 0) {
8136
xerbla_("DSYMV ", &info);
8137
return 0;
8138
}
8139
8140
/* Quick return if possible. */
8141
8142
if (*n == 0 || *alpha == 0. && *beta == 1.) {
8143
return 0;
8144
}
8145
8146
/* Set up the start points in X and Y. */
8147
8148
if (*incx > 0) {
8149
kx = 1;
8150
} else {
8151
kx = 1 - (*n - 1) * *incx;
8152
}
8153
if (*incy > 0) {
8154
ky = 1;
8155
} else {
8156
ky = 1 - (*n - 1) * *incy;
8157
}
8158
8159
/*
8160
Start the operations. In this version the elements of A are
8161
accessed sequentially with one pass through the triangular part
8162
of A.
8163
8164
First form y := beta*y.
8165
*/
8166
8167
if (*beta != 1.) {
8168
if (*incy == 1) {
8169
if (*beta == 0.) {
8170
i__1 = *n;
8171
for (i__ = 1; i__ <= i__1; ++i__) {
8172
y[i__] = 0.;
8173
/* L10: */
8174
}
8175
} else {
8176
i__1 = *n;
8177
for (i__ = 1; i__ <= i__1; ++i__) {
8178
y[i__] = *beta * y[i__];
8179
/* L20: */
8180
}
8181
}
8182
} else {
8183
iy = ky;
8184
if (*beta == 0.) {
8185
i__1 = *n;
8186
for (i__ = 1; i__ <= i__1; ++i__) {
8187
y[iy] = 0.;
8188
iy += *incy;
8189
/* L30: */
8190
}
8191
} else {
8192
i__1 = *n;
8193
for (i__ = 1; i__ <= i__1; ++i__) {
8194
y[iy] = *beta * y[iy];
8195
iy += *incy;
8196
/* L40: */
8197
}
8198
}
8199
}
8200
}
8201
if (*alpha == 0.) {
8202
return 0;
8203
}
8204
if (lsame_(uplo, "U")) {
8205
8206
/* Form y when A is stored in upper triangle. */
8207
8208
if (*incx == 1 && *incy == 1) {
8209
i__1 = *n;
8210
for (j = 1; j <= i__1; ++j) {
8211
temp1 = *alpha * x[j];
8212
temp2 = 0.;
8213
i__2 = j - 1;
8214
for (i__ = 1; i__ <= i__2; ++i__) {
8215
y[i__] += temp1 * a[i__ + j * a_dim1];
8216
temp2 += a[i__ + j * a_dim1] * x[i__];
8217
/* L50: */
8218
}
8219
y[j] = y[j] + temp1 * a[j + j * a_dim1] + *alpha * temp2;
8220
/* L60: */
8221
}
8222
} else {
8223
jx = kx;
8224
jy = ky;
8225
i__1 = *n;
8226
for (j = 1; j <= i__1; ++j) {
8227
temp1 = *alpha * x[jx];
8228
temp2 = 0.;
8229
ix = kx;
8230
iy = ky;
8231
i__2 = j - 1;
8232
for (i__ = 1; i__ <= i__2; ++i__) {
8233
y[iy] += temp1 * a[i__ + j * a_dim1];
8234
temp2 += a[i__ + j * a_dim1] * x[ix];
8235
ix += *incx;
8236
iy += *incy;
8237
/* L70: */
8238
}
8239
y[jy] = y[jy] + temp1 * a[j + j * a_dim1] + *alpha * temp2;
8240
jx += *incx;
8241
jy += *incy;
8242
/* L80: */
8243
}
8244
}
8245
} else {
8246
8247
/* Form y when A is stored in lower triangle. */
8248
8249
if (*incx == 1 && *incy == 1) {
8250
i__1 = *n;
8251
for (j = 1; j <= i__1; ++j) {
8252
temp1 = *alpha * x[j];
8253
temp2 = 0.;
8254
y[j] += temp1 * a[j + j * a_dim1];
8255
i__2 = *n;
8256
for (i__ = j + 1; i__ <= i__2; ++i__) {
8257
y[i__] += temp1 * a[i__ + j * a_dim1];
8258
temp2 += a[i__ + j * a_dim1] * x[i__];
8259
/* L90: */
8260
}
8261
y[j] += *alpha * temp2;
8262
/* L100: */
8263
}
8264
} else {
8265
jx = kx;
8266
jy = ky;
8267
i__1 = *n;
8268
for (j = 1; j <= i__1; ++j) {
8269
temp1 = *alpha * x[jx];
8270
temp2 = 0.;
8271
y[jy] += temp1 * a[j + j * a_dim1];
8272
ix = jx;
8273
iy = jy;
8274
i__2 = *n;
8275
for (i__ = j + 1; i__ <= i__2; ++i__) {
8276
ix += *incx;
8277
iy += *incy;
8278
y[iy] += temp1 * a[i__ + j * a_dim1];
8279
temp2 += a[i__ + j * a_dim1] * x[ix];
8280
/* L110: */
8281
}
8282
y[jy] += *alpha * temp2;
8283
jx += *incx;
8284
jy += *incy;
8285
/* L120: */
8286
}
8287
}
8288
}
8289
8290
return 0;
8291
8292
/* End of DSYMV . */
8293
8294
} /* dsymv_ */
8295
8296
/* Subroutine */ int dsyr2_(char *uplo, integer *n, doublereal *alpha,
8297
doublereal *x, integer *incx, doublereal *y, integer *incy,
8298
doublereal *a, integer *lda)
8299
{
8300
/* System generated locals */
8301
integer a_dim1, a_offset, i__1, i__2;
8302
8303
/* Local variables */
8304
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
8305
static doublereal temp1, temp2;
8306
extern logical lsame_(char *, char *);
8307
extern /* Subroutine */ int xerbla_(char *, integer *);
8308
8309
8310
/*
8311
Purpose
8312
=======
8313
8314
DSYR2 performs the symmetric rank 2 operation
8315
8316
A := alpha*x*y' + alpha*y*x' + A,
8317
8318
where alpha is a scalar, x and y are n element vectors and A is an n
8319
by n symmetric matrix.
8320
8321
Arguments
8322
==========
8323
8324
UPLO - CHARACTER*1.
8325
On entry, UPLO specifies whether the upper or lower
8326
triangular part of the array A is to be referenced as
8327
follows:
8328
8329
UPLO = 'U' or 'u' Only the upper triangular part of A
8330
is to be referenced.
8331
8332
UPLO = 'L' or 'l' Only the lower triangular part of A
8333
is to be referenced.
8334
8335
Unchanged on exit.
8336
8337
N - INTEGER.
8338
On entry, N specifies the order of the matrix A.
8339
N must be at least zero.
8340
Unchanged on exit.
8341
8342
ALPHA - DOUBLE PRECISION.
8343
On entry, ALPHA specifies the scalar alpha.
8344
Unchanged on exit.
8345
8346
X - DOUBLE PRECISION array of dimension at least
8347
( 1 + ( n - 1 )*abs( INCX ) ).
8348
Before entry, the incremented array X must contain the n
8349
element vector x.
8350
Unchanged on exit.
8351
8352
INCX - INTEGER.
8353
On entry, INCX specifies the increment for the elements of
8354
X. INCX must not be zero.
8355
Unchanged on exit.
8356
8357
Y - DOUBLE PRECISION array of dimension at least
8358
( 1 + ( n - 1 )*abs( INCY ) ).
8359
Before entry, the incremented array Y must contain the n
8360
element vector y.
8361
Unchanged on exit.
8362
8363
INCY - INTEGER.
8364
On entry, INCY specifies the increment for the elements of
8365
Y. INCY must not be zero.
8366
Unchanged on exit.
8367
8368
A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
8369
Before entry with UPLO = 'U' or 'u', the leading n by n
8370
upper triangular part of the array A must contain the upper
8371
triangular part of the symmetric matrix and the strictly
8372
lower triangular part of A is not referenced. On exit, the
8373
upper triangular part of the array A is overwritten by the
8374
upper triangular part of the updated matrix.
8375
Before entry with UPLO = 'L' or 'l', the leading n by n
8376
lower triangular part of the array A must contain the lower
8377
triangular part of the symmetric matrix and the strictly
8378
upper triangular part of A is not referenced. On exit, the
8379
lower triangular part of the array A is overwritten by the
8380
lower triangular part of the updated matrix.
8381
8382
LDA - INTEGER.
8383
On entry, LDA specifies the first dimension of A as declared
8384
in the calling (sub) program. LDA must be at least
8385
max( 1, n ).
8386
Unchanged on exit.
8387
8388
Further Details
8389
===============
8390
8391
Level 2 Blas routine.
8392
8393
-- Written on 22-October-1986.
8394
Jack Dongarra, Argonne National Lab.
8395
Jeremy Du Croz, Nag Central Office.
8396
Sven Hammarling, Nag Central Office.
8397
Richard Hanson, Sandia National Labs.
8398
8399
=====================================================================
8400
8401
8402
Test the input parameters.
8403
*/
8404
8405
/* Parameter adjustments */
8406
--x;
8407
--y;
8408
a_dim1 = *lda;
8409
a_offset = 1 + a_dim1;
8410
a -= a_offset;
8411
8412
/* Function Body */
8413
info = 0;
8414
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
8415
info = 1;
8416
} else if (*n < 0) {
8417
info = 2;
8418
} else if (*incx == 0) {
8419
info = 5;
8420
} else if (*incy == 0) {
8421
info = 7;
8422
} else if (*lda < max(1,*n)) {
8423
info = 9;
8424
}
8425
if (info != 0) {
8426
xerbla_("DSYR2 ", &info);
8427
return 0;
8428
}
8429
8430
/* Quick return if possible. */
8431
8432
if (*n == 0 || *alpha == 0.) {
8433
return 0;
8434
}
8435
8436
/*
8437
Set up the start points in X and Y if the increments are not both
8438
unity.
8439
*/
8440
8441
if (*incx != 1 || *incy != 1) {
8442
if (*incx > 0) {
8443
kx = 1;
8444
} else {
8445
kx = 1 - (*n - 1) * *incx;
8446
}
8447
if (*incy > 0) {
8448
ky = 1;
8449
} else {
8450
ky = 1 - (*n - 1) * *incy;
8451
}
8452
jx = kx;
8453
jy = ky;
8454
}
8455
8456
/*
8457
Start the operations. In this version the elements of A are
8458
accessed sequentially with one pass through the triangular part
8459
of A.
8460
*/
8461
8462
if (lsame_(uplo, "U")) {
8463
8464
/* Form A when A is stored in the upper triangle. */
8465
8466
if (*incx == 1 && *incy == 1) {
8467
i__1 = *n;
8468
for (j = 1; j <= i__1; ++j) {
8469
if (x[j] != 0. || y[j] != 0.) {
8470
temp1 = *alpha * y[j];
8471
temp2 = *alpha * x[j];
8472
i__2 = j;
8473
for (i__ = 1; i__ <= i__2; ++i__) {
8474
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
8475
temp1 + y[i__] * temp2;
8476
/* L10: */
8477
}
8478
}
8479
/* L20: */
8480
}
8481
} else {
8482
i__1 = *n;
8483
for (j = 1; j <= i__1; ++j) {
8484
if (x[jx] != 0. || y[jy] != 0.) {
8485
temp1 = *alpha * y[jy];
8486
temp2 = *alpha * x[jx];
8487
ix = kx;
8488
iy = ky;
8489
i__2 = j;
8490
for (i__ = 1; i__ <= i__2; ++i__) {
8491
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
8492
temp1 + y[iy] * temp2;
8493
ix += *incx;
8494
iy += *incy;
8495
/* L30: */
8496
}
8497
}
8498
jx += *incx;
8499
jy += *incy;
8500
/* L40: */
8501
}
8502
}
8503
} else {
8504
8505
/* Form A when A is stored in the lower triangle. */
8506
8507
if (*incx == 1 && *incy == 1) {
8508
i__1 = *n;
8509
for (j = 1; j <= i__1; ++j) {
8510
if (x[j] != 0. || y[j] != 0.) {
8511
temp1 = *alpha * y[j];
8512
temp2 = *alpha * x[j];
8513
i__2 = *n;
8514
for (i__ = j; i__ <= i__2; ++i__) {
8515
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
8516
temp1 + y[i__] * temp2;
8517
/* L50: */
8518
}
8519
}
8520
/* L60: */
8521
}
8522
} else {
8523
i__1 = *n;
8524
for (j = 1; j <= i__1; ++j) {
8525
if (x[jx] != 0. || y[jy] != 0.) {
8526
temp1 = *alpha * y[jy];
8527
temp2 = *alpha * x[jx];
8528
ix = jx;
8529
iy = jy;
8530
i__2 = *n;
8531
for (i__ = j; i__ <= i__2; ++i__) {
8532
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
8533
temp1 + y[iy] * temp2;
8534
ix += *incx;
8535
iy += *incy;
8536
/* L70: */
8537
}
8538
}
8539
jx += *incx;
8540
jy += *incy;
8541
/* L80: */
8542
}
8543
}
8544
}
8545
8546
return 0;
8547
8548
/* End of DSYR2 . */
8549
8550
} /* dsyr2_ */
8551
8552
/* Subroutine */ int dsyr2k_(char *uplo, char *trans, integer *n, integer *k,
8553
doublereal *alpha, doublereal *a, integer *lda, doublereal *b,
8554
integer *ldb, doublereal *beta, doublereal *c__, integer *ldc)
8555
{
8556
/* System generated locals */
8557
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
8558
i__3;
8559
8560
/* Local variables */
8561
static integer i__, j, l, info;
8562
static doublereal temp1, temp2;
8563
extern logical lsame_(char *, char *);
8564
static integer nrowa;
8565
static logical upper;
8566
extern /* Subroutine */ int xerbla_(char *, integer *);
8567
8568
8569
/*
8570
Purpose
8571
=======
8572
8573
DSYR2K performs one of the symmetric rank 2k operations
8574
8575
C := alpha*A*B' + alpha*B*A' + beta*C,
8576
8577
or
8578
8579
C := alpha*A'*B + alpha*B'*A + beta*C,
8580
8581
where alpha and beta are scalars, C is an n by n symmetric matrix
8582
and A and B are n by k matrices in the first case and k by n
8583
matrices in the second case.
8584
8585
Arguments
8586
==========
8587
8588
UPLO - CHARACTER*1.
8589
On entry, UPLO specifies whether the upper or lower
8590
triangular part of the array C is to be referenced as
8591
follows:
8592
8593
UPLO = 'U' or 'u' Only the upper triangular part of C
8594
is to be referenced.
8595
8596
UPLO = 'L' or 'l' Only the lower triangular part of C
8597
is to be referenced.
8598
8599
Unchanged on exit.
8600
8601
TRANS - CHARACTER*1.
8602
On entry, TRANS specifies the operation to be performed as
8603
follows:
8604
8605
TRANS = 'N' or 'n' C := alpha*A*B' + alpha*B*A' +
8606
beta*C.
8607
8608
TRANS = 'T' or 't' C := alpha*A'*B + alpha*B'*A +
8609
beta*C.
8610
8611
TRANS = 'C' or 'c' C := alpha*A'*B + alpha*B'*A +
8612
beta*C.
8613
8614
Unchanged on exit.
8615
8616
N - INTEGER.
8617
On entry, N specifies the order of the matrix C. N must be
8618
at least zero.
8619
Unchanged on exit.
8620
8621
K - INTEGER.
8622
On entry with TRANS = 'N' or 'n', K specifies the number
8623
of columns of the matrices A and B, and on entry with
8624
TRANS = 'T' or 't' or 'C' or 'c', K specifies the number
8625
of rows of the matrices A and B. K must be at least zero.
8626
Unchanged on exit.
8627
8628
ALPHA - DOUBLE PRECISION.
8629
On entry, ALPHA specifies the scalar alpha.
8630
Unchanged on exit.
8631
8632
A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is
8633
k when TRANS = 'N' or 'n', and is n otherwise.
8634
Before entry with TRANS = 'N' or 'n', the leading n by k
8635
part of the array A must contain the matrix A, otherwise
8636
the leading k by n part of the array A must contain the
8637
matrix A.
8638
Unchanged on exit.
8639
8640
LDA - INTEGER.
8641
On entry, LDA specifies the first dimension of A as declared
8642
in the calling (sub) program. When TRANS = 'N' or 'n'
8643
then LDA must be at least max( 1, n ), otherwise LDA must
8644
be at least max( 1, k ).
8645
Unchanged on exit.
8646
8647
B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is
8648
k when TRANS = 'N' or 'n', and is n otherwise.
8649
Before entry with TRANS = 'N' or 'n', the leading n by k
8650
part of the array B must contain the matrix B, otherwise
8651
the leading k by n part of the array B must contain the
8652
matrix B.
8653
Unchanged on exit.
8654
8655
LDB - INTEGER.
8656
On entry, LDB specifies the first dimension of B as declared
8657
in the calling (sub) program. When TRANS = 'N' or 'n'
8658
then LDB must be at least max( 1, n ), otherwise LDB must
8659
be at least max( 1, k ).
8660
Unchanged on exit.
8661
8662
BETA - DOUBLE PRECISION.
8663
On entry, BETA specifies the scalar beta.
8664
Unchanged on exit.
8665
8666
C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
8667
Before entry with UPLO = 'U' or 'u', the leading n by n
8668
upper triangular part of the array C must contain the upper
8669
triangular part of the symmetric matrix and the strictly
8670
lower triangular part of C is not referenced. On exit, the
8671
upper triangular part of the array C is overwritten by the
8672
upper triangular part of the updated matrix.
8673
Before entry with UPLO = 'L' or 'l', the leading n by n
8674
lower triangular part of the array C must contain the lower
8675
triangular part of the symmetric matrix and the strictly
8676
upper triangular part of C is not referenced. On exit, the
8677
lower triangular part of the array C is overwritten by the
8678
lower triangular part of the updated matrix.
8679
8680
LDC - INTEGER.
8681
On entry, LDC specifies the first dimension of C as declared
8682
in the calling (sub) program. LDC must be at least
8683
max( 1, n ).
8684
Unchanged on exit.
8685
8686
Further Details
8687
===============
8688
8689
Level 3 Blas routine.
8690
8691
8692
-- Written on 8-February-1989.
8693
Jack Dongarra, Argonne National Laboratory.
8694
Iain Duff, AERE Harwell.
8695
Jeremy Du Croz, Numerical Algorithms Group Ltd.
8696
Sven Hammarling, Numerical Algorithms Group Ltd.
8697
8698
=====================================================================
8699
8700
8701
Test the input parameters.
8702
*/
8703
8704
/* Parameter adjustments */
8705
a_dim1 = *lda;
8706
a_offset = 1 + a_dim1;
8707
a -= a_offset;
8708
b_dim1 = *ldb;
8709
b_offset = 1 + b_dim1;
8710
b -= b_offset;
8711
c_dim1 = *ldc;
8712
c_offset = 1 + c_dim1;
8713
c__ -= c_offset;
8714
8715
/* Function Body */
8716
if (lsame_(trans, "N")) {
8717
nrowa = *n;
8718
} else {
8719
nrowa = *k;
8720
}
8721
upper = lsame_(uplo, "U");
8722
8723
info = 0;
8724
if (! upper && ! lsame_(uplo, "L")) {
8725
info = 1;
8726
} else if (! lsame_(trans, "N") && ! lsame_(trans,
8727
"T") && ! lsame_(trans, "C")) {
8728
info = 2;
8729
} else if (*n < 0) {
8730
info = 3;
8731
} else if (*k < 0) {
8732
info = 4;
8733
} else if (*lda < max(1,nrowa)) {
8734
info = 7;
8735
} else if (*ldb < max(1,nrowa)) {
8736
info = 9;
8737
} else if (*ldc < max(1,*n)) {
8738
info = 12;
8739
}
8740
if (info != 0) {
8741
xerbla_("DSYR2K", &info);
8742
return 0;
8743
}
8744
8745
/* Quick return if possible. */
8746
8747
if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
8748
return 0;
8749
}
8750
8751
/* And when alpha.eq.zero. */
8752
8753
if (*alpha == 0.) {
8754
if (upper) {
8755
if (*beta == 0.) {
8756
i__1 = *n;
8757
for (j = 1; j <= i__1; ++j) {
8758
i__2 = j;
8759
for (i__ = 1; i__ <= i__2; ++i__) {
8760
c__[i__ + j * c_dim1] = 0.;
8761
/* L10: */
8762
}
8763
/* L20: */
8764
}
8765
} else {
8766
i__1 = *n;
8767
for (j = 1; j <= i__1; ++j) {
8768
i__2 = j;
8769
for (i__ = 1; i__ <= i__2; ++i__) {
8770
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
8771
/* L30: */
8772
}
8773
/* L40: */
8774
}
8775
}
8776
} else {
8777
if (*beta == 0.) {
8778
i__1 = *n;
8779
for (j = 1; j <= i__1; ++j) {
8780
i__2 = *n;
8781
for (i__ = j; i__ <= i__2; ++i__) {
8782
c__[i__ + j * c_dim1] = 0.;
8783
/* L50: */
8784
}
8785
/* L60: */
8786
}
8787
} else {
8788
i__1 = *n;
8789
for (j = 1; j <= i__1; ++j) {
8790
i__2 = *n;
8791
for (i__ = j; i__ <= i__2; ++i__) {
8792
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
8793
/* L70: */
8794
}
8795
/* L80: */
8796
}
8797
}
8798
}
8799
return 0;
8800
}
8801
8802
/* Start the operations. */
8803
8804
if (lsame_(trans, "N")) {
8805
8806
/* Form C := alpha*A*B' + alpha*B*A' + C. */
8807
8808
if (upper) {
8809
i__1 = *n;
8810
for (j = 1; j <= i__1; ++j) {
8811
if (*beta == 0.) {
8812
i__2 = j;
8813
for (i__ = 1; i__ <= i__2; ++i__) {
8814
c__[i__ + j * c_dim1] = 0.;
8815
/* L90: */
8816
}
8817
} else if (*beta != 1.) {
8818
i__2 = j;
8819
for (i__ = 1; i__ <= i__2; ++i__) {
8820
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
8821
/* L100: */
8822
}
8823
}
8824
i__2 = *k;
8825
for (l = 1; l <= i__2; ++l) {
8826
if (a[j + l * a_dim1] != 0. || b[j + l * b_dim1] != 0.) {
8827
temp1 = *alpha * b[j + l * b_dim1];
8828
temp2 = *alpha * a[j + l * a_dim1];
8829
i__3 = j;
8830
for (i__ = 1; i__ <= i__3; ++i__) {
8831
c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
8832
i__ + l * a_dim1] * temp1 + b[i__ + l *
8833
b_dim1] * temp2;
8834
/* L110: */
8835
}
8836
}
8837
/* L120: */
8838
}
8839
/* L130: */
8840
}
8841
} else {
8842
i__1 = *n;
8843
for (j = 1; j <= i__1; ++j) {
8844
if (*beta == 0.) {
8845
i__2 = *n;
8846
for (i__ = j; i__ <= i__2; ++i__) {
8847
c__[i__ + j * c_dim1] = 0.;
8848
/* L140: */
8849
}
8850
} else if (*beta != 1.) {
8851
i__2 = *n;
8852
for (i__ = j; i__ <= i__2; ++i__) {
8853
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
8854
/* L150: */
8855
}
8856
}
8857
i__2 = *k;
8858
for (l = 1; l <= i__2; ++l) {
8859
if (a[j + l * a_dim1] != 0. || b[j + l * b_dim1] != 0.) {
8860
temp1 = *alpha * b[j + l * b_dim1];
8861
temp2 = *alpha * a[j + l * a_dim1];
8862
i__3 = *n;
8863
for (i__ = j; i__ <= i__3; ++i__) {
8864
c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
8865
i__ + l * a_dim1] * temp1 + b[i__ + l *
8866
b_dim1] * temp2;
8867
/* L160: */
8868
}
8869
}
8870
/* L170: */
8871
}
8872
/* L180: */
8873
}
8874
}
8875
} else {
8876
8877
/* Form C := alpha*A'*B + alpha*B'*A + C. */
8878
8879
if (upper) {
8880
i__1 = *n;
8881
for (j = 1; j <= i__1; ++j) {
8882
i__2 = j;
8883
for (i__ = 1; i__ <= i__2; ++i__) {
8884
temp1 = 0.;
8885
temp2 = 0.;
8886
i__3 = *k;
8887
for (l = 1; l <= i__3; ++l) {
8888
temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
8889
temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
8890
/* L190: */
8891
}
8892
if (*beta == 0.) {
8893
c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
8894
temp2;
8895
} else {
8896
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
8897
+ *alpha * temp1 + *alpha * temp2;
8898
}
8899
/* L200: */
8900
}
8901
/* L210: */
8902
}
8903
} else {
8904
i__1 = *n;
8905
for (j = 1; j <= i__1; ++j) {
8906
i__2 = *n;
8907
for (i__ = j; i__ <= i__2; ++i__) {
8908
temp1 = 0.;
8909
temp2 = 0.;
8910
i__3 = *k;
8911
for (l = 1; l <= i__3; ++l) {
8912
temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
8913
temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
8914
/* L220: */
8915
}
8916
if (*beta == 0.) {
8917
c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
8918
temp2;
8919
} else {
8920
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
8921
+ *alpha * temp1 + *alpha * temp2;
8922
}
8923
/* L230: */
8924
}
8925
/* L240: */
8926
}
8927
}
8928
}
8929
8930
return 0;
8931
8932
/* End of DSYR2K. */
8933
8934
} /* dsyr2k_ */
8935
8936
/* Subroutine */ int dsyrk_(char *uplo, char *trans, integer *n, integer *k,
8937
doublereal *alpha, doublereal *a, integer *lda, doublereal *beta,
8938
doublereal *c__, integer *ldc)
8939
{
8940
/* System generated locals */
8941
integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3;
8942
8943
/* Local variables */
8944
static integer i__, j, l, info;
8945
static doublereal temp;
8946
extern logical lsame_(char *, char *);
8947
static integer nrowa;
8948
static logical upper;
8949
extern /* Subroutine */ int xerbla_(char *, integer *);
8950
8951
8952
/*
8953
Purpose
8954
=======
8955
8956
DSYRK performs one of the symmetric rank k operations
8957
8958
C := alpha*A*A' + beta*C,
8959
8960
or
8961
8962
C := alpha*A'*A + beta*C,
8963
8964
where alpha and beta are scalars, C is an n by n symmetric matrix
8965
and A is an n by k matrix in the first case and a k by n matrix
8966
in the second case.
8967
8968
Arguments
8969
==========
8970
8971
UPLO - CHARACTER*1.
8972
On entry, UPLO specifies whether the upper or lower
8973
triangular part of the array C is to be referenced as
8974
follows:
8975
8976
UPLO = 'U' or 'u' Only the upper triangular part of C
8977
is to be referenced.
8978
8979
UPLO = 'L' or 'l' Only the lower triangular part of C
8980
is to be referenced.
8981
8982
Unchanged on exit.
8983
8984
TRANS - CHARACTER*1.
8985
On entry, TRANS specifies the operation to be performed as
8986
follows:
8987
8988
TRANS = 'N' or 'n' C := alpha*A*A' + beta*C.
8989
8990
TRANS = 'T' or 't' C := alpha*A'*A + beta*C.
8991
8992
TRANS = 'C' or 'c' C := alpha*A'*A + beta*C.
8993
8994
Unchanged on exit.
8995
8996
N - INTEGER.
8997
On entry, N specifies the order of the matrix C. N must be
8998
at least zero.
8999
Unchanged on exit.
9000
9001
K - INTEGER.
9002
On entry with TRANS = 'N' or 'n', K specifies the number
9003
of columns of the matrix A, and on entry with
9004
TRANS = 'T' or 't' or 'C' or 'c', K specifies the number
9005
of rows of the matrix A. K must be at least zero.
9006
Unchanged on exit.
9007
9008
ALPHA - DOUBLE PRECISION.
9009
On entry, ALPHA specifies the scalar alpha.
9010
Unchanged on exit.
9011
9012
A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is
9013
k when TRANS = 'N' or 'n', and is n otherwise.
9014
Before entry with TRANS = 'N' or 'n', the leading n by k
9015
part of the array A must contain the matrix A, otherwise
9016
the leading k by n part of the array A must contain the
9017
matrix A.
9018
Unchanged on exit.
9019
9020
LDA - INTEGER.
9021
On entry, LDA specifies the first dimension of A as declared
9022
in the calling (sub) program. When TRANS = 'N' or 'n'
9023
then LDA must be at least max( 1, n ), otherwise LDA must
9024
be at least max( 1, k ).
9025
Unchanged on exit.
9026
9027
BETA - DOUBLE PRECISION.
9028
On entry, BETA specifies the scalar beta.
9029
Unchanged on exit.
9030
9031
C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
9032
Before entry with UPLO = 'U' or 'u', the leading n by n
9033
upper triangular part of the array C must contain the upper
9034
triangular part of the symmetric matrix and the strictly
9035
lower triangular part of C is not referenced. On exit, the
9036
upper triangular part of the array C is overwritten by the
9037
upper triangular part of the updated matrix.
9038
Before entry with UPLO = 'L' or 'l', the leading n by n
9039
lower triangular part of the array C must contain the lower
9040
triangular part of the symmetric matrix and the strictly
9041
upper triangular part of C is not referenced. On exit, the
9042
lower triangular part of the array C is overwritten by the
9043
lower triangular part of the updated matrix.
9044
9045
LDC - INTEGER.
9046
On entry, LDC specifies the first dimension of C as declared
9047
in the calling (sub) program. LDC must be at least
9048
max( 1, n ).
9049
Unchanged on exit.
9050
9051
Further Details
9052
===============
9053
9054
Level 3 Blas routine.
9055
9056
-- Written on 8-February-1989.
9057
Jack Dongarra, Argonne National Laboratory.
9058
Iain Duff, AERE Harwell.
9059
Jeremy Du Croz, Numerical Algorithms Group Ltd.
9060
Sven Hammarling, Numerical Algorithms Group Ltd.
9061
9062
=====================================================================
9063
9064
9065
Test the input parameters.
9066
*/
9067
9068
/* Parameter adjustments */
9069
a_dim1 = *lda;
9070
a_offset = 1 + a_dim1;
9071
a -= a_offset;
9072
c_dim1 = *ldc;
9073
c_offset = 1 + c_dim1;
9074
c__ -= c_offset;
9075
9076
/* Function Body */
9077
if (lsame_(trans, "N")) {
9078
nrowa = *n;
9079
} else {
9080
nrowa = *k;
9081
}
9082
upper = lsame_(uplo, "U");
9083
9084
info = 0;
9085
if (! upper && ! lsame_(uplo, "L")) {
9086
info = 1;
9087
} else if (! lsame_(trans, "N") && ! lsame_(trans,
9088
"T") && ! lsame_(trans, "C")) {
9089
info = 2;
9090
} else if (*n < 0) {
9091
info = 3;
9092
} else if (*k < 0) {
9093
info = 4;
9094
} else if (*lda < max(1,nrowa)) {
9095
info = 7;
9096
} else if (*ldc < max(1,*n)) {
9097
info = 10;
9098
}
9099
if (info != 0) {
9100
xerbla_("DSYRK ", &info);
9101
return 0;
9102
}
9103
9104
/* Quick return if possible. */
9105
9106
if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
9107
return 0;
9108
}
9109
9110
/* And when alpha.eq.zero. */
9111
9112
if (*alpha == 0.) {
9113
if (upper) {
9114
if (*beta == 0.) {
9115
i__1 = *n;
9116
for (j = 1; j <= i__1; ++j) {
9117
i__2 = j;
9118
for (i__ = 1; i__ <= i__2; ++i__) {
9119
c__[i__ + j * c_dim1] = 0.;
9120
/* L10: */
9121
}
9122
/* L20: */
9123
}
9124
} else {
9125
i__1 = *n;
9126
for (j = 1; j <= i__1; ++j) {
9127
i__2 = j;
9128
for (i__ = 1; i__ <= i__2; ++i__) {
9129
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
9130
/* L30: */
9131
}
9132
/* L40: */
9133
}
9134
}
9135
} else {
9136
if (*beta == 0.) {
9137
i__1 = *n;
9138
for (j = 1; j <= i__1; ++j) {
9139
i__2 = *n;
9140
for (i__ = j; i__ <= i__2; ++i__) {
9141
c__[i__ + j * c_dim1] = 0.;
9142
/* L50: */
9143
}
9144
/* L60: */
9145
}
9146
} else {
9147
i__1 = *n;
9148
for (j = 1; j <= i__1; ++j) {
9149
i__2 = *n;
9150
for (i__ = j; i__ <= i__2; ++i__) {
9151
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
9152
/* L70: */
9153
}
9154
/* L80: */
9155
}
9156
}
9157
}
9158
return 0;
9159
}
9160
9161
/* Start the operations. */
9162
9163
if (lsame_(trans, "N")) {
9164
9165
/* Form C := alpha*A*A' + beta*C. */
9166
9167
if (upper) {
9168
i__1 = *n;
9169
for (j = 1; j <= i__1; ++j) {
9170
if (*beta == 0.) {
9171
i__2 = j;
9172
for (i__ = 1; i__ <= i__2; ++i__) {
9173
c__[i__ + j * c_dim1] = 0.;
9174
/* L90: */
9175
}
9176
} else if (*beta != 1.) {
9177
i__2 = j;
9178
for (i__ = 1; i__ <= i__2; ++i__) {
9179
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
9180
/* L100: */
9181
}
9182
}
9183
i__2 = *k;
9184
for (l = 1; l <= i__2; ++l) {
9185
if (a[j + l * a_dim1] != 0.) {
9186
temp = *alpha * a[j + l * a_dim1];
9187
i__3 = j;
9188
for (i__ = 1; i__ <= i__3; ++i__) {
9189
c__[i__ + j * c_dim1] += temp * a[i__ + l *
9190
a_dim1];
9191
/* L110: */
9192
}
9193
}
9194
/* L120: */
9195
}
9196
/* L130: */
9197
}
9198
} else {
9199
i__1 = *n;
9200
for (j = 1; j <= i__1; ++j) {
9201
if (*beta == 0.) {
9202
i__2 = *n;
9203
for (i__ = j; i__ <= i__2; ++i__) {
9204
c__[i__ + j * c_dim1] = 0.;
9205
/* L140: */
9206
}
9207
} else if (*beta != 1.) {
9208
i__2 = *n;
9209
for (i__ = j; i__ <= i__2; ++i__) {
9210
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
9211
/* L150: */
9212
}
9213
}
9214
i__2 = *k;
9215
for (l = 1; l <= i__2; ++l) {
9216
if (a[j + l * a_dim1] != 0.) {
9217
temp = *alpha * a[j + l * a_dim1];
9218
i__3 = *n;
9219
for (i__ = j; i__ <= i__3; ++i__) {
9220
c__[i__ + j * c_dim1] += temp * a[i__ + l *
9221
a_dim1];
9222
/* L160: */
9223
}
9224
}
9225
/* L170: */
9226
}
9227
/* L180: */
9228
}
9229
}
9230
} else {
9231
9232
/* Form C := alpha*A'*A + beta*C. */
9233
9234
if (upper) {
9235
i__1 = *n;
9236
for (j = 1; j <= i__1; ++j) {
9237
i__2 = j;
9238
for (i__ = 1; i__ <= i__2; ++i__) {
9239
temp = 0.;
9240
i__3 = *k;
9241
for (l = 1; l <= i__3; ++l) {
9242
temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
9243
/* L190: */
9244
}
9245
if (*beta == 0.) {
9246
c__[i__ + j * c_dim1] = *alpha * temp;
9247
} else {
9248
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
9249
i__ + j * c_dim1];
9250
}
9251
/* L200: */
9252
}
9253
/* L210: */
9254
}
9255
} else {
9256
i__1 = *n;
9257
for (j = 1; j <= i__1; ++j) {
9258
i__2 = *n;
9259
for (i__ = j; i__ <= i__2; ++i__) {
9260
temp = 0.;
9261
i__3 = *k;
9262
for (l = 1; l <= i__3; ++l) {
9263
temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
9264
/* L220: */
9265
}
9266
if (*beta == 0.) {
9267
c__[i__ + j * c_dim1] = *alpha * temp;
9268
} else {
9269
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
9270
i__ + j * c_dim1];
9271
}
9272
/* L230: */
9273
}
9274
/* L240: */
9275
}
9276
}
9277
}
9278
9279
return 0;
9280
9281
/* End of DSYRK . */
9282
9283
} /* dsyrk_ */
9284
9285
/* Subroutine */ int dtrmm_(char *side, char *uplo, char *transa, char *diag,
9286
integer *m, integer *n, doublereal *alpha, doublereal *a, integer *
9287
lda, doublereal *b, integer *ldb)
9288
{
9289
/* System generated locals */
9290
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
9291
9292
/* Local variables */
9293
static integer i__, j, k, info;
9294
static doublereal temp;
9295
static logical lside;
9296
extern logical lsame_(char *, char *);
9297
static integer nrowa;
9298
static logical upper;
9299
extern /* Subroutine */ int xerbla_(char *, integer *);
9300
static logical nounit;
9301
9302
9303
/*
9304
Purpose
9305
=======
9306
9307
DTRMM performs one of the matrix-matrix operations
9308
9309
B := alpha*op( A )*B, or B := alpha*B*op( A ),
9310
9311
where alpha is a scalar, B is an m by n matrix, A is a unit, or
9312
non-unit, upper or lower triangular matrix and op( A ) is one of
9313
9314
op( A ) = A or op( A ) = A'.
9315
9316
Arguments
9317
==========
9318
9319
SIDE - CHARACTER*1.
9320
On entry, SIDE specifies whether op( A ) multiplies B from
9321
the left or right as follows:
9322
9323
SIDE = 'L' or 'l' B := alpha*op( A )*B.
9324
9325
SIDE = 'R' or 'r' B := alpha*B*op( A ).
9326
9327
Unchanged on exit.
9328
9329
UPLO - CHARACTER*1.
9330
On entry, UPLO specifies whether the matrix A is an upper or
9331
lower triangular matrix as follows:
9332
9333
UPLO = 'U' or 'u' A is an upper triangular matrix.
9334
9335
UPLO = 'L' or 'l' A is a lower triangular matrix.
9336
9337
Unchanged on exit.
9338
9339
TRANSA - CHARACTER*1.
9340
On entry, TRANSA specifies the form of op( A ) to be used in
9341
the matrix multiplication as follows:
9342
9343
TRANSA = 'N' or 'n' op( A ) = A.
9344
9345
TRANSA = 'T' or 't' op( A ) = A'.
9346
9347
TRANSA = 'C' or 'c' op( A ) = A'.
9348
9349
Unchanged on exit.
9350
9351
DIAG - CHARACTER*1.
9352
On entry, DIAG specifies whether or not A is unit triangular
9353
as follows:
9354
9355
DIAG = 'U' or 'u' A is assumed to be unit triangular.
9356
9357
DIAG = 'N' or 'n' A is not assumed to be unit
9358
triangular.
9359
9360
Unchanged on exit.
9361
9362
M - INTEGER.
9363
On entry, M specifies the number of rows of B. M must be at
9364
least zero.
9365
Unchanged on exit.
9366
9367
N - INTEGER.
9368
On entry, N specifies the number of columns of B. N must be
9369
at least zero.
9370
Unchanged on exit.
9371
9372
ALPHA - DOUBLE PRECISION.
9373
On entry, ALPHA specifies the scalar alpha. When alpha is
9374
zero then A is not referenced and B need not be set before
9375
entry.
9376
Unchanged on exit.
9377
9378
A - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m
9379
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
9380
Before entry with UPLO = 'U' or 'u', the leading k by k
9381
upper triangular part of the array A must contain the upper
9382
triangular matrix and the strictly lower triangular part of
9383
A is not referenced.
9384
Before entry with UPLO = 'L' or 'l', the leading k by k
9385
lower triangular part of the array A must contain the lower
9386
triangular matrix and the strictly upper triangular part of
9387
A is not referenced.
9388
Note that when DIAG = 'U' or 'u', the diagonal elements of
9389
A are not referenced either, but are assumed to be unity.
9390
Unchanged on exit.
9391
9392
LDA - INTEGER.
9393
On entry, LDA specifies the first dimension of A as declared
9394
in the calling (sub) program. When SIDE = 'L' or 'l' then
9395
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
9396
then LDA must be at least max( 1, n ).
9397
Unchanged on exit.
9398
9399
B - DOUBLE PRECISION array of DIMENSION ( LDB, n ).
9400
Before entry, the leading m by n part of the array B must
9401
contain the matrix B, and on exit is overwritten by the
9402
transformed matrix.
9403
9404
LDB - INTEGER.
9405
On entry, LDB specifies the first dimension of B as declared
9406
in the calling (sub) program. LDB must be at least
9407
max( 1, m ).
9408
Unchanged on exit.
9409
9410
Further Details
9411
===============
9412
9413
Level 3 Blas routine.
9414
9415
-- Written on 8-February-1989.
9416
Jack Dongarra, Argonne National Laboratory.
9417
Iain Duff, AERE Harwell.
9418
Jeremy Du Croz, Numerical Algorithms Group Ltd.
9419
Sven Hammarling, Numerical Algorithms Group Ltd.
9420
9421
=====================================================================
9422
9423
9424
Test the input parameters.
9425
*/
9426
9427
/* Parameter adjustments */
9428
a_dim1 = *lda;
9429
a_offset = 1 + a_dim1;
9430
a -= a_offset;
9431
b_dim1 = *ldb;
9432
b_offset = 1 + b_dim1;
9433
b -= b_offset;
9434
9435
/* Function Body */
9436
lside = lsame_(side, "L");
9437
if (lside) {
9438
nrowa = *m;
9439
} else {
9440
nrowa = *n;
9441
}
9442
nounit = lsame_(diag, "N");
9443
upper = lsame_(uplo, "U");
9444
9445
info = 0;
9446
if (! lside && ! lsame_(side, "R")) {
9447
info = 1;
9448
} else if (! upper && ! lsame_(uplo, "L")) {
9449
info = 2;
9450
} else if (! lsame_(transa, "N") && ! lsame_(transa,
9451
"T") && ! lsame_(transa, "C")) {
9452
info = 3;
9453
} else if (! lsame_(diag, "U") && ! lsame_(diag,
9454
"N")) {
9455
info = 4;
9456
} else if (*m < 0) {
9457
info = 5;
9458
} else if (*n < 0) {
9459
info = 6;
9460
} else if (*lda < max(1,nrowa)) {
9461
info = 9;
9462
} else if (*ldb < max(1,*m)) {
9463
info = 11;
9464
}
9465
if (info != 0) {
9466
xerbla_("DTRMM ", &info);
9467
return 0;
9468
}
9469
9470
/* Quick return if possible. */
9471
9472
if (*m == 0 || *n == 0) {
9473
return 0;
9474
}
9475
9476
/* And when alpha.eq.zero. */
9477
9478
if (*alpha == 0.) {
9479
i__1 = *n;
9480
for (j = 1; j <= i__1; ++j) {
9481
i__2 = *m;
9482
for (i__ = 1; i__ <= i__2; ++i__) {
9483
b[i__ + j * b_dim1] = 0.;
9484
/* L10: */
9485
}
9486
/* L20: */
9487
}
9488
return 0;
9489
}
9490
9491
/* Start the operations. */
9492
9493
if (lside) {
9494
if (lsame_(transa, "N")) {
9495
9496
/* Form B := alpha*A*B. */
9497
9498
if (upper) {
9499
i__1 = *n;
9500
for (j = 1; j <= i__1; ++j) {
9501
i__2 = *m;
9502
for (k = 1; k <= i__2; ++k) {
9503
if (b[k + j * b_dim1] != 0.) {
9504
temp = *alpha * b[k + j * b_dim1];
9505
i__3 = k - 1;
9506
for (i__ = 1; i__ <= i__3; ++i__) {
9507
b[i__ + j * b_dim1] += temp * a[i__ + k *
9508
a_dim1];
9509
/* L30: */
9510
}
9511
if (nounit) {
9512
temp *= a[k + k * a_dim1];
9513
}
9514
b[k + j * b_dim1] = temp;
9515
}
9516
/* L40: */
9517
}
9518
/* L50: */
9519
}
9520
} else {
9521
i__1 = *n;
9522
for (j = 1; j <= i__1; ++j) {
9523
for (k = *m; k >= 1; --k) {
9524
if (b[k + j * b_dim1] != 0.) {
9525
temp = *alpha * b[k + j * b_dim1];
9526
b[k + j * b_dim1] = temp;
9527
if (nounit) {
9528
b[k + j * b_dim1] *= a[k + k * a_dim1];
9529
}
9530
i__2 = *m;
9531
for (i__ = k + 1; i__ <= i__2; ++i__) {
9532
b[i__ + j * b_dim1] += temp * a[i__ + k *
9533
a_dim1];
9534
/* L60: */
9535
}
9536
}
9537
/* L70: */
9538
}
9539
/* L80: */
9540
}
9541
}
9542
} else {
9543
9544
/* Form B := alpha*A'*B. */
9545
9546
if (upper) {
9547
i__1 = *n;
9548
for (j = 1; j <= i__1; ++j) {
9549
for (i__ = *m; i__ >= 1; --i__) {
9550
temp = b[i__ + j * b_dim1];
9551
if (nounit) {
9552
temp *= a[i__ + i__ * a_dim1];
9553
}
9554
i__2 = i__ - 1;
9555
for (k = 1; k <= i__2; ++k) {
9556
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
9557
/* L90: */
9558
}
9559
b[i__ + j * b_dim1] = *alpha * temp;
9560
/* L100: */
9561
}
9562
/* L110: */
9563
}
9564
} else {
9565
i__1 = *n;
9566
for (j = 1; j <= i__1; ++j) {
9567
i__2 = *m;
9568
for (i__ = 1; i__ <= i__2; ++i__) {
9569
temp = b[i__ + j * b_dim1];
9570
if (nounit) {
9571
temp *= a[i__ + i__ * a_dim1];
9572
}
9573
i__3 = *m;
9574
for (k = i__ + 1; k <= i__3; ++k) {
9575
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
9576
/* L120: */
9577
}
9578
b[i__ + j * b_dim1] = *alpha * temp;
9579
/* L130: */
9580
}
9581
/* L140: */
9582
}
9583
}
9584
}
9585
} else {
9586
if (lsame_(transa, "N")) {
9587
9588
/* Form B := alpha*B*A. */
9589
9590
if (upper) {
9591
for (j = *n; j >= 1; --j) {
9592
temp = *alpha;
9593
if (nounit) {
9594
temp *= a[j + j * a_dim1];
9595
}
9596
i__1 = *m;
9597
for (i__ = 1; i__ <= i__1; ++i__) {
9598
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
9599
/* L150: */
9600
}
9601
i__1 = j - 1;
9602
for (k = 1; k <= i__1; ++k) {
9603
if (a[k + j * a_dim1] != 0.) {
9604
temp = *alpha * a[k + j * a_dim1];
9605
i__2 = *m;
9606
for (i__ = 1; i__ <= i__2; ++i__) {
9607
b[i__ + j * b_dim1] += temp * b[i__ + k *
9608
b_dim1];
9609
/* L160: */
9610
}
9611
}
9612
/* L170: */
9613
}
9614
/* L180: */
9615
}
9616
} else {
9617
i__1 = *n;
9618
for (j = 1; j <= i__1; ++j) {
9619
temp = *alpha;
9620
if (nounit) {
9621
temp *= a[j + j * a_dim1];
9622
}
9623
i__2 = *m;
9624
for (i__ = 1; i__ <= i__2; ++i__) {
9625
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
9626
/* L190: */
9627
}
9628
i__2 = *n;
9629
for (k = j + 1; k <= i__2; ++k) {
9630
if (a[k + j * a_dim1] != 0.) {
9631
temp = *alpha * a[k + j * a_dim1];
9632
i__3 = *m;
9633
for (i__ = 1; i__ <= i__3; ++i__) {
9634
b[i__ + j * b_dim1] += temp * b[i__ + k *
9635
b_dim1];
9636
/* L200: */
9637
}
9638
}
9639
/* L210: */
9640
}
9641
/* L220: */
9642
}
9643
}
9644
} else {
9645
9646
/* Form B := alpha*B*A'. */
9647
9648
if (upper) {
9649
i__1 = *n;
9650
for (k = 1; k <= i__1; ++k) {
9651
i__2 = k - 1;
9652
for (j = 1; j <= i__2; ++j) {
9653
if (a[j + k * a_dim1] != 0.) {
9654
temp = *alpha * a[j + k * a_dim1];
9655
i__3 = *m;
9656
for (i__ = 1; i__ <= i__3; ++i__) {
9657
b[i__ + j * b_dim1] += temp * b[i__ + k *
9658
b_dim1];
9659
/* L230: */
9660
}
9661
}
9662
/* L240: */
9663
}
9664
temp = *alpha;
9665
if (nounit) {
9666
temp *= a[k + k * a_dim1];
9667
}
9668
if (temp != 1.) {
9669
i__2 = *m;
9670
for (i__ = 1; i__ <= i__2; ++i__) {
9671
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
9672
/* L250: */
9673
}
9674
}
9675
/* L260: */
9676
}
9677
} else {
9678
for (k = *n; k >= 1; --k) {
9679
i__1 = *n;
9680
for (j = k + 1; j <= i__1; ++j) {
9681
if (a[j + k * a_dim1] != 0.) {
9682
temp = *alpha * a[j + k * a_dim1];
9683
i__2 = *m;
9684
for (i__ = 1; i__ <= i__2; ++i__) {
9685
b[i__ + j * b_dim1] += temp * b[i__ + k *
9686
b_dim1];
9687
/* L270: */
9688
}
9689
}
9690
/* L280: */
9691
}
9692
temp = *alpha;
9693
if (nounit) {
9694
temp *= a[k + k * a_dim1];
9695
}
9696
if (temp != 1.) {
9697
i__1 = *m;
9698
for (i__ = 1; i__ <= i__1; ++i__) {
9699
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
9700
/* L290: */
9701
}
9702
}
9703
/* L300: */
9704
}
9705
}
9706
}
9707
}
9708
9709
return 0;
9710
9711
/* End of DTRMM . */
9712
9713
} /* dtrmm_ */
9714
9715
/* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, integer *n,
9716
doublereal *a, integer *lda, doublereal *x, integer *incx)
9717
{
9718
/* System generated locals */
9719
integer a_dim1, a_offset, i__1, i__2;
9720
9721
/* Local variables */
9722
static integer i__, j, ix, jx, kx, info;
9723
static doublereal temp;
9724
extern logical lsame_(char *, char *);
9725
extern /* Subroutine */ int xerbla_(char *, integer *);
9726
static logical nounit;
9727
9728
9729
/*
9730
Purpose
9731
=======
9732
9733
DTRMV performs one of the matrix-vector operations
9734
9735
x := A*x, or x := A'*x,
9736
9737
where x is an n element vector and A is an n by n unit, or non-unit,
9738
upper or lower triangular matrix.
9739
9740
Arguments
9741
==========
9742
9743
UPLO - CHARACTER*1.
9744
On entry, UPLO specifies whether the matrix is an upper or
9745
lower triangular matrix as follows:
9746
9747
UPLO = 'U' or 'u' A is an upper triangular matrix.
9748
9749
UPLO = 'L' or 'l' A is a lower triangular matrix.
9750
9751
Unchanged on exit.
9752
9753
TRANS - CHARACTER*1.
9754
On entry, TRANS specifies the operation to be performed as
9755
follows:
9756
9757
TRANS = 'N' or 'n' x := A*x.
9758
9759
TRANS = 'T' or 't' x := A'*x.
9760
9761
TRANS = 'C' or 'c' x := A'*x.
9762
9763
Unchanged on exit.
9764
9765
DIAG - CHARACTER*1.
9766
On entry, DIAG specifies whether or not A is unit
9767
triangular as follows:
9768
9769
DIAG = 'U' or 'u' A is assumed to be unit triangular.
9770
9771
DIAG = 'N' or 'n' A is not assumed to be unit
9772
triangular.
9773
9774
Unchanged on exit.
9775
9776
N - INTEGER.
9777
On entry, N specifies the order of the matrix A.
9778
N must be at least zero.
9779
Unchanged on exit.
9780
9781
A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
9782
Before entry with UPLO = 'U' or 'u', the leading n by n
9783
upper triangular part of the array A must contain the upper
9784
triangular matrix and the strictly lower triangular part of
9785
A is not referenced.
9786
Before entry with UPLO = 'L' or 'l', the leading n by n
9787
lower triangular part of the array A must contain the lower
9788
triangular matrix and the strictly upper triangular part of
9789
A is not referenced.
9790
Note that when DIAG = 'U' or 'u', the diagonal elements of
9791
A are not referenced either, but are assumed to be unity.
9792
Unchanged on exit.
9793
9794
LDA - INTEGER.
9795
On entry, LDA specifies the first dimension of A as declared
9796
in the calling (sub) program. LDA must be at least
9797
max( 1, n ).
9798
Unchanged on exit.
9799
9800
X - DOUBLE PRECISION array of dimension at least
9801
( 1 + ( n - 1 )*abs( INCX ) ).
9802
Before entry, the incremented array X must contain the n
9803
element vector x. On exit, X is overwritten with the
9804
tranformed vector x.
9805
9806
INCX - INTEGER.
9807
On entry, INCX specifies the increment for the elements of
9808
X. INCX must not be zero.
9809
Unchanged on exit.
9810
9811
Further Details
9812
===============
9813
9814
Level 2 Blas routine.
9815
9816
-- Written on 22-October-1986.
9817
Jack Dongarra, Argonne National Lab.
9818
Jeremy Du Croz, Nag Central Office.
9819
Sven Hammarling, Nag Central Office.
9820
Richard Hanson, Sandia National Labs.
9821
9822
=====================================================================
9823
9824
9825
Test the input parameters.
9826
*/
9827
9828
/* Parameter adjustments */
9829
a_dim1 = *lda;
9830
a_offset = 1 + a_dim1;
9831
a -= a_offset;
9832
--x;
9833
9834
/* Function Body */
9835
info = 0;
9836
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
9837
info = 1;
9838
} else if (! lsame_(trans, "N") && ! lsame_(trans,
9839
"T") && ! lsame_(trans, "C")) {
9840
info = 2;
9841
} else if (! lsame_(diag, "U") && ! lsame_(diag,
9842
"N")) {
9843
info = 3;
9844
} else if (*n < 0) {
9845
info = 4;
9846
} else if (*lda < max(1,*n)) {
9847
info = 6;
9848
} else if (*incx == 0) {
9849
info = 8;
9850
}
9851
if (info != 0) {
9852
xerbla_("DTRMV ", &info);
9853
return 0;
9854
}
9855
9856
/* Quick return if possible. */
9857
9858
if (*n == 0) {
9859
return 0;
9860
}
9861
9862
nounit = lsame_(diag, "N");
9863
9864
/*
9865
Set up the start point in X if the increment is not unity. This
9866
will be ( N - 1 )*INCX too small for descending loops.
9867
*/
9868
9869
if (*incx <= 0) {
9870
kx = 1 - (*n - 1) * *incx;
9871
} else if (*incx != 1) {
9872
kx = 1;
9873
}
9874
9875
/*
9876
Start the operations. In this version the elements of A are
9877
accessed sequentially with one pass through A.
9878
*/
9879
9880
if (lsame_(trans, "N")) {
9881
9882
/* Form x := A*x. */
9883
9884
if (lsame_(uplo, "U")) {
9885
if (*incx == 1) {
9886
i__1 = *n;
9887
for (j = 1; j <= i__1; ++j) {
9888
if (x[j] != 0.) {
9889
temp = x[j];
9890
i__2 = j - 1;
9891
for (i__ = 1; i__ <= i__2; ++i__) {
9892
x[i__] += temp * a[i__ + j * a_dim1];
9893
/* L10: */
9894
}
9895
if (nounit) {
9896
x[j] *= a[j + j * a_dim1];
9897
}
9898
}
9899
/* L20: */
9900
}
9901
} else {
9902
jx = kx;
9903
i__1 = *n;
9904
for (j = 1; j <= i__1; ++j) {
9905
if (x[jx] != 0.) {
9906
temp = x[jx];
9907
ix = kx;
9908
i__2 = j - 1;
9909
for (i__ = 1; i__ <= i__2; ++i__) {
9910
x[ix] += temp * a[i__ + j * a_dim1];
9911
ix += *incx;
9912
/* L30: */
9913
}
9914
if (nounit) {
9915
x[jx] *= a[j + j * a_dim1];
9916
}
9917
}
9918
jx += *incx;
9919
/* L40: */
9920
}
9921
}
9922
} else {
9923
if (*incx == 1) {
9924
for (j = *n; j >= 1; --j) {
9925
if (x[j] != 0.) {
9926
temp = x[j];
9927
i__1 = j + 1;
9928
for (i__ = *n; i__ >= i__1; --i__) {
9929
x[i__] += temp * a[i__ + j * a_dim1];
9930
/* L50: */
9931
}
9932
if (nounit) {
9933
x[j] *= a[j + j * a_dim1];
9934
}
9935
}
9936
/* L60: */
9937
}
9938
} else {
9939
kx += (*n - 1) * *incx;
9940
jx = kx;
9941
for (j = *n; j >= 1; --j) {
9942
if (x[jx] != 0.) {
9943
temp = x[jx];
9944
ix = kx;
9945
i__1 = j + 1;
9946
for (i__ = *n; i__ >= i__1; --i__) {
9947
x[ix] += temp * a[i__ + j * a_dim1];
9948
ix -= *incx;
9949
/* L70: */
9950
}
9951
if (nounit) {
9952
x[jx] *= a[j + j * a_dim1];
9953
}
9954
}
9955
jx -= *incx;
9956
/* L80: */
9957
}
9958
}
9959
}
9960
} else {
9961
9962
/* Form x := A'*x. */
9963
9964
if (lsame_(uplo, "U")) {
9965
if (*incx == 1) {
9966
for (j = *n; j >= 1; --j) {
9967
temp = x[j];
9968
if (nounit) {
9969
temp *= a[j + j * a_dim1];
9970
}
9971
for (i__ = j - 1; i__ >= 1; --i__) {
9972
temp += a[i__ + j * a_dim1] * x[i__];
9973
/* L90: */
9974
}
9975
x[j] = temp;
9976
/* L100: */
9977
}
9978
} else {
9979
jx = kx + (*n - 1) * *incx;
9980
for (j = *n; j >= 1; --j) {
9981
temp = x[jx];
9982
ix = jx;
9983
if (nounit) {
9984
temp *= a[j + j * a_dim1];
9985
}
9986
for (i__ = j - 1; i__ >= 1; --i__) {
9987
ix -= *incx;
9988
temp += a[i__ + j * a_dim1] * x[ix];
9989
/* L110: */
9990
}
9991
x[jx] = temp;
9992
jx -= *incx;
9993
/* L120: */
9994
}
9995
}
9996
} else {
9997
if (*incx == 1) {
9998
i__1 = *n;
9999
for (j = 1; j <= i__1; ++j) {
10000
temp = x[j];
10001
if (nounit) {
10002
temp *= a[j + j * a_dim1];
10003
}
10004
i__2 = *n;
10005
for (i__ = j + 1; i__ <= i__2; ++i__) {
10006
temp += a[i__ + j * a_dim1] * x[i__];
10007
/* L130: */
10008
}
10009
x[j] = temp;
10010
/* L140: */
10011
}
10012
} else {
10013
jx = kx;
10014
i__1 = *n;
10015
for (j = 1; j <= i__1; ++j) {
10016
temp = x[jx];
10017
ix = jx;
10018
if (nounit) {
10019
temp *= a[j + j * a_dim1];
10020
}
10021
i__2 = *n;
10022
for (i__ = j + 1; i__ <= i__2; ++i__) {
10023
ix += *incx;
10024
temp += a[i__ + j * a_dim1] * x[ix];
10025
/* L150: */
10026
}
10027
x[jx] = temp;
10028
jx += *incx;
10029
/* L160: */
10030
}
10031
}
10032
}
10033
}
10034
10035
return 0;
10036
10037
/* End of DTRMV . */
10038
10039
} /* dtrmv_ */
10040
10041
/* Subroutine */ int dtrsm_(char *side, char *uplo, char *transa, char *diag,
10042
integer *m, integer *n, doublereal *alpha, doublereal *a, integer *
10043
lda, doublereal *b, integer *ldb)
10044
{
10045
/* System generated locals */
10046
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
10047
10048
/* Local variables */
10049
static integer i__, j, k, info;
10050
static doublereal temp;
10051
static logical lside;
10052
extern logical lsame_(char *, char *);
10053
static integer nrowa;
10054
static logical upper;
10055
extern /* Subroutine */ int xerbla_(char *, integer *);
10056
static logical nounit;
10057
10058
10059
/*
10060
Purpose
10061
=======
10062
10063
DTRSM solves one of the matrix equations
10064
10065
op( A )*X = alpha*B, or X*op( A ) = alpha*B,
10066
10067
where alpha is a scalar, X and B are m by n matrices, A is a unit, or
10068
non-unit, upper or lower triangular matrix and op( A ) is one of
10069
10070
op( A ) = A or op( A ) = A'.
10071
10072
The matrix X is overwritten on B.
10073
10074
Arguments
10075
==========
10076
10077
SIDE - CHARACTER*1.
10078
On entry, SIDE specifies whether op( A ) appears on the left
10079
or right of X as follows:
10080
10081
SIDE = 'L' or 'l' op( A )*X = alpha*B.
10082
10083
SIDE = 'R' or 'r' X*op( A ) = alpha*B.
10084
10085
Unchanged on exit.
10086
10087
UPLO - CHARACTER*1.
10088
On entry, UPLO specifies whether the matrix A is an upper or
10089
lower triangular matrix as follows:
10090
10091
UPLO = 'U' or 'u' A is an upper triangular matrix.
10092
10093
UPLO = 'L' or 'l' A is a lower triangular matrix.
10094
10095
Unchanged on exit.
10096
10097
TRANSA - CHARACTER*1.
10098
On entry, TRANSA specifies the form of op( A ) to be used in
10099
the matrix multiplication as follows:
10100
10101
TRANSA = 'N' or 'n' op( A ) = A.
10102
10103
TRANSA = 'T' or 't' op( A ) = A'.
10104
10105
TRANSA = 'C' or 'c' op( A ) = A'.
10106
10107
Unchanged on exit.
10108
10109
DIAG - CHARACTER*1.
10110
On entry, DIAG specifies whether or not A is unit triangular
10111
as follows:
10112
10113
DIAG = 'U' or 'u' A is assumed to be unit triangular.
10114
10115
DIAG = 'N' or 'n' A is not assumed to be unit
10116
triangular.
10117
10118
Unchanged on exit.
10119
10120
M - INTEGER.
10121
On entry, M specifies the number of rows of B. M must be at
10122
least zero.
10123
Unchanged on exit.
10124
10125
N - INTEGER.
10126
On entry, N specifies the number of columns of B. N must be
10127
at least zero.
10128
Unchanged on exit.
10129
10130
ALPHA - DOUBLE PRECISION.
10131
On entry, ALPHA specifies the scalar alpha. When alpha is
10132
zero then A is not referenced and B need not be set before
10133
entry.
10134
Unchanged on exit.
10135
10136
A - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m
10137
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
10138
Before entry with UPLO = 'U' or 'u', the leading k by k
10139
upper triangular part of the array A must contain the upper
10140
triangular matrix and the strictly lower triangular part of
10141
A is not referenced.
10142
Before entry with UPLO = 'L' or 'l', the leading k by k
10143
lower triangular part of the array A must contain the lower
10144
triangular matrix and the strictly upper triangular part of
10145
A is not referenced.
10146
Note that when DIAG = 'U' or 'u', the diagonal elements of
10147
A are not referenced either, but are assumed to be unity.
10148
Unchanged on exit.
10149
10150
LDA - INTEGER.
10151
On entry, LDA specifies the first dimension of A as declared
10152
in the calling (sub) program. When SIDE = 'L' or 'l' then
10153
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
10154
then LDA must be at least max( 1, n ).
10155
Unchanged on exit.
10156
10157
B - DOUBLE PRECISION array of DIMENSION ( LDB, n ).
10158
Before entry, the leading m by n part of the array B must
10159
contain the right-hand side matrix B, and on exit is
10160
overwritten by the solution matrix X.
10161
10162
LDB - INTEGER.
10163
On entry, LDB specifies the first dimension of B as declared
10164
in the calling (sub) program. LDB must be at least
10165
max( 1, m ).
10166
Unchanged on exit.
10167
10168
Further Details
10169
===============
10170
10171
Level 3 Blas routine.
10172
10173
10174
-- Written on 8-February-1989.
10175
Jack Dongarra, Argonne National Laboratory.
10176
Iain Duff, AERE Harwell.
10177
Jeremy Du Croz, Numerical Algorithms Group Ltd.
10178
Sven Hammarling, Numerical Algorithms Group Ltd.
10179
10180
=====================================================================
10181
10182
10183
Test the input parameters.
10184
*/
10185
10186
/* Parameter adjustments */
10187
a_dim1 = *lda;
10188
a_offset = 1 + a_dim1;
10189
a -= a_offset;
10190
b_dim1 = *ldb;
10191
b_offset = 1 + b_dim1;
10192
b -= b_offset;
10193
10194
/* Function Body */
10195
lside = lsame_(side, "L");
10196
if (lside) {
10197
nrowa = *m;
10198
} else {
10199
nrowa = *n;
10200
}
10201
nounit = lsame_(diag, "N");
10202
upper = lsame_(uplo, "U");
10203
10204
info = 0;
10205
if (! lside && ! lsame_(side, "R")) {
10206
info = 1;
10207
} else if (! upper && ! lsame_(uplo, "L")) {
10208
info = 2;
10209
} else if (! lsame_(transa, "N") && ! lsame_(transa,
10210
"T") && ! lsame_(transa, "C")) {
10211
info = 3;
10212
} else if (! lsame_(diag, "U") && ! lsame_(diag,
10213
"N")) {
10214
info = 4;
10215
} else if (*m < 0) {
10216
info = 5;
10217
} else if (*n < 0) {
10218
info = 6;
10219
} else if (*lda < max(1,nrowa)) {
10220
info = 9;
10221
} else if (*ldb < max(1,*m)) {
10222
info = 11;
10223
}
10224
if (info != 0) {
10225
xerbla_("DTRSM ", &info);
10226
return 0;
10227
}
10228
10229
/* Quick return if possible. */
10230
10231
if (*m == 0 || *n == 0) {
10232
return 0;
10233
}
10234
10235
/* And when alpha.eq.zero. */
10236
10237
if (*alpha == 0.) {
10238
i__1 = *n;
10239
for (j = 1; j <= i__1; ++j) {
10240
i__2 = *m;
10241
for (i__ = 1; i__ <= i__2; ++i__) {
10242
b[i__ + j * b_dim1] = 0.;
10243
/* L10: */
10244
}
10245
/* L20: */
10246
}
10247
return 0;
10248
}
10249
10250
/* Start the operations. */
10251
10252
if (lside) {
10253
if (lsame_(transa, "N")) {
10254
10255
/* Form B := alpha*inv( A )*B. */
10256
10257
if (upper) {
10258
i__1 = *n;
10259
for (j = 1; j <= i__1; ++j) {
10260
if (*alpha != 1.) {
10261
i__2 = *m;
10262
for (i__ = 1; i__ <= i__2; ++i__) {
10263
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
10264
;
10265
/* L30: */
10266
}
10267
}
10268
for (k = *m; k >= 1; --k) {
10269
if (b[k + j * b_dim1] != 0.) {
10270
if (nounit) {
10271
b[k + j * b_dim1] /= a[k + k * a_dim1];
10272
}
10273
i__2 = k - 1;
10274
for (i__ = 1; i__ <= i__2; ++i__) {
10275
b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
10276
i__ + k * a_dim1];
10277
/* L40: */
10278
}
10279
}
10280
/* L50: */
10281
}
10282
/* L60: */
10283
}
10284
} else {
10285
i__1 = *n;
10286
for (j = 1; j <= i__1; ++j) {
10287
if (*alpha != 1.) {
10288
i__2 = *m;
10289
for (i__ = 1; i__ <= i__2; ++i__) {
10290
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
10291
;
10292
/* L70: */
10293
}
10294
}
10295
i__2 = *m;
10296
for (k = 1; k <= i__2; ++k) {
10297
if (b[k + j * b_dim1] != 0.) {
10298
if (nounit) {
10299
b[k + j * b_dim1] /= a[k + k * a_dim1];
10300
}
10301
i__3 = *m;
10302
for (i__ = k + 1; i__ <= i__3; ++i__) {
10303
b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
10304
i__ + k * a_dim1];
10305
/* L80: */
10306
}
10307
}
10308
/* L90: */
10309
}
10310
/* L100: */
10311
}
10312
}
10313
} else {
10314
10315
/* Form B := alpha*inv( A' )*B. */
10316
10317
if (upper) {
10318
i__1 = *n;
10319
for (j = 1; j <= i__1; ++j) {
10320
i__2 = *m;
10321
for (i__ = 1; i__ <= i__2; ++i__) {
10322
temp = *alpha * b[i__ + j * b_dim1];
10323
i__3 = i__ - 1;
10324
for (k = 1; k <= i__3; ++k) {
10325
temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
10326
/* L110: */
10327
}
10328
if (nounit) {
10329
temp /= a[i__ + i__ * a_dim1];
10330
}
10331
b[i__ + j * b_dim1] = temp;
10332
/* L120: */
10333
}
10334
/* L130: */
10335
}
10336
} else {
10337
i__1 = *n;
10338
for (j = 1; j <= i__1; ++j) {
10339
for (i__ = *m; i__ >= 1; --i__) {
10340
temp = *alpha * b[i__ + j * b_dim1];
10341
i__2 = *m;
10342
for (k = i__ + 1; k <= i__2; ++k) {
10343
temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
10344
/* L140: */
10345
}
10346
if (nounit) {
10347
temp /= a[i__ + i__ * a_dim1];
10348
}
10349
b[i__ + j * b_dim1] = temp;
10350
/* L150: */
10351
}
10352
/* L160: */
10353
}
10354
}
10355
}
10356
} else {
10357
if (lsame_(transa, "N")) {
10358
10359
/* Form B := alpha*B*inv( A ). */
10360
10361
if (upper) {
10362
i__1 = *n;
10363
for (j = 1; j <= i__1; ++j) {
10364
if (*alpha != 1.) {
10365
i__2 = *m;
10366
for (i__ = 1; i__ <= i__2; ++i__) {
10367
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
10368
;
10369
/* L170: */
10370
}
10371
}
10372
i__2 = j - 1;
10373
for (k = 1; k <= i__2; ++k) {
10374
if (a[k + j * a_dim1] != 0.) {
10375
i__3 = *m;
10376
for (i__ = 1; i__ <= i__3; ++i__) {
10377
b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
10378
i__ + k * b_dim1];
10379
/* L180: */
10380
}
10381
}
10382
/* L190: */
10383
}
10384
if (nounit) {
10385
temp = 1. / a[j + j * a_dim1];
10386
i__2 = *m;
10387
for (i__ = 1; i__ <= i__2; ++i__) {
10388
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
10389
/* L200: */
10390
}
10391
}
10392
/* L210: */
10393
}
10394
} else {
10395
for (j = *n; j >= 1; --j) {
10396
if (*alpha != 1.) {
10397
i__1 = *m;
10398
for (i__ = 1; i__ <= i__1; ++i__) {
10399
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
10400
;
10401
/* L220: */
10402
}
10403
}
10404
i__1 = *n;
10405
for (k = j + 1; k <= i__1; ++k) {
10406
if (a[k + j * a_dim1] != 0.) {
10407
i__2 = *m;
10408
for (i__ = 1; i__ <= i__2; ++i__) {
10409
b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
10410
i__ + k * b_dim1];
10411
/* L230: */
10412
}
10413
}
10414
/* L240: */
10415
}
10416
if (nounit) {
10417
temp = 1. / a[j + j * a_dim1];
10418
i__1 = *m;
10419
for (i__ = 1; i__ <= i__1; ++i__) {
10420
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
10421
/* L250: */
10422
}
10423
}
10424
/* L260: */
10425
}
10426
}
10427
} else {
10428
10429
/* Form B := alpha*B*inv( A' ). */
10430
10431
if (upper) {
10432
for (k = *n; k >= 1; --k) {
10433
if (nounit) {
10434
temp = 1. / a[k + k * a_dim1];
10435
i__1 = *m;
10436
for (i__ = 1; i__ <= i__1; ++i__) {
10437
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
10438
/* L270: */
10439
}
10440
}
10441
i__1 = k - 1;
10442
for (j = 1; j <= i__1; ++j) {
10443
if (a[j + k * a_dim1] != 0.) {
10444
temp = a[j + k * a_dim1];
10445
i__2 = *m;
10446
for (i__ = 1; i__ <= i__2; ++i__) {
10447
b[i__ + j * b_dim1] -= temp * b[i__ + k *
10448
b_dim1];
10449
/* L280: */
10450
}
10451
}
10452
/* L290: */
10453
}
10454
if (*alpha != 1.) {
10455
i__1 = *m;
10456
for (i__ = 1; i__ <= i__1; ++i__) {
10457
b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
10458
;
10459
/* L300: */
10460
}
10461
}
10462
/* L310: */
10463
}
10464
} else {
10465
i__1 = *n;
10466
for (k = 1; k <= i__1; ++k) {
10467
if (nounit) {
10468
temp = 1. / a[k + k * a_dim1];
10469
i__2 = *m;
10470
for (i__ = 1; i__ <= i__2; ++i__) {
10471
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
10472
/* L320: */
10473
}
10474
}
10475
i__2 = *n;
10476
for (j = k + 1; j <= i__2; ++j) {
10477
if (a[j + k * a_dim1] != 0.) {
10478
temp = a[j + k * a_dim1];
10479
i__3 = *m;
10480
for (i__ = 1; i__ <= i__3; ++i__) {
10481
b[i__ + j * b_dim1] -= temp * b[i__ + k *
10482
b_dim1];
10483
/* L330: */
10484
}
10485
}
10486
/* L340: */
10487
}
10488
if (*alpha != 1.) {
10489
i__2 = *m;
10490
for (i__ = 1; i__ <= i__2; ++i__) {
10491
b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
10492
;
10493
/* L350: */
10494
}
10495
}
10496
/* L360: */
10497
}
10498
}
10499
}
10500
}
10501
10502
return 0;
10503
10504
/* End of DTRSM . */
10505
10506
} /* dtrsm_ */
10507
10508
doublereal dzasum_(integer *n, doublecomplex *zx, integer *incx)
10509
{
10510
/* System generated locals */
10511
integer i__1;
10512
doublereal ret_val;
10513
10514
/* Local variables */
10515
static integer i__, ix;
10516
static doublereal stemp;
10517
extern doublereal dcabs1_(doublecomplex *);
10518
10519
10520
/*
10521
Purpose
10522
=======
10523
10524
DZASUM takes the sum of the absolute values.
10525
10526
Further Details
10527
===============
10528
10529
jack dongarra, 3/11/78.
10530
modified 3/93 to return if incx .le. 0.
10531
modified 12/3/93, array(1) declarations changed to array(*)
10532
10533
=====================================================================
10534
*/
10535
10536
/* Parameter adjustments */
10537
--zx;
10538
10539
/* Function Body */
10540
ret_val = 0.;
10541
stemp = 0.;
10542
if (*n <= 0 || *incx <= 0) {
10543
return ret_val;
10544
}
10545
if (*incx == 1) {
10546
goto L20;
10547
}
10548
10549
/* code for increment not equal to 1 */
10550
10551
ix = 1;
10552
i__1 = *n;
10553
for (i__ = 1; i__ <= i__1; ++i__) {
10554
stemp += dcabs1_(&zx[ix]);
10555
ix += *incx;
10556
/* L10: */
10557
}
10558
ret_val = stemp;
10559
return ret_val;
10560
10561
/* code for increment equal to 1 */
10562
10563
L20:
10564
i__1 = *n;
10565
for (i__ = 1; i__ <= i__1; ++i__) {
10566
stemp += dcabs1_(&zx[i__]);
10567
/* L30: */
10568
}
10569
ret_val = stemp;
10570
return ret_val;
10571
} /* dzasum_ */
10572
10573
doublereal dznrm2_(integer *n, doublecomplex *x, integer *incx)
10574
{
10575
/* System generated locals */
10576
integer i__1, i__2, i__3;
10577
doublereal ret_val, d__1;
10578
10579
/* Local variables */
10580
static integer ix;
10581
static doublereal ssq, temp, norm, scale;
10582
10583
10584
/*
10585
Purpose
10586
=======
10587
10588
DZNRM2 returns the euclidean norm of a vector via the function
10589
name, so that
10590
10591
DZNRM2 := sqrt( conjg( x' )*x )
10592
10593
Further Details
10594
===============
10595
10596
-- This version written on 25-October-1982.
10597
Modified on 14-October-1993 to inline the call to ZLASSQ.
10598
Sven Hammarling, Nag Ltd.
10599
10600
=====================================================================
10601
*/
10602
10603
/* Parameter adjustments */
10604
--x;
10605
10606
/* Function Body */
10607
if (*n < 1 || *incx < 1) {
10608
norm = 0.;
10609
} else {
10610
scale = 0.;
10611
ssq = 1.;
10612
/*
10613
The following loop is equivalent to this call to the LAPACK
10614
auxiliary routine:
10615
CALL ZLASSQ( N, X, INCX, SCALE, SSQ )
10616
*/
10617
10618
i__1 = (*n - 1) * *incx + 1;
10619
i__2 = *incx;
10620
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
10621
i__3 = ix;
10622
if (x[i__3].r != 0.) {
10623
i__3 = ix;
10624
temp = (d__1 = x[i__3].r, abs(d__1));
10625
if (scale < temp) {
10626
/* Computing 2nd power */
10627
d__1 = scale / temp;
10628
ssq = ssq * (d__1 * d__1) + 1.;
10629
scale = temp;
10630
} else {
10631
/* Computing 2nd power */
10632
d__1 = temp / scale;
10633
ssq += d__1 * d__1;
10634
}
10635
}
10636
if (d_imag(&x[ix]) != 0.) {
10637
temp = (d__1 = d_imag(&x[ix]), abs(d__1));
10638
if (scale < temp) {
10639
/* Computing 2nd power */
10640
d__1 = scale / temp;
10641
ssq = ssq * (d__1 * d__1) + 1.;
10642
scale = temp;
10643
} else {
10644
/* Computing 2nd power */
10645
d__1 = temp / scale;
10646
ssq += d__1 * d__1;
10647
}
10648
}
10649
/* L10: */
10650
}
10651
norm = scale * sqrt(ssq);
10652
}
10653
10654
ret_val = norm;
10655
return ret_val;
10656
10657
/* End of DZNRM2. */
10658
10659
} /* dznrm2_ */
10660
10661
integer icamax_(integer *n, singlecomplex *cx, integer *incx)
10662
{
10663
/* System generated locals */
10664
integer ret_val, i__1;
10665
10666
/* Local variables */
10667
static integer i__, ix;
10668
static real smax;
10669
extern doublereal scabs1_(singlecomplex *);
10670
10671
10672
/*
10673
Purpose
10674
=======
10675
10676
ICAMAX finds the index of element having max. absolute value.
10677
10678
Further Details
10679
===============
10680
10681
jack dongarra, linpack, 3/11/78.
10682
modified 3/93 to return if incx .le. 0.
10683
modified 12/3/93, array(1) declarations changed to array(*)
10684
10685
=====================================================================
10686
*/
10687
10688
/* Parameter adjustments */
10689
--cx;
10690
10691
/* Function Body */
10692
ret_val = 0;
10693
if (*n < 1 || *incx <= 0) {
10694
return ret_val;
10695
}
10696
ret_val = 1;
10697
if (*n == 1) {
10698
return ret_val;
10699
}
10700
if (*incx == 1) {
10701
goto L20;
10702
}
10703
10704
/* code for increment not equal to 1 */
10705
10706
ix = 1;
10707
smax = scabs1_(&cx[1]);
10708
ix += *incx;
10709
i__1 = *n;
10710
for (i__ = 2; i__ <= i__1; ++i__) {
10711
if (scabs1_(&cx[ix]) <= smax) {
10712
goto L5;
10713
}
10714
ret_val = i__;
10715
smax = scabs1_(&cx[ix]);
10716
L5:
10717
ix += *incx;
10718
/* L10: */
10719
}
10720
return ret_val;
10721
10722
/* code for increment equal to 1 */
10723
10724
L20:
10725
smax = scabs1_(&cx[1]);
10726
i__1 = *n;
10727
for (i__ = 2; i__ <= i__1; ++i__) {
10728
if (scabs1_(&cx[i__]) <= smax) {
10729
goto L30;
10730
}
10731
ret_val = i__;
10732
smax = scabs1_(&cx[i__]);
10733
L30:
10734
;
10735
}
10736
return ret_val;
10737
} /* icamax_ */
10738
10739
integer idamax_(integer *n, doublereal *dx, integer *incx)
10740
{
10741
/* System generated locals */
10742
integer ret_val, i__1;
10743
doublereal d__1;
10744
10745
/* Local variables */
10746
static integer i__, ix;
10747
static doublereal dmax__;
10748
10749
10750
/*
10751
Purpose
10752
=======
10753
10754
IDAMAX finds the index of element having max. absolute value.
10755
10756
Further Details
10757
===============
10758
10759
jack dongarra, linpack, 3/11/78.
10760
modified 3/93 to return if incx .le. 0.
10761
modified 12/3/93, array(1) declarations changed to array(*)
10762
10763
=====================================================================
10764
*/
10765
10766
/* Parameter adjustments */
10767
--dx;
10768
10769
/* Function Body */
10770
ret_val = 0;
10771
if (*n < 1 || *incx <= 0) {
10772
return ret_val;
10773
}
10774
ret_val = 1;
10775
if (*n == 1) {
10776
return ret_val;
10777
}
10778
if (*incx == 1) {
10779
goto L20;
10780
}
10781
10782
/* code for increment not equal to 1 */
10783
10784
ix = 1;
10785
dmax__ = abs(dx[1]);
10786
ix += *incx;
10787
i__1 = *n;
10788
for (i__ = 2; i__ <= i__1; ++i__) {
10789
if ((d__1 = dx[ix], abs(d__1)) <= dmax__) {
10790
goto L5;
10791
}
10792
ret_val = i__;
10793
dmax__ = (d__1 = dx[ix], abs(d__1));
10794
L5:
10795
ix += *incx;
10796
/* L10: */
10797
}
10798
return ret_val;
10799
10800
/* code for increment equal to 1 */
10801
10802
L20:
10803
dmax__ = abs(dx[1]);
10804
i__1 = *n;
10805
for (i__ = 2; i__ <= i__1; ++i__) {
10806
if ((d__1 = dx[i__], abs(d__1)) <= dmax__) {
10807
goto L30;
10808
}
10809
ret_val = i__;
10810
dmax__ = (d__1 = dx[i__], abs(d__1));
10811
L30:
10812
;
10813
}
10814
return ret_val;
10815
} /* idamax_ */
10816
10817
integer isamax_(integer *n, real *sx, integer *incx)
10818
{
10819
/* System generated locals */
10820
integer ret_val, i__1;
10821
real r__1;
10822
10823
/* Local variables */
10824
static integer i__, ix;
10825
static real smax;
10826
10827
10828
/*
10829
Purpose
10830
=======
10831
10832
ISAMAX finds the index of element having max. absolute value.
10833
10834
Further Details
10835
===============
10836
10837
jack dongarra, linpack, 3/11/78.
10838
modified 3/93 to return if incx .le. 0.
10839
modified 12/3/93, array(1) declarations changed to array(*)
10840
10841
=====================================================================
10842
*/
10843
10844
/* Parameter adjustments */
10845
--sx;
10846
10847
/* Function Body */
10848
ret_val = 0;
10849
if (*n < 1 || *incx <= 0) {
10850
return ret_val;
10851
}
10852
ret_val = 1;
10853
if (*n == 1) {
10854
return ret_val;
10855
}
10856
if (*incx == 1) {
10857
goto L20;
10858
}
10859
10860
/* code for increment not equal to 1 */
10861
10862
ix = 1;
10863
smax = dabs(sx[1]);
10864
ix += *incx;
10865
i__1 = *n;
10866
for (i__ = 2; i__ <= i__1; ++i__) {
10867
if ((r__1 = sx[ix], dabs(r__1)) <= smax) {
10868
goto L5;
10869
}
10870
ret_val = i__;
10871
smax = (r__1 = sx[ix], dabs(r__1));
10872
L5:
10873
ix += *incx;
10874
/* L10: */
10875
}
10876
return ret_val;
10877
10878
/* code for increment equal to 1 */
10879
10880
L20:
10881
smax = dabs(sx[1]);
10882
i__1 = *n;
10883
for (i__ = 2; i__ <= i__1; ++i__) {
10884
if ((r__1 = sx[i__], dabs(r__1)) <= smax) {
10885
goto L30;
10886
}
10887
ret_val = i__;
10888
smax = (r__1 = sx[i__], dabs(r__1));
10889
L30:
10890
;
10891
}
10892
return ret_val;
10893
} /* isamax_ */
10894
10895
integer izamax_(integer *n, doublecomplex *zx, integer *incx)
10896
{
10897
/* System generated locals */
10898
integer ret_val, i__1;
10899
10900
/* Local variables */
10901
static integer i__, ix;
10902
static doublereal smax;
10903
extern doublereal dcabs1_(doublecomplex *);
10904
10905
10906
/*
10907
Purpose
10908
=======
10909
10910
IZAMAX finds the index of element having max. absolute value.
10911
10912
Further Details
10913
===============
10914
10915
jack dongarra, 1/15/85.
10916
modified 3/93 to return if incx .le. 0.
10917
modified 12/3/93, array(1) declarations changed to array(*)
10918
10919
=====================================================================
10920
*/
10921
10922
/* Parameter adjustments */
10923
--zx;
10924
10925
/* Function Body */
10926
ret_val = 0;
10927
if (*n < 1 || *incx <= 0) {
10928
return ret_val;
10929
}
10930
ret_val = 1;
10931
if (*n == 1) {
10932
return ret_val;
10933
}
10934
if (*incx == 1) {
10935
goto L20;
10936
}
10937
10938
/* code for increment not equal to 1 */
10939
10940
ix = 1;
10941
smax = dcabs1_(&zx[1]);
10942
ix += *incx;
10943
i__1 = *n;
10944
for (i__ = 2; i__ <= i__1; ++i__) {
10945
if (dcabs1_(&zx[ix]) <= smax) {
10946
goto L5;
10947
}
10948
ret_val = i__;
10949
smax = dcabs1_(&zx[ix]);
10950
L5:
10951
ix += *incx;
10952
/* L10: */
10953
}
10954
return ret_val;
10955
10956
/* code for increment equal to 1 */
10957
10958
L20:
10959
smax = dcabs1_(&zx[1]);
10960
i__1 = *n;
10961
for (i__ = 2; i__ <= i__1; ++i__) {
10962
if (dcabs1_(&zx[i__]) <= smax) {
10963
goto L30;
10964
}
10965
ret_val = i__;
10966
smax = dcabs1_(&zx[i__]);
10967
L30:
10968
;
10969
}
10970
return ret_val;
10971
} /* izamax_ */
10972
10973
/* Subroutine */ int saxpy_(integer *n, real *sa, real *sx, integer *incx,
10974
real *sy, integer *incy)
10975
{
10976
/* System generated locals */
10977
integer i__1;
10978
10979
/* Local variables */
10980
static integer i__, m, ix, iy, mp1;
10981
10982
10983
/*
10984
Purpose
10985
=======
10986
10987
SAXPY constant times a vector plus a vector.
10988
uses unrolled loop for increments equal to one.
10989
10990
Further Details
10991
===============
10992
10993
jack dongarra, linpack, 3/11/78.
10994
modified 12/3/93, array(1) declarations changed to array(*)
10995
10996
=====================================================================
10997
*/
10998
10999
/* Parameter adjustments */
11000
--sy;
11001
--sx;
11002
11003
/* Function Body */
11004
if (*n <= 0) {
11005
return 0;
11006
}
11007
if (*sa == 0.f) {
11008
return 0;
11009
}
11010
if (*incx == 1 && *incy == 1) {
11011
goto L20;
11012
}
11013
11014
/*
11015
code for unequal increments or equal increments
11016
not equal to 1
11017
*/
11018
11019
ix = 1;
11020
iy = 1;
11021
if (*incx < 0) {
11022
ix = (-(*n) + 1) * *incx + 1;
11023
}
11024
if (*incy < 0) {
11025
iy = (-(*n) + 1) * *incy + 1;
11026
}
11027
i__1 = *n;
11028
for (i__ = 1; i__ <= i__1; ++i__) {
11029
sy[iy] += *sa * sx[ix];
11030
ix += *incx;
11031
iy += *incy;
11032
/* L10: */
11033
}
11034
return 0;
11035
11036
/*
11037
code for both increments equal to 1
11038
11039
11040
clean-up loop
11041
*/
11042
11043
L20:
11044
m = *n % 4;
11045
if (m == 0) {
11046
goto L40;
11047
}
11048
i__1 = m;
11049
for (i__ = 1; i__ <= i__1; ++i__) {
11050
sy[i__] += *sa * sx[i__];
11051
/* L30: */
11052
}
11053
if (*n < 4) {
11054
return 0;
11055
}
11056
L40:
11057
mp1 = m + 1;
11058
i__1 = *n;
11059
for (i__ = mp1; i__ <= i__1; i__ += 4) {
11060
sy[i__] += *sa * sx[i__];
11061
sy[i__ + 1] += *sa * sx[i__ + 1];
11062
sy[i__ + 2] += *sa * sx[i__ + 2];
11063
sy[i__ + 3] += *sa * sx[i__ + 3];
11064
/* L50: */
11065
}
11066
return 0;
11067
} /* saxpy_ */
11068
11069
doublereal scabs1_(singlecomplex *z__)
11070
{
11071
/* System generated locals */
11072
real ret_val, r__1, r__2;
11073
11074
11075
/*
11076
Purpose
11077
=======
11078
11079
SCABS1 computes absolute value of a complex number
11080
11081
=====================================================================
11082
*/
11083
11084
ret_val = (r__1 = z__->r, dabs(r__1)) + (r__2 = r_imag(z__), dabs(r__2));
11085
return ret_val;
11086
} /* scabs1_ */
11087
11088
doublereal scasum_(integer *n, singlecomplex *cx, integer *incx)
11089
{
11090
/* System generated locals */
11091
integer i__1, i__2, i__3;
11092
real ret_val, r__1, r__2;
11093
11094
/* Local variables */
11095
static integer i__, nincx;
11096
static real stemp;
11097
11098
11099
/*
11100
Purpose
11101
=======
11102
11103
SCASUM takes the sum of the absolute values of a complex vector and
11104
returns a single precision result.
11105
11106
Further Details
11107
===============
11108
11109
jack dongarra, linpack, 3/11/78.
11110
modified 3/93 to return if incx .le. 0.
11111
modified 12/3/93, array(1) declarations changed to array(*)
11112
11113
=====================================================================
11114
*/
11115
11116
/* Parameter adjustments */
11117
--cx;
11118
11119
/* Function Body */
11120
ret_val = 0.f;
11121
stemp = 0.f;
11122
if (*n <= 0 || *incx <= 0) {
11123
return ret_val;
11124
}
11125
if (*incx == 1) {
11126
goto L20;
11127
}
11128
11129
/* code for increment not equal to 1 */
11130
11131
nincx = *n * *incx;
11132
i__1 = nincx;
11133
i__2 = *incx;
11134
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
11135
i__3 = i__;
11136
stemp = stemp + (r__1 = cx[i__3].r, dabs(r__1)) + (r__2 = r_imag(&cx[
11137
i__]), dabs(r__2));
11138
/* L10: */
11139
}
11140
ret_val = stemp;
11141
return ret_val;
11142
11143
/* code for increment equal to 1 */
11144
11145
L20:
11146
i__2 = *n;
11147
for (i__ = 1; i__ <= i__2; ++i__) {
11148
i__1 = i__;
11149
stemp = stemp + (r__1 = cx[i__1].r, dabs(r__1)) + (r__2 = r_imag(&cx[
11150
i__]), dabs(r__2));
11151
/* L30: */
11152
}
11153
ret_val = stemp;
11154
return ret_val;
11155
} /* scasum_ */
11156
11157
doublereal scnrm2_(integer *n, singlecomplex *x, integer *incx)
11158
{
11159
/* System generated locals */
11160
integer i__1, i__2, i__3;
11161
real ret_val, r__1;
11162
11163
/* Local variables */
11164
static integer ix;
11165
static real ssq, temp, norm, scale;
11166
11167
11168
/*
11169
Purpose
11170
=======
11171
11172
SCNRM2 returns the euclidean norm of a vector via the function
11173
name, so that
11174
11175
SCNRM2 := sqrt( conjg( x' )*x )
11176
11177
Further Details
11178
===============
11179
11180
-- This version written on 25-October-1982.
11181
Modified on 14-October-1993 to inline the call to CLASSQ.
11182
Sven Hammarling, Nag Ltd.
11183
11184
=====================================================================
11185
*/
11186
11187
/* Parameter adjustments */
11188
--x;
11189
11190
/* Function Body */
11191
if (*n < 1 || *incx < 1) {
11192
norm = 0.f;
11193
} else {
11194
scale = 0.f;
11195
ssq = 1.f;
11196
/*
11197
The following loop is equivalent to this call to the LAPACK
11198
auxiliary routine:
11199
CALL CLASSQ( N, X, INCX, SCALE, SSQ )
11200
*/
11201
11202
i__1 = (*n - 1) * *incx + 1;
11203
i__2 = *incx;
11204
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
11205
i__3 = ix;
11206
if (x[i__3].r != 0.f) {
11207
i__3 = ix;
11208
temp = (r__1 = x[i__3].r, dabs(r__1));
11209
if (scale < temp) {
11210
/* Computing 2nd power */
11211
r__1 = scale / temp;
11212
ssq = ssq * (r__1 * r__1) + 1.f;
11213
scale = temp;
11214
} else {
11215
/* Computing 2nd power */
11216
r__1 = temp / scale;
11217
ssq += r__1 * r__1;
11218
}
11219
}
11220
if (r_imag(&x[ix]) != 0.f) {
11221
temp = (r__1 = r_imag(&x[ix]), dabs(r__1));
11222
if (scale < temp) {
11223
/* Computing 2nd power */
11224
r__1 = scale / temp;
11225
ssq = ssq * (r__1 * r__1) + 1.f;
11226
scale = temp;
11227
} else {
11228
/* Computing 2nd power */
11229
r__1 = temp / scale;
11230
ssq += r__1 * r__1;
11231
}
11232
}
11233
/* L10: */
11234
}
11235
norm = scale * sqrt(ssq);
11236
}
11237
11238
ret_val = norm;
11239
return ret_val;
11240
11241
/* End of SCNRM2. */
11242
11243
} /* scnrm2_ */
11244
11245
/* Subroutine */ int scopy_(integer *n, real *sx, integer *incx, real *sy,
11246
integer *incy)
11247
{
11248
/* System generated locals */
11249
integer i__1;
11250
11251
/* Local variables */
11252
static integer i__, m, ix, iy, mp1;
11253
11254
11255
/*
11256
Purpose
11257
=======
11258
11259
SCOPY copies a vector, x, to a vector, y.
11260
uses unrolled loops for increments equal to 1.
11261
11262
Further Details
11263
===============
11264
11265
jack dongarra, linpack, 3/11/78.
11266
modified 12/3/93, array(1) declarations changed to array(*)
11267
11268
=====================================================================
11269
*/
11270
11271
/* Parameter adjustments */
11272
--sy;
11273
--sx;
11274
11275
/* Function Body */
11276
if (*n <= 0) {
11277
return 0;
11278
}
11279
if (*incx == 1 && *incy == 1) {
11280
goto L20;
11281
}
11282
11283
/*
11284
code for unequal increments or equal increments
11285
not equal to 1
11286
*/
11287
11288
ix = 1;
11289
iy = 1;
11290
if (*incx < 0) {
11291
ix = (-(*n) + 1) * *incx + 1;
11292
}
11293
if (*incy < 0) {
11294
iy = (-(*n) + 1) * *incy + 1;
11295
}
11296
i__1 = *n;
11297
for (i__ = 1; i__ <= i__1; ++i__) {
11298
sy[iy] = sx[ix];
11299
ix += *incx;
11300
iy += *incy;
11301
/* L10: */
11302
}
11303
return 0;
11304
11305
/*
11306
code for both increments equal to 1
11307
11308
11309
clean-up loop
11310
*/
11311
11312
L20:
11313
m = *n % 7;
11314
if (m == 0) {
11315
goto L40;
11316
}
11317
i__1 = m;
11318
for (i__ = 1; i__ <= i__1; ++i__) {
11319
sy[i__] = sx[i__];
11320
/* L30: */
11321
}
11322
if (*n < 7) {
11323
return 0;
11324
}
11325
L40:
11326
mp1 = m + 1;
11327
i__1 = *n;
11328
for (i__ = mp1; i__ <= i__1; i__ += 7) {
11329
sy[i__] = sx[i__];
11330
sy[i__ + 1] = sx[i__ + 1];
11331
sy[i__ + 2] = sx[i__ + 2];
11332
sy[i__ + 3] = sx[i__ + 3];
11333
sy[i__ + 4] = sx[i__ + 4];
11334
sy[i__ + 5] = sx[i__ + 5];
11335
sy[i__ + 6] = sx[i__ + 6];
11336
/* L50: */
11337
}
11338
return 0;
11339
} /* scopy_ */
11340
11341
doublereal sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy)
11342
{
11343
/* System generated locals */
11344
integer i__1;
11345
real ret_val;
11346
11347
/* Local variables */
11348
static integer i__, m, ix, iy, mp1;
11349
static real stemp;
11350
11351
11352
/*
11353
Purpose
11354
=======
11355
11356
SDOT forms the dot product of two vectors.
11357
uses unrolled loops for increments equal to one.
11358
11359
Further Details
11360
===============
11361
11362
jack dongarra, linpack, 3/11/78.
11363
modified 12/3/93, array(1) declarations changed to array(*)
11364
11365
=====================================================================
11366
*/
11367
11368
/* Parameter adjustments */
11369
--sy;
11370
--sx;
11371
11372
/* Function Body */
11373
stemp = 0.f;
11374
ret_val = 0.f;
11375
if (*n <= 0) {
11376
return ret_val;
11377
}
11378
if (*incx == 1 && *incy == 1) {
11379
goto L20;
11380
}
11381
11382
/*
11383
code for unequal increments or equal increments
11384
not equal to 1
11385
*/
11386
11387
ix = 1;
11388
iy = 1;
11389
if (*incx < 0) {
11390
ix = (-(*n) + 1) * *incx + 1;
11391
}
11392
if (*incy < 0) {
11393
iy = (-(*n) + 1) * *incy + 1;
11394
}
11395
i__1 = *n;
11396
for (i__ = 1; i__ <= i__1; ++i__) {
11397
stemp += sx[ix] * sy[iy];
11398
ix += *incx;
11399
iy += *incy;
11400
/* L10: */
11401
}
11402
ret_val = stemp;
11403
return ret_val;
11404
11405
/*
11406
code for both increments equal to 1
11407
11408
11409
clean-up loop
11410
*/
11411
11412
L20:
11413
m = *n % 5;
11414
if (m == 0) {
11415
goto L40;
11416
}
11417
i__1 = m;
11418
for (i__ = 1; i__ <= i__1; ++i__) {
11419
stemp += sx[i__] * sy[i__];
11420
/* L30: */
11421
}
11422
if (*n < 5) {
11423
goto L60;
11424
}
11425
L40:
11426
mp1 = m + 1;
11427
i__1 = *n;
11428
for (i__ = mp1; i__ <= i__1; i__ += 5) {
11429
stemp = stemp + sx[i__] * sy[i__] + sx[i__ + 1] * sy[i__ + 1] + sx[
11430
i__ + 2] * sy[i__ + 2] + sx[i__ + 3] * sy[i__ + 3] + sx[i__ +
11431
4] * sy[i__ + 4];
11432
/* L50: */
11433
}
11434
L60:
11435
ret_val = stemp;
11436
return ret_val;
11437
} /* sdot_ */
11438
11439
/* Subroutine */ int sgemm_(char *transa, char *transb, integer *m, integer *
11440
n, integer *k, real *alpha, real *a, integer *lda, real *b, integer *
11441
ldb, real *beta, real *c__, integer *ldc)
11442
{
11443
/* System generated locals */
11444
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
11445
i__3;
11446
11447
/* Local variables */
11448
static integer i__, j, l, info;
11449
static logical nota, notb;
11450
static real temp;
11451
extern logical lsame_(char *, char *);
11452
static integer nrowa, nrowb;
11453
extern /* Subroutine */ int xerbla_(char *, integer *);
11454
11455
11456
/*
11457
Purpose
11458
=======
11459
11460
SGEMM performs one of the matrix-matrix operations
11461
11462
C := alpha*op( A )*op( B ) + beta*C,
11463
11464
where op( X ) is one of
11465
11466
op( X ) = X or op( X ) = X',
11467
11468
alpha and beta are scalars, and A, B and C are matrices, with op( A )
11469
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
11470
11471
Arguments
11472
==========
11473
11474
TRANSA - CHARACTER*1.
11475
On entry, TRANSA specifies the form of op( A ) to be used in
11476
the matrix multiplication as follows:
11477
11478
TRANSA = 'N' or 'n', op( A ) = A.
11479
11480
TRANSA = 'T' or 't', op( A ) = A'.
11481
11482
TRANSA = 'C' or 'c', op( A ) = A'.
11483
11484
Unchanged on exit.
11485
11486
TRANSB - CHARACTER*1.
11487
On entry, TRANSB specifies the form of op( B ) to be used in
11488
the matrix multiplication as follows:
11489
11490
TRANSB = 'N' or 'n', op( B ) = B.
11491
11492
TRANSB = 'T' or 't', op( B ) = B'.
11493
11494
TRANSB = 'C' or 'c', op( B ) = B'.
11495
11496
Unchanged on exit.
11497
11498
M - INTEGER.
11499
On entry, M specifies the number of rows of the matrix
11500
op( A ) and of the matrix C. M must be at least zero.
11501
Unchanged on exit.
11502
11503
N - INTEGER.
11504
On entry, N specifies the number of columns of the matrix
11505
op( B ) and the number of columns of the matrix C. N must be
11506
at least zero.
11507
Unchanged on exit.
11508
11509
K - INTEGER.
11510
On entry, K specifies the number of columns of the matrix
11511
op( A ) and the number of rows of the matrix op( B ). K must
11512
be at least zero.
11513
Unchanged on exit.
11514
11515
ALPHA - REAL .
11516
On entry, ALPHA specifies the scalar alpha.
11517
Unchanged on exit.
11518
11519
A - REAL array of DIMENSION ( LDA, ka ), where ka is
11520
k when TRANSA = 'N' or 'n', and is m otherwise.
11521
Before entry with TRANSA = 'N' or 'n', the leading m by k
11522
part of the array A must contain the matrix A, otherwise
11523
the leading k by m part of the array A must contain the
11524
matrix A.
11525
Unchanged on exit.
11526
11527
LDA - INTEGER.
11528
On entry, LDA specifies the first dimension of A as declared
11529
in the calling (sub) program. When TRANSA = 'N' or 'n' then
11530
LDA must be at least max( 1, m ), otherwise LDA must be at
11531
least max( 1, k ).
11532
Unchanged on exit.
11533
11534
B - REAL array of DIMENSION ( LDB, kb ), where kb is
11535
n when TRANSB = 'N' or 'n', and is k otherwise.
11536
Before entry with TRANSB = 'N' or 'n', the leading k by n
11537
part of the array B must contain the matrix B, otherwise
11538
the leading n by k part of the array B must contain the
11539
matrix B.
11540
Unchanged on exit.
11541
11542
LDB - INTEGER.
11543
On entry, LDB specifies the first dimension of B as declared
11544
in the calling (sub) program. When TRANSB = 'N' or 'n' then
11545
LDB must be at least max( 1, k ), otherwise LDB must be at
11546
least max( 1, n ).
11547
Unchanged on exit.
11548
11549
BETA - REAL .
11550
On entry, BETA specifies the scalar beta. When BETA is
11551
supplied as zero then C need not be set on input.
11552
Unchanged on exit.
11553
11554
C - REAL array of DIMENSION ( LDC, n ).
11555
Before entry, the leading m by n part of the array C must
11556
contain the matrix C, except when beta is zero, in which
11557
case C need not be set on entry.
11558
On exit, the array C is overwritten by the m by n matrix
11559
( alpha*op( A )*op( B ) + beta*C ).
11560
11561
LDC - INTEGER.
11562
On entry, LDC specifies the first dimension of C as declared
11563
in the calling (sub) program. LDC must be at least
11564
max( 1, m ).
11565
Unchanged on exit.
11566
11567
Further Details
11568
===============
11569
11570
Level 3 Blas routine.
11571
11572
-- Written on 8-February-1989.
11573
Jack Dongarra, Argonne National Laboratory.
11574
Iain Duff, AERE Harwell.
11575
Jeremy Du Croz, Numerical Algorithms Group Ltd.
11576
Sven Hammarling, Numerical Algorithms Group Ltd.
11577
11578
=====================================================================
11579
11580
11581
Set NOTA and NOTB as true if A and B respectively are not
11582
transposed and set NROWA and NROWB as the number of rows
11583
and columns of A and the number of rows of B respectively.
11584
*/
11585
11586
/* Parameter adjustments */
11587
a_dim1 = *lda;
11588
a_offset = 1 + a_dim1;
11589
a -= a_offset;
11590
b_dim1 = *ldb;
11591
b_offset = 1 + b_dim1;
11592
b -= b_offset;
11593
c_dim1 = *ldc;
11594
c_offset = 1 + c_dim1;
11595
c__ -= c_offset;
11596
11597
/* Function Body */
11598
nota = lsame_(transa, "N");
11599
notb = lsame_(transb, "N");
11600
if (nota) {
11601
nrowa = *m;
11602
} else {
11603
nrowa = *k;
11604
}
11605
if (notb) {
11606
nrowb = *k;
11607
} else {
11608
nrowb = *n;
11609
}
11610
11611
/* Test the input parameters. */
11612
11613
info = 0;
11614
if (! nota && ! lsame_(transa, "C") && ! lsame_(
11615
transa, "T")) {
11616
info = 1;
11617
} else if (! notb && ! lsame_(transb, "C") && !
11618
lsame_(transb, "T")) {
11619
info = 2;
11620
} else if (*m < 0) {
11621
info = 3;
11622
} else if (*n < 0) {
11623
info = 4;
11624
} else if (*k < 0) {
11625
info = 5;
11626
} else if (*lda < max(1,nrowa)) {
11627
info = 8;
11628
} else if (*ldb < max(1,nrowb)) {
11629
info = 10;
11630
} else if (*ldc < max(1,*m)) {
11631
info = 13;
11632
}
11633
if (info != 0) {
11634
xerbla_("SGEMM ", &info);
11635
return 0;
11636
}
11637
11638
/* Quick return if possible. */
11639
11640
if (*m == 0 || *n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
11641
return 0;
11642
}
11643
11644
/* And if alpha.eq.zero. */
11645
11646
if (*alpha == 0.f) {
11647
if (*beta == 0.f) {
11648
i__1 = *n;
11649
for (j = 1; j <= i__1; ++j) {
11650
i__2 = *m;
11651
for (i__ = 1; i__ <= i__2; ++i__) {
11652
c__[i__ + j * c_dim1] = 0.f;
11653
/* L10: */
11654
}
11655
/* L20: */
11656
}
11657
} else {
11658
i__1 = *n;
11659
for (j = 1; j <= i__1; ++j) {
11660
i__2 = *m;
11661
for (i__ = 1; i__ <= i__2; ++i__) {
11662
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
11663
/* L30: */
11664
}
11665
/* L40: */
11666
}
11667
}
11668
return 0;
11669
}
11670
11671
/* Start the operations. */
11672
11673
if (notb) {
11674
if (nota) {
11675
11676
/* Form C := alpha*A*B + beta*C. */
11677
11678
i__1 = *n;
11679
for (j = 1; j <= i__1; ++j) {
11680
if (*beta == 0.f) {
11681
i__2 = *m;
11682
for (i__ = 1; i__ <= i__2; ++i__) {
11683
c__[i__ + j * c_dim1] = 0.f;
11684
/* L50: */
11685
}
11686
} else if (*beta != 1.f) {
11687
i__2 = *m;
11688
for (i__ = 1; i__ <= i__2; ++i__) {
11689
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
11690
/* L60: */
11691
}
11692
}
11693
i__2 = *k;
11694
for (l = 1; l <= i__2; ++l) {
11695
if (b[l + j * b_dim1] != 0.f) {
11696
temp = *alpha * b[l + j * b_dim1];
11697
i__3 = *m;
11698
for (i__ = 1; i__ <= i__3; ++i__) {
11699
c__[i__ + j * c_dim1] += temp * a[i__ + l *
11700
a_dim1];
11701
/* L70: */
11702
}
11703
}
11704
/* L80: */
11705
}
11706
/* L90: */
11707
}
11708
} else {
11709
11710
/* Form C := alpha*A'*B + beta*C */
11711
11712
i__1 = *n;
11713
for (j = 1; j <= i__1; ++j) {
11714
i__2 = *m;
11715
for (i__ = 1; i__ <= i__2; ++i__) {
11716
temp = 0.f;
11717
i__3 = *k;
11718
for (l = 1; l <= i__3; ++l) {
11719
temp += a[l + i__ * a_dim1] * b[l + j * b_dim1];
11720
/* L100: */
11721
}
11722
if (*beta == 0.f) {
11723
c__[i__ + j * c_dim1] = *alpha * temp;
11724
} else {
11725
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
11726
i__ + j * c_dim1];
11727
}
11728
/* L110: */
11729
}
11730
/* L120: */
11731
}
11732
}
11733
} else {
11734
if (nota) {
11735
11736
/* Form C := alpha*A*B' + beta*C */
11737
11738
i__1 = *n;
11739
for (j = 1; j <= i__1; ++j) {
11740
if (*beta == 0.f) {
11741
i__2 = *m;
11742
for (i__ = 1; i__ <= i__2; ++i__) {
11743
c__[i__ + j * c_dim1] = 0.f;
11744
/* L130: */
11745
}
11746
} else if (*beta != 1.f) {
11747
i__2 = *m;
11748
for (i__ = 1; i__ <= i__2; ++i__) {
11749
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
11750
/* L140: */
11751
}
11752
}
11753
i__2 = *k;
11754
for (l = 1; l <= i__2; ++l) {
11755
if (b[j + l * b_dim1] != 0.f) {
11756
temp = *alpha * b[j + l * b_dim1];
11757
i__3 = *m;
11758
for (i__ = 1; i__ <= i__3; ++i__) {
11759
c__[i__ + j * c_dim1] += temp * a[i__ + l *
11760
a_dim1];
11761
/* L150: */
11762
}
11763
}
11764
/* L160: */
11765
}
11766
/* L170: */
11767
}
11768
} else {
11769
11770
/* Form C := alpha*A'*B' + beta*C */
11771
11772
i__1 = *n;
11773
for (j = 1; j <= i__1; ++j) {
11774
i__2 = *m;
11775
for (i__ = 1; i__ <= i__2; ++i__) {
11776
temp = 0.f;
11777
i__3 = *k;
11778
for (l = 1; l <= i__3; ++l) {
11779
temp += a[l + i__ * a_dim1] * b[j + l * b_dim1];
11780
/* L180: */
11781
}
11782
if (*beta == 0.f) {
11783
c__[i__ + j * c_dim1] = *alpha * temp;
11784
} else {
11785
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
11786
i__ + j * c_dim1];
11787
}
11788
/* L190: */
11789
}
11790
/* L200: */
11791
}
11792
}
11793
}
11794
11795
return 0;
11796
11797
/* End of SGEMM . */
11798
11799
} /* sgemm_ */
11800
11801
/* Subroutine */ int sgemv_(char *trans, integer *m, integer *n, real *alpha,
11802
real *a, integer *lda, real *x, integer *incx, real *beta, real *y,
11803
integer *incy)
11804
{
11805
/* System generated locals */
11806
integer a_dim1, a_offset, i__1, i__2;
11807
11808
/* Local variables */
11809
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
11810
static real temp;
11811
static integer lenx, leny;
11812
extern logical lsame_(char *, char *);
11813
extern /* Subroutine */ int xerbla_(char *, integer *);
11814
11815
11816
/*
11817
Purpose
11818
=======
11819
11820
SGEMV performs one of the matrix-vector operations
11821
11822
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
11823
11824
where alpha and beta are scalars, x and y are vectors and A is an
11825
m by n matrix.
11826
11827
Arguments
11828
==========
11829
11830
TRANS - CHARACTER*1.
11831
On entry, TRANS specifies the operation to be performed as
11832
follows:
11833
11834
TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
11835
11836
TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
11837
11838
TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
11839
11840
Unchanged on exit.
11841
11842
M - INTEGER.
11843
On entry, M specifies the number of rows of the matrix A.
11844
M must be at least zero.
11845
Unchanged on exit.
11846
11847
N - INTEGER.
11848
On entry, N specifies the number of columns of the matrix A.
11849
N must be at least zero.
11850
Unchanged on exit.
11851
11852
ALPHA - REAL .
11853
On entry, ALPHA specifies the scalar alpha.
11854
Unchanged on exit.
11855
11856
A - REAL array of DIMENSION ( LDA, n ).
11857
Before entry, the leading m by n part of the array A must
11858
contain the matrix of coefficients.
11859
Unchanged on exit.
11860
11861
LDA - INTEGER.
11862
On entry, LDA specifies the first dimension of A as declared
11863
in the calling (sub) program. LDA must be at least
11864
max( 1, m ).
11865
Unchanged on exit.
11866
11867
X - REAL array of DIMENSION at least
11868
( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
11869
and at least
11870
( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
11871
Before entry, the incremented array X must contain the
11872
vector x.
11873
Unchanged on exit.
11874
11875
INCX - INTEGER.
11876
On entry, INCX specifies the increment for the elements of
11877
X. INCX must not be zero.
11878
Unchanged on exit.
11879
11880
BETA - REAL .
11881
On entry, BETA specifies the scalar beta. When BETA is
11882
supplied as zero then Y need not be set on input.
11883
Unchanged on exit.
11884
11885
Y - REAL array of DIMENSION at least
11886
( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
11887
and at least
11888
( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
11889
Before entry with BETA non-zero, the incremented array Y
11890
must contain the vector y. On exit, Y is overwritten by the
11891
updated vector y.
11892
11893
INCY - INTEGER.
11894
On entry, INCY specifies the increment for the elements of
11895
Y. INCY must not be zero.
11896
Unchanged on exit.
11897
11898
Further Details
11899
===============
11900
11901
Level 2 Blas routine.
11902
11903
-- Written on 22-October-1986.
11904
Jack Dongarra, Argonne National Lab.
11905
Jeremy Du Croz, Nag Central Office.
11906
Sven Hammarling, Nag Central Office.
11907
Richard Hanson, Sandia National Labs.
11908
11909
=====================================================================
11910
11911
11912
Test the input parameters.
11913
*/
11914
11915
/* Parameter adjustments */
11916
a_dim1 = *lda;
11917
a_offset = 1 + a_dim1;
11918
a -= a_offset;
11919
--x;
11920
--y;
11921
11922
/* Function Body */
11923
info = 0;
11924
if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
11925
) {
11926
info = 1;
11927
} else if (*m < 0) {
11928
info = 2;
11929
} else if (*n < 0) {
11930
info = 3;
11931
} else if (*lda < max(1,*m)) {
11932
info = 6;
11933
} else if (*incx == 0) {
11934
info = 8;
11935
} else if (*incy == 0) {
11936
info = 11;
11937
}
11938
if (info != 0) {
11939
xerbla_("SGEMV ", &info);
11940
return 0;
11941
}
11942
11943
/* Quick return if possible. */
11944
11945
if (*m == 0 || *n == 0 || *alpha == 0.f && *beta == 1.f) {
11946
return 0;
11947
}
11948
11949
/*
11950
Set LENX and LENY, the lengths of the vectors x and y, and set
11951
up the start points in X and Y.
11952
*/
11953
11954
if (lsame_(trans, "N")) {
11955
lenx = *n;
11956
leny = *m;
11957
} else {
11958
lenx = *m;
11959
leny = *n;
11960
}
11961
if (*incx > 0) {
11962
kx = 1;
11963
} else {
11964
kx = 1 - (lenx - 1) * *incx;
11965
}
11966
if (*incy > 0) {
11967
ky = 1;
11968
} else {
11969
ky = 1 - (leny - 1) * *incy;
11970
}
11971
11972
/*
11973
Start the operations. In this version the elements of A are
11974
accessed sequentially with one pass through A.
11975
11976
First form y := beta*y.
11977
*/
11978
11979
if (*beta != 1.f) {
11980
if (*incy == 1) {
11981
if (*beta == 0.f) {
11982
i__1 = leny;
11983
for (i__ = 1; i__ <= i__1; ++i__) {
11984
y[i__] = 0.f;
11985
/* L10: */
11986
}
11987
} else {
11988
i__1 = leny;
11989
for (i__ = 1; i__ <= i__1; ++i__) {
11990
y[i__] = *beta * y[i__];
11991
/* L20: */
11992
}
11993
}
11994
} else {
11995
iy = ky;
11996
if (*beta == 0.f) {
11997
i__1 = leny;
11998
for (i__ = 1; i__ <= i__1; ++i__) {
11999
y[iy] = 0.f;
12000
iy += *incy;
12001
/* L30: */
12002
}
12003
} else {
12004
i__1 = leny;
12005
for (i__ = 1; i__ <= i__1; ++i__) {
12006
y[iy] = *beta * y[iy];
12007
iy += *incy;
12008
/* L40: */
12009
}
12010
}
12011
}
12012
}
12013
if (*alpha == 0.f) {
12014
return 0;
12015
}
12016
if (lsame_(trans, "N")) {
12017
12018
/* Form y := alpha*A*x + y. */
12019
12020
jx = kx;
12021
if (*incy == 1) {
12022
i__1 = *n;
12023
for (j = 1; j <= i__1; ++j) {
12024
if (x[jx] != 0.f) {
12025
temp = *alpha * x[jx];
12026
i__2 = *m;
12027
for (i__ = 1; i__ <= i__2; ++i__) {
12028
y[i__] += temp * a[i__ + j * a_dim1];
12029
/* L50: */
12030
}
12031
}
12032
jx += *incx;
12033
/* L60: */
12034
}
12035
} else {
12036
i__1 = *n;
12037
for (j = 1; j <= i__1; ++j) {
12038
if (x[jx] != 0.f) {
12039
temp = *alpha * x[jx];
12040
iy = ky;
12041
i__2 = *m;
12042
for (i__ = 1; i__ <= i__2; ++i__) {
12043
y[iy] += temp * a[i__ + j * a_dim1];
12044
iy += *incy;
12045
/* L70: */
12046
}
12047
}
12048
jx += *incx;
12049
/* L80: */
12050
}
12051
}
12052
} else {
12053
12054
/* Form y := alpha*A'*x + y. */
12055
12056
jy = ky;
12057
if (*incx == 1) {
12058
i__1 = *n;
12059
for (j = 1; j <= i__1; ++j) {
12060
temp = 0.f;
12061
i__2 = *m;
12062
for (i__ = 1; i__ <= i__2; ++i__) {
12063
temp += a[i__ + j * a_dim1] * x[i__];
12064
/* L90: */
12065
}
12066
y[jy] += *alpha * temp;
12067
jy += *incy;
12068
/* L100: */
12069
}
12070
} else {
12071
i__1 = *n;
12072
for (j = 1; j <= i__1; ++j) {
12073
temp = 0.f;
12074
ix = kx;
12075
i__2 = *m;
12076
for (i__ = 1; i__ <= i__2; ++i__) {
12077
temp += a[i__ + j * a_dim1] * x[ix];
12078
ix += *incx;
12079
/* L110: */
12080
}
12081
y[jy] += *alpha * temp;
12082
jy += *incy;
12083
/* L120: */
12084
}
12085
}
12086
}
12087
12088
return 0;
12089
12090
/* End of SGEMV . */
12091
12092
} /* sgemv_ */
12093
12094
/* Subroutine */ int sger_(integer *m, integer *n, real *alpha, real *x,
12095
integer *incx, real *y, integer *incy, real *a, integer *lda)
12096
{
12097
/* System generated locals */
12098
integer a_dim1, a_offset, i__1, i__2;
12099
12100
/* Local variables */
12101
static integer i__, j, ix, jy, kx, info;
12102
static real temp;
12103
extern /* Subroutine */ int xerbla_(char *, integer *);
12104
12105
12106
/*
12107
Purpose
12108
=======
12109
12110
SGER performs the rank 1 operation
12111
12112
A := alpha*x*y' + A,
12113
12114
where alpha is a scalar, x is an m element vector, y is an n element
12115
vector and A is an m by n matrix.
12116
12117
Arguments
12118
==========
12119
12120
M - INTEGER.
12121
On entry, M specifies the number of rows of the matrix A.
12122
M must be at least zero.
12123
Unchanged on exit.
12124
12125
N - INTEGER.
12126
On entry, N specifies the number of columns of the matrix A.
12127
N must be at least zero.
12128
Unchanged on exit.
12129
12130
ALPHA - REAL .
12131
On entry, ALPHA specifies the scalar alpha.
12132
Unchanged on exit.
12133
12134
X - REAL array of dimension at least
12135
( 1 + ( m - 1 )*abs( INCX ) ).
12136
Before entry, the incremented array X must contain the m
12137
element vector x.
12138
Unchanged on exit.
12139
12140
INCX - INTEGER.
12141
On entry, INCX specifies the increment for the elements of
12142
X. INCX must not be zero.
12143
Unchanged on exit.
12144
12145
Y - REAL array of dimension at least
12146
( 1 + ( n - 1 )*abs( INCY ) ).
12147
Before entry, the incremented array Y must contain the n
12148
element vector y.
12149
Unchanged on exit.
12150
12151
INCY - INTEGER.
12152
On entry, INCY specifies the increment for the elements of
12153
Y. INCY must not be zero.
12154
Unchanged on exit.
12155
12156
A - REAL array of DIMENSION ( LDA, n ).
12157
Before entry, the leading m by n part of the array A must
12158
contain the matrix of coefficients. On exit, A is
12159
overwritten by the updated matrix.
12160
12161
LDA - INTEGER.
12162
On entry, LDA specifies the first dimension of A as declared
12163
in the calling (sub) program. LDA must be at least
12164
max( 1, m ).
12165
Unchanged on exit.
12166
12167
Further Details
12168
===============
12169
12170
Level 2 Blas routine.
12171
12172
-- Written on 22-October-1986.
12173
Jack Dongarra, Argonne National Lab.
12174
Jeremy Du Croz, Nag Central Office.
12175
Sven Hammarling, Nag Central Office.
12176
Richard Hanson, Sandia National Labs.
12177
12178
=====================================================================
12179
12180
12181
Test the input parameters.
12182
*/
12183
12184
/* Parameter adjustments */
12185
--x;
12186
--y;
12187
a_dim1 = *lda;
12188
a_offset = 1 + a_dim1;
12189
a -= a_offset;
12190
12191
/* Function Body */
12192
info = 0;
12193
if (*m < 0) {
12194
info = 1;
12195
} else if (*n < 0) {
12196
info = 2;
12197
} else if (*incx == 0) {
12198
info = 5;
12199
} else if (*incy == 0) {
12200
info = 7;
12201
} else if (*lda < max(1,*m)) {
12202
info = 9;
12203
}
12204
if (info != 0) {
12205
xerbla_("SGER ", &info);
12206
return 0;
12207
}
12208
12209
/* Quick return if possible. */
12210
12211
if (*m == 0 || *n == 0 || *alpha == 0.f) {
12212
return 0;
12213
}
12214
12215
/*
12216
Start the operations. In this version the elements of A are
12217
accessed sequentially with one pass through A.
12218
*/
12219
12220
if (*incy > 0) {
12221
jy = 1;
12222
} else {
12223
jy = 1 - (*n - 1) * *incy;
12224
}
12225
if (*incx == 1) {
12226
i__1 = *n;
12227
for (j = 1; j <= i__1; ++j) {
12228
if (y[jy] != 0.f) {
12229
temp = *alpha * y[jy];
12230
i__2 = *m;
12231
for (i__ = 1; i__ <= i__2; ++i__) {
12232
a[i__ + j * a_dim1] += x[i__] * temp;
12233
/* L10: */
12234
}
12235
}
12236
jy += *incy;
12237
/* L20: */
12238
}
12239
} else {
12240
if (*incx > 0) {
12241
kx = 1;
12242
} else {
12243
kx = 1 - (*m - 1) * *incx;
12244
}
12245
i__1 = *n;
12246
for (j = 1; j <= i__1; ++j) {
12247
if (y[jy] != 0.f) {
12248
temp = *alpha * y[jy];
12249
ix = kx;
12250
i__2 = *m;
12251
for (i__ = 1; i__ <= i__2; ++i__) {
12252
a[i__ + j * a_dim1] += x[ix] * temp;
12253
ix += *incx;
12254
/* L30: */
12255
}
12256
}
12257
jy += *incy;
12258
/* L40: */
12259
}
12260
}
12261
12262
return 0;
12263
12264
/* End of SGER . */
12265
12266
} /* sger_ */
12267
12268
doublereal snrm2_(integer *n, real *x, integer *incx)
12269
{
12270
/* System generated locals */
12271
integer i__1, i__2;
12272
real ret_val, r__1;
12273
12274
/* Local variables */
12275
static integer ix;
12276
static real ssq, norm, scale, absxi;
12277
12278
12279
/*
12280
Purpose
12281
=======
12282
12283
SNRM2 returns the euclidean norm of a vector via the function
12284
name, so that
12285
12286
SNRM2 := sqrt( x'*x ).
12287
12288
Further Details
12289
===============
12290
12291
-- This version written on 25-October-1982.
12292
Modified on 14-October-1993 to inline the call to SLASSQ.
12293
Sven Hammarling, Nag Ltd.
12294
12295
=====================================================================
12296
*/
12297
12298
/* Parameter adjustments */
12299
--x;
12300
12301
/* Function Body */
12302
if (*n < 1 || *incx < 1) {
12303
norm = 0.f;
12304
} else if (*n == 1) {
12305
norm = dabs(x[1]);
12306
} else {
12307
scale = 0.f;
12308
ssq = 1.f;
12309
/*
12310
The following loop is equivalent to this call to the LAPACK
12311
auxiliary routine:
12312
CALL SLASSQ( N, X, INCX, SCALE, SSQ )
12313
*/
12314
12315
i__1 = (*n - 1) * *incx + 1;
12316
i__2 = *incx;
12317
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
12318
if (x[ix] != 0.f) {
12319
absxi = (r__1 = x[ix], dabs(r__1));
12320
if (scale < absxi) {
12321
/* Computing 2nd power */
12322
r__1 = scale / absxi;
12323
ssq = ssq * (r__1 * r__1) + 1.f;
12324
scale = absxi;
12325
} else {
12326
/* Computing 2nd power */
12327
r__1 = absxi / scale;
12328
ssq += r__1 * r__1;
12329
}
12330
}
12331
/* L10: */
12332
}
12333
norm = scale * sqrt(ssq);
12334
}
12335
12336
ret_val = norm;
12337
return ret_val;
12338
12339
/* End of SNRM2. */
12340
12341
} /* snrm2_ */
12342
12343
/* Subroutine */ int srot_(integer *n, real *sx, integer *incx, real *sy,
12344
integer *incy, real *c__, real *s)
12345
{
12346
/* System generated locals */
12347
integer i__1;
12348
12349
/* Local variables */
12350
static integer i__, ix, iy;
12351
static real stemp;
12352
12353
12354
/*
12355
Purpose
12356
=======
12357
12358
applies a plane rotation.
12359
12360
Further Details
12361
===============
12362
12363
jack dongarra, linpack, 3/11/78.
12364
modified 12/3/93, array(1) declarations changed to array(*)
12365
12366
=====================================================================
12367
*/
12368
12369
/* Parameter adjustments */
12370
--sy;
12371
--sx;
12372
12373
/* Function Body */
12374
if (*n <= 0) {
12375
return 0;
12376
}
12377
if (*incx == 1 && *incy == 1) {
12378
goto L20;
12379
}
12380
12381
/*
12382
code for unequal increments or equal increments not equal
12383
to 1
12384
*/
12385
12386
ix = 1;
12387
iy = 1;
12388
if (*incx < 0) {
12389
ix = (-(*n) + 1) * *incx + 1;
12390
}
12391
if (*incy < 0) {
12392
iy = (-(*n) + 1) * *incy + 1;
12393
}
12394
i__1 = *n;
12395
for (i__ = 1; i__ <= i__1; ++i__) {
12396
stemp = *c__ * sx[ix] + *s * sy[iy];
12397
sy[iy] = *c__ * sy[iy] - *s * sx[ix];
12398
sx[ix] = stemp;
12399
ix += *incx;
12400
iy += *incy;
12401
/* L10: */
12402
}
12403
return 0;
12404
12405
/* code for both increments equal to 1 */
12406
12407
L20:
12408
i__1 = *n;
12409
for (i__ = 1; i__ <= i__1; ++i__) {
12410
stemp = *c__ * sx[i__] + *s * sy[i__];
12411
sy[i__] = *c__ * sy[i__] - *s * sx[i__];
12412
sx[i__] = stemp;
12413
/* L30: */
12414
}
12415
return 0;
12416
} /* srot_ */
12417
12418
/* Subroutine */ int sscal_(integer *n, real *sa, real *sx, integer *incx)
12419
{
12420
/* System generated locals */
12421
integer i__1, i__2;
12422
12423
/* Local variables */
12424
static integer i__, m, mp1, nincx;
12425
12426
12427
/*
12428
Purpose
12429
=======
12430
12431
scales a vector by a constant.
12432
uses unrolled loops for increment equal to 1.
12433
12434
Further Details
12435
===============
12436
12437
jack dongarra, linpack, 3/11/78.
12438
modified 3/93 to return if incx .le. 0.
12439
modified 12/3/93, array(1) declarations changed to array(*)
12440
12441
=====================================================================
12442
*/
12443
12444
/* Parameter adjustments */
12445
--sx;
12446
12447
/* Function Body */
12448
if (*n <= 0 || *incx <= 0) {
12449
return 0;
12450
}
12451
if (*incx == 1) {
12452
goto L20;
12453
}
12454
12455
/* code for increment not equal to 1 */
12456
12457
nincx = *n * *incx;
12458
i__1 = nincx;
12459
i__2 = *incx;
12460
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
12461
sx[i__] = *sa * sx[i__];
12462
/* L10: */
12463
}
12464
return 0;
12465
12466
/*
12467
code for increment equal to 1
12468
12469
12470
clean-up loop
12471
*/
12472
12473
L20:
12474
m = *n % 5;
12475
if (m == 0) {
12476
goto L40;
12477
}
12478
i__2 = m;
12479
for (i__ = 1; i__ <= i__2; ++i__) {
12480
sx[i__] = *sa * sx[i__];
12481
/* L30: */
12482
}
12483
if (*n < 5) {
12484
return 0;
12485
}
12486
L40:
12487
mp1 = m + 1;
12488
i__2 = *n;
12489
for (i__ = mp1; i__ <= i__2; i__ += 5) {
12490
sx[i__] = *sa * sx[i__];
12491
sx[i__ + 1] = *sa * sx[i__ + 1];
12492
sx[i__ + 2] = *sa * sx[i__ + 2];
12493
sx[i__ + 3] = *sa * sx[i__ + 3];
12494
sx[i__ + 4] = *sa * sx[i__ + 4];
12495
/* L50: */
12496
}
12497
return 0;
12498
} /* sscal_ */
12499
12500
/* Subroutine */ int sswap_(integer *n, real *sx, integer *incx, real *sy,
12501
integer *incy)
12502
{
12503
/* System generated locals */
12504
integer i__1;
12505
12506
/* Local variables */
12507
static integer i__, m, ix, iy, mp1;
12508
static real stemp;
12509
12510
12511
/*
12512
Purpose
12513
=======
12514
12515
interchanges two vectors.
12516
uses unrolled loops for increments equal to 1.
12517
12518
Further Details
12519
===============
12520
12521
jack dongarra, linpack, 3/11/78.
12522
modified 12/3/93, array(1) declarations changed to array(*)
12523
12524
=====================================================================
12525
*/
12526
12527
/* Parameter adjustments */
12528
--sy;
12529
--sx;
12530
12531
/* Function Body */
12532
if (*n <= 0) {
12533
return 0;
12534
}
12535
if (*incx == 1 && *incy == 1) {
12536
goto L20;
12537
}
12538
12539
/*
12540
code for unequal increments or equal increments not equal
12541
to 1
12542
*/
12543
12544
ix = 1;
12545
iy = 1;
12546
if (*incx < 0) {
12547
ix = (-(*n) + 1) * *incx + 1;
12548
}
12549
if (*incy < 0) {
12550
iy = (-(*n) + 1) * *incy + 1;
12551
}
12552
i__1 = *n;
12553
for (i__ = 1; i__ <= i__1; ++i__) {
12554
stemp = sx[ix];
12555
sx[ix] = sy[iy];
12556
sy[iy] = stemp;
12557
ix += *incx;
12558
iy += *incy;
12559
/* L10: */
12560
}
12561
return 0;
12562
12563
/*
12564
code for both increments equal to 1
12565
12566
12567
clean-up loop
12568
*/
12569
12570
L20:
12571
m = *n % 3;
12572
if (m == 0) {
12573
goto L40;
12574
}
12575
i__1 = m;
12576
for (i__ = 1; i__ <= i__1; ++i__) {
12577
stemp = sx[i__];
12578
sx[i__] = sy[i__];
12579
sy[i__] = stemp;
12580
/* L30: */
12581
}
12582
if (*n < 3) {
12583
return 0;
12584
}
12585
L40:
12586
mp1 = m + 1;
12587
i__1 = *n;
12588
for (i__ = mp1; i__ <= i__1; i__ += 3) {
12589
stemp = sx[i__];
12590
sx[i__] = sy[i__];
12591
sy[i__] = stemp;
12592
stemp = sx[i__ + 1];
12593
sx[i__ + 1] = sy[i__ + 1];
12594
sy[i__ + 1] = stemp;
12595
stemp = sx[i__ + 2];
12596
sx[i__ + 2] = sy[i__ + 2];
12597
sy[i__ + 2] = stemp;
12598
/* L50: */
12599
}
12600
return 0;
12601
} /* sswap_ */
12602
12603
/* Subroutine */ int ssymv_(char *uplo, integer *n, real *alpha, real *a,
12604
integer *lda, real *x, integer *incx, real *beta, real *y, integer *
12605
incy)
12606
{
12607
/* System generated locals */
12608
integer a_dim1, a_offset, i__1, i__2;
12609
12610
/* Local variables */
12611
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
12612
static real temp1, temp2;
12613
extern logical lsame_(char *, char *);
12614
extern /* Subroutine */ int xerbla_(char *, integer *);
12615
12616
12617
/*
12618
Purpose
12619
=======
12620
12621
SSYMV performs the matrix-vector operation
12622
12623
y := alpha*A*x + beta*y,
12624
12625
where alpha and beta are scalars, x and y are n element vectors and
12626
A is an n by n symmetric matrix.
12627
12628
Arguments
12629
==========
12630
12631
UPLO - CHARACTER*1.
12632
On entry, UPLO specifies whether the upper or lower
12633
triangular part of the array A is to be referenced as
12634
follows:
12635
12636
UPLO = 'U' or 'u' Only the upper triangular part of A
12637
is to be referenced.
12638
12639
UPLO = 'L' or 'l' Only the lower triangular part of A
12640
is to be referenced.
12641
12642
Unchanged on exit.
12643
12644
N - INTEGER.
12645
On entry, N specifies the order of the matrix A.
12646
N must be at least zero.
12647
Unchanged on exit.
12648
12649
ALPHA - REAL .
12650
On entry, ALPHA specifies the scalar alpha.
12651
Unchanged on exit.
12652
12653
A - REAL array of DIMENSION ( LDA, n ).
12654
Before entry with UPLO = 'U' or 'u', the leading n by n
12655
upper triangular part of the array A must contain the upper
12656
triangular part of the symmetric matrix and the strictly
12657
lower triangular part of A is not referenced.
12658
Before entry with UPLO = 'L' or 'l', the leading n by n
12659
lower triangular part of the array A must contain the lower
12660
triangular part of the symmetric matrix and the strictly
12661
upper triangular part of A is not referenced.
12662
Unchanged on exit.
12663
12664
LDA - INTEGER.
12665
On entry, LDA specifies the first dimension of A as declared
12666
in the calling (sub) program. LDA must be at least
12667
max( 1, n ).
12668
Unchanged on exit.
12669
12670
X - REAL array of dimension at least
12671
( 1 + ( n - 1 )*abs( INCX ) ).
12672
Before entry, the incremented array X must contain the n
12673
element vector x.
12674
Unchanged on exit.
12675
12676
INCX - INTEGER.
12677
On entry, INCX specifies the increment for the elements of
12678
X. INCX must not be zero.
12679
Unchanged on exit.
12680
12681
BETA - REAL .
12682
On entry, BETA specifies the scalar beta. When BETA is
12683
supplied as zero then Y need not be set on input.
12684
Unchanged on exit.
12685
12686
Y - REAL array of dimension at least
12687
( 1 + ( n - 1 )*abs( INCY ) ).
12688
Before entry, the incremented array Y must contain the n
12689
element vector y. On exit, Y is overwritten by the updated
12690
vector y.
12691
12692
INCY - INTEGER.
12693
On entry, INCY specifies the increment for the elements of
12694
Y. INCY must not be zero.
12695
Unchanged on exit.
12696
12697
Further Details
12698
===============
12699
12700
Level 2 Blas routine.
12701
12702
-- Written on 22-October-1986.
12703
Jack Dongarra, Argonne National Lab.
12704
Jeremy Du Croz, Nag Central Office.
12705
Sven Hammarling, Nag Central Office.
12706
Richard Hanson, Sandia National Labs.
12707
12708
=====================================================================
12709
12710
12711
Test the input parameters.
12712
*/
12713
12714
/* Parameter adjustments */
12715
a_dim1 = *lda;
12716
a_offset = 1 + a_dim1;
12717
a -= a_offset;
12718
--x;
12719
--y;
12720
12721
/* Function Body */
12722
info = 0;
12723
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
12724
info = 1;
12725
} else if (*n < 0) {
12726
info = 2;
12727
} else if (*lda < max(1,*n)) {
12728
info = 5;
12729
} else if (*incx == 0) {
12730
info = 7;
12731
} else if (*incy == 0) {
12732
info = 10;
12733
}
12734
if (info != 0) {
12735
xerbla_("SSYMV ", &info);
12736
return 0;
12737
}
12738
12739
/* Quick return if possible. */
12740
12741
if (*n == 0 || *alpha == 0.f && *beta == 1.f) {
12742
return 0;
12743
}
12744
12745
/* Set up the start points in X and Y. */
12746
12747
if (*incx > 0) {
12748
kx = 1;
12749
} else {
12750
kx = 1 - (*n - 1) * *incx;
12751
}
12752
if (*incy > 0) {
12753
ky = 1;
12754
} else {
12755
ky = 1 - (*n - 1) * *incy;
12756
}
12757
12758
/*
12759
Start the operations. In this version the elements of A are
12760
accessed sequentially with one pass through the triangular part
12761
of A.
12762
12763
First form y := beta*y.
12764
*/
12765
12766
if (*beta != 1.f) {
12767
if (*incy == 1) {
12768
if (*beta == 0.f) {
12769
i__1 = *n;
12770
for (i__ = 1; i__ <= i__1; ++i__) {
12771
y[i__] = 0.f;
12772
/* L10: */
12773
}
12774
} else {
12775
i__1 = *n;
12776
for (i__ = 1; i__ <= i__1; ++i__) {
12777
y[i__] = *beta * y[i__];
12778
/* L20: */
12779
}
12780
}
12781
} else {
12782
iy = ky;
12783
if (*beta == 0.f) {
12784
i__1 = *n;
12785
for (i__ = 1; i__ <= i__1; ++i__) {
12786
y[iy] = 0.f;
12787
iy += *incy;
12788
/* L30: */
12789
}
12790
} else {
12791
i__1 = *n;
12792
for (i__ = 1; i__ <= i__1; ++i__) {
12793
y[iy] = *beta * y[iy];
12794
iy += *incy;
12795
/* L40: */
12796
}
12797
}
12798
}
12799
}
12800
if (*alpha == 0.f) {
12801
return 0;
12802
}
12803
if (lsame_(uplo, "U")) {
12804
12805
/* Form y when A is stored in upper triangle. */
12806
12807
if (*incx == 1 && *incy == 1) {
12808
i__1 = *n;
12809
for (j = 1; j <= i__1; ++j) {
12810
temp1 = *alpha * x[j];
12811
temp2 = 0.f;
12812
i__2 = j - 1;
12813
for (i__ = 1; i__ <= i__2; ++i__) {
12814
y[i__] += temp1 * a[i__ + j * a_dim1];
12815
temp2 += a[i__ + j * a_dim1] * x[i__];
12816
/* L50: */
12817
}
12818
y[j] = y[j] + temp1 * a[j + j * a_dim1] + *alpha * temp2;
12819
/* L60: */
12820
}
12821
} else {
12822
jx = kx;
12823
jy = ky;
12824
i__1 = *n;
12825
for (j = 1; j <= i__1; ++j) {
12826
temp1 = *alpha * x[jx];
12827
temp2 = 0.f;
12828
ix = kx;
12829
iy = ky;
12830
i__2 = j - 1;
12831
for (i__ = 1; i__ <= i__2; ++i__) {
12832
y[iy] += temp1 * a[i__ + j * a_dim1];
12833
temp2 += a[i__ + j * a_dim1] * x[ix];
12834
ix += *incx;
12835
iy += *incy;
12836
/* L70: */
12837
}
12838
y[jy] = y[jy] + temp1 * a[j + j * a_dim1] + *alpha * temp2;
12839
jx += *incx;
12840
jy += *incy;
12841
/* L80: */
12842
}
12843
}
12844
} else {
12845
12846
/* Form y when A is stored in lower triangle. */
12847
12848
if (*incx == 1 && *incy == 1) {
12849
i__1 = *n;
12850
for (j = 1; j <= i__1; ++j) {
12851
temp1 = *alpha * x[j];
12852
temp2 = 0.f;
12853
y[j] += temp1 * a[j + j * a_dim1];
12854
i__2 = *n;
12855
for (i__ = j + 1; i__ <= i__2; ++i__) {
12856
y[i__] += temp1 * a[i__ + j * a_dim1];
12857
temp2 += a[i__ + j * a_dim1] * x[i__];
12858
/* L90: */
12859
}
12860
y[j] += *alpha * temp2;
12861
/* L100: */
12862
}
12863
} else {
12864
jx = kx;
12865
jy = ky;
12866
i__1 = *n;
12867
for (j = 1; j <= i__1; ++j) {
12868
temp1 = *alpha * x[jx];
12869
temp2 = 0.f;
12870
y[jy] += temp1 * a[j + j * a_dim1];
12871
ix = jx;
12872
iy = jy;
12873
i__2 = *n;
12874
for (i__ = j + 1; i__ <= i__2; ++i__) {
12875
ix += *incx;
12876
iy += *incy;
12877
y[iy] += temp1 * a[i__ + j * a_dim1];
12878
temp2 += a[i__ + j * a_dim1] * x[ix];
12879
/* L110: */
12880
}
12881
y[jy] += *alpha * temp2;
12882
jx += *incx;
12883
jy += *incy;
12884
/* L120: */
12885
}
12886
}
12887
}
12888
12889
return 0;
12890
12891
/* End of SSYMV . */
12892
12893
} /* ssymv_ */
12894
12895
/* Subroutine */ int ssyr2_(char *uplo, integer *n, real *alpha, real *x,
12896
integer *incx, real *y, integer *incy, real *a, integer *lda)
12897
{
12898
/* System generated locals */
12899
integer a_dim1, a_offset, i__1, i__2;
12900
12901
/* Local variables */
12902
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
12903
static real temp1, temp2;
12904
extern logical lsame_(char *, char *);
12905
extern /* Subroutine */ int xerbla_(char *, integer *);
12906
12907
12908
/*
12909
Purpose
12910
=======
12911
12912
SSYR2 performs the symmetric rank 2 operation
12913
12914
A := alpha*x*y' + alpha*y*x' + A,
12915
12916
where alpha is a scalar, x and y are n element vectors and A is an n
12917
by n symmetric matrix.
12918
12919
Arguments
12920
==========
12921
12922
UPLO - CHARACTER*1.
12923
On entry, UPLO specifies whether the upper or lower
12924
triangular part of the array A is to be referenced as
12925
follows:
12926
12927
UPLO = 'U' or 'u' Only the upper triangular part of A
12928
is to be referenced.
12929
12930
UPLO = 'L' or 'l' Only the lower triangular part of A
12931
is to be referenced.
12932
12933
Unchanged on exit.
12934
12935
N - INTEGER.
12936
On entry, N specifies the order of the matrix A.
12937
N must be at least zero.
12938
Unchanged on exit.
12939
12940
ALPHA - REAL .
12941
On entry, ALPHA specifies the scalar alpha.
12942
Unchanged on exit.
12943
12944
X - REAL array of dimension at least
12945
( 1 + ( n - 1 )*abs( INCX ) ).
12946
Before entry, the incremented array X must contain the n
12947
element vector x.
12948
Unchanged on exit.
12949
12950
INCX - INTEGER.
12951
On entry, INCX specifies the increment for the elements of
12952
X. INCX must not be zero.
12953
Unchanged on exit.
12954
12955
Y - REAL array of dimension at least
12956
( 1 + ( n - 1 )*abs( INCY ) ).
12957
Before entry, the incremented array Y must contain the n
12958
element vector y.
12959
Unchanged on exit.
12960
12961
INCY - INTEGER.
12962
On entry, INCY specifies the increment for the elements of
12963
Y. INCY must not be zero.
12964
Unchanged on exit.
12965
12966
A - REAL array of DIMENSION ( LDA, n ).
12967
Before entry with UPLO = 'U' or 'u', the leading n by n
12968
upper triangular part of the array A must contain the upper
12969
triangular part of the symmetric matrix and the strictly
12970
lower triangular part of A is not referenced. On exit, the
12971
upper triangular part of the array A is overwritten by the
12972
upper triangular part of the updated matrix.
12973
Before entry with UPLO = 'L' or 'l', the leading n by n
12974
lower triangular part of the array A must contain the lower
12975
triangular part of the symmetric matrix and the strictly
12976
upper triangular part of A is not referenced. On exit, the
12977
lower triangular part of the array A is overwritten by the
12978
lower triangular part of the updated matrix.
12979
12980
LDA - INTEGER.
12981
On entry, LDA specifies the first dimension of A as declared
12982
in the calling (sub) program. LDA must be at least
12983
max( 1, n ).
12984
Unchanged on exit.
12985
12986
Further Details
12987
===============
12988
12989
Level 2 Blas routine.
12990
12991
-- Written on 22-October-1986.
12992
Jack Dongarra, Argonne National Lab.
12993
Jeremy Du Croz, Nag Central Office.
12994
Sven Hammarling, Nag Central Office.
12995
Richard Hanson, Sandia National Labs.
12996
12997
=====================================================================
12998
12999
13000
Test the input parameters.
13001
*/
13002
13003
/* Parameter adjustments */
13004
--x;
13005
--y;
13006
a_dim1 = *lda;
13007
a_offset = 1 + a_dim1;
13008
a -= a_offset;
13009
13010
/* Function Body */
13011
info = 0;
13012
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
13013
info = 1;
13014
} else if (*n < 0) {
13015
info = 2;
13016
} else if (*incx == 0) {
13017
info = 5;
13018
} else if (*incy == 0) {
13019
info = 7;
13020
} else if (*lda < max(1,*n)) {
13021
info = 9;
13022
}
13023
if (info != 0) {
13024
xerbla_("SSYR2 ", &info);
13025
return 0;
13026
}
13027
13028
/* Quick return if possible. */
13029
13030
if (*n == 0 || *alpha == 0.f) {
13031
return 0;
13032
}
13033
13034
/*
13035
Set up the start points in X and Y if the increments are not both
13036
unity.
13037
*/
13038
13039
if (*incx != 1 || *incy != 1) {
13040
if (*incx > 0) {
13041
kx = 1;
13042
} else {
13043
kx = 1 - (*n - 1) * *incx;
13044
}
13045
if (*incy > 0) {
13046
ky = 1;
13047
} else {
13048
ky = 1 - (*n - 1) * *incy;
13049
}
13050
jx = kx;
13051
jy = ky;
13052
}
13053
13054
/*
13055
Start the operations. In this version the elements of A are
13056
accessed sequentially with one pass through the triangular part
13057
of A.
13058
*/
13059
13060
if (lsame_(uplo, "U")) {
13061
13062
/* Form A when A is stored in the upper triangle. */
13063
13064
if (*incx == 1 && *incy == 1) {
13065
i__1 = *n;
13066
for (j = 1; j <= i__1; ++j) {
13067
if (x[j] != 0.f || y[j] != 0.f) {
13068
temp1 = *alpha * y[j];
13069
temp2 = *alpha * x[j];
13070
i__2 = j;
13071
for (i__ = 1; i__ <= i__2; ++i__) {
13072
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
13073
temp1 + y[i__] * temp2;
13074
/* L10: */
13075
}
13076
}
13077
/* L20: */
13078
}
13079
} else {
13080
i__1 = *n;
13081
for (j = 1; j <= i__1; ++j) {
13082
if (x[jx] != 0.f || y[jy] != 0.f) {
13083
temp1 = *alpha * y[jy];
13084
temp2 = *alpha * x[jx];
13085
ix = kx;
13086
iy = ky;
13087
i__2 = j;
13088
for (i__ = 1; i__ <= i__2; ++i__) {
13089
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
13090
temp1 + y[iy] * temp2;
13091
ix += *incx;
13092
iy += *incy;
13093
/* L30: */
13094
}
13095
}
13096
jx += *incx;
13097
jy += *incy;
13098
/* L40: */
13099
}
13100
}
13101
} else {
13102
13103
/* Form A when A is stored in the lower triangle. */
13104
13105
if (*incx == 1 && *incy == 1) {
13106
i__1 = *n;
13107
for (j = 1; j <= i__1; ++j) {
13108
if (x[j] != 0.f || y[j] != 0.f) {
13109
temp1 = *alpha * y[j];
13110
temp2 = *alpha * x[j];
13111
i__2 = *n;
13112
for (i__ = j; i__ <= i__2; ++i__) {
13113
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
13114
temp1 + y[i__] * temp2;
13115
/* L50: */
13116
}
13117
}
13118
/* L60: */
13119
}
13120
} else {
13121
i__1 = *n;
13122
for (j = 1; j <= i__1; ++j) {
13123
if (x[jx] != 0.f || y[jy] != 0.f) {
13124
temp1 = *alpha * y[jy];
13125
temp2 = *alpha * x[jx];
13126
ix = jx;
13127
iy = jy;
13128
i__2 = *n;
13129
for (i__ = j; i__ <= i__2; ++i__) {
13130
a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
13131
temp1 + y[iy] * temp2;
13132
ix += *incx;
13133
iy += *incy;
13134
/* L70: */
13135
}
13136
}
13137
jx += *incx;
13138
jy += *incy;
13139
/* L80: */
13140
}
13141
}
13142
}
13143
13144
return 0;
13145
13146
/* End of SSYR2 . */
13147
13148
} /* ssyr2_ */
13149
13150
/* Subroutine */ int ssyr2k_(char *uplo, char *trans, integer *n, integer *k,
13151
real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta,
13152
real *c__, integer *ldc)
13153
{
13154
/* System generated locals */
13155
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
13156
i__3;
13157
13158
/* Local variables */
13159
static integer i__, j, l, info;
13160
static real temp1, temp2;
13161
extern logical lsame_(char *, char *);
13162
static integer nrowa;
13163
static logical upper;
13164
extern /* Subroutine */ int xerbla_(char *, integer *);
13165
13166
13167
/*
13168
Purpose
13169
=======
13170
13171
SSYR2K performs one of the symmetric rank 2k operations
13172
13173
C := alpha*A*B' + alpha*B*A' + beta*C,
13174
13175
or
13176
13177
C := alpha*A'*B + alpha*B'*A + beta*C,
13178
13179
where alpha and beta are scalars, C is an n by n symmetric matrix
13180
and A and B are n by k matrices in the first case and k by n
13181
matrices in the second case.
13182
13183
Arguments
13184
==========
13185
13186
UPLO - CHARACTER*1.
13187
On entry, UPLO specifies whether the upper or lower
13188
triangular part of the array C is to be referenced as
13189
follows:
13190
13191
UPLO = 'U' or 'u' Only the upper triangular part of C
13192
is to be referenced.
13193
13194
UPLO = 'L' or 'l' Only the lower triangular part of C
13195
is to be referenced.
13196
13197
Unchanged on exit.
13198
13199
TRANS - CHARACTER*1.
13200
On entry, TRANS specifies the operation to be performed as
13201
follows:
13202
13203
TRANS = 'N' or 'n' C := alpha*A*B' + alpha*B*A' +
13204
beta*C.
13205
13206
TRANS = 'T' or 't' C := alpha*A'*B + alpha*B'*A +
13207
beta*C.
13208
13209
TRANS = 'C' or 'c' C := alpha*A'*B + alpha*B'*A +
13210
beta*C.
13211
13212
Unchanged on exit.
13213
13214
N - INTEGER.
13215
On entry, N specifies the order of the matrix C. N must be
13216
at least zero.
13217
Unchanged on exit.
13218
13219
K - INTEGER.
13220
On entry with TRANS = 'N' or 'n', K specifies the number
13221
of columns of the matrices A and B, and on entry with
13222
TRANS = 'T' or 't' or 'C' or 'c', K specifies the number
13223
of rows of the matrices A and B. K must be at least zero.
13224
Unchanged on exit.
13225
13226
ALPHA - REAL .
13227
On entry, ALPHA specifies the scalar alpha.
13228
Unchanged on exit.
13229
13230
A - REAL array of DIMENSION ( LDA, ka ), where ka is
13231
k when TRANS = 'N' or 'n', and is n otherwise.
13232
Before entry with TRANS = 'N' or 'n', the leading n by k
13233
part of the array A must contain the matrix A, otherwise
13234
the leading k by n part of the array A must contain the
13235
matrix A.
13236
Unchanged on exit.
13237
13238
LDA - INTEGER.
13239
On entry, LDA specifies the first dimension of A as declared
13240
in the calling (sub) program. When TRANS = 'N' or 'n'
13241
then LDA must be at least max( 1, n ), otherwise LDA must
13242
be at least max( 1, k ).
13243
Unchanged on exit.
13244
13245
B - REAL array of DIMENSION ( LDB, kb ), where kb is
13246
k when TRANS = 'N' or 'n', and is n otherwise.
13247
Before entry with TRANS = 'N' or 'n', the leading n by k
13248
part of the array B must contain the matrix B, otherwise
13249
the leading k by n part of the array B must contain the
13250
matrix B.
13251
Unchanged on exit.
13252
13253
LDB - INTEGER.
13254
On entry, LDB specifies the first dimension of B as declared
13255
in the calling (sub) program. When TRANS = 'N' or 'n'
13256
then LDB must be at least max( 1, n ), otherwise LDB must
13257
be at least max( 1, k ).
13258
Unchanged on exit.
13259
13260
BETA - REAL .
13261
On entry, BETA specifies the scalar beta.
13262
Unchanged on exit.
13263
13264
C - REAL array of DIMENSION ( LDC, n ).
13265
Before entry with UPLO = 'U' or 'u', the leading n by n
13266
upper triangular part of the array C must contain the upper
13267
triangular part of the symmetric matrix and the strictly
13268
lower triangular part of C is not referenced. On exit, the
13269
upper triangular part of the array C is overwritten by the
13270
upper triangular part of the updated matrix.
13271
Before entry with UPLO = 'L' or 'l', the leading n by n
13272
lower triangular part of the array C must contain the lower
13273
triangular part of the symmetric matrix and the strictly
13274
upper triangular part of C is not referenced. On exit, the
13275
lower triangular part of the array C is overwritten by the
13276
lower triangular part of the updated matrix.
13277
13278
LDC - INTEGER.
13279
On entry, LDC specifies the first dimension of C as declared
13280
in the calling (sub) program. LDC must be at least
13281
max( 1, n ).
13282
Unchanged on exit.
13283
13284
Further Details
13285
===============
13286
13287
Level 3 Blas routine.
13288
13289
13290
-- Written on 8-February-1989.
13291
Jack Dongarra, Argonne National Laboratory.
13292
Iain Duff, AERE Harwell.
13293
Jeremy Du Croz, Numerical Algorithms Group Ltd.
13294
Sven Hammarling, Numerical Algorithms Group Ltd.
13295
13296
=====================================================================
13297
13298
13299
Test the input parameters.
13300
*/
13301
13302
/* Parameter adjustments */
13303
a_dim1 = *lda;
13304
a_offset = 1 + a_dim1;
13305
a -= a_offset;
13306
b_dim1 = *ldb;
13307
b_offset = 1 + b_dim1;
13308
b -= b_offset;
13309
c_dim1 = *ldc;
13310
c_offset = 1 + c_dim1;
13311
c__ -= c_offset;
13312
13313
/* Function Body */
13314
if (lsame_(trans, "N")) {
13315
nrowa = *n;
13316
} else {
13317
nrowa = *k;
13318
}
13319
upper = lsame_(uplo, "U");
13320
13321
info = 0;
13322
if (! upper && ! lsame_(uplo, "L")) {
13323
info = 1;
13324
} else if (! lsame_(trans, "N") && ! lsame_(trans,
13325
"T") && ! lsame_(trans, "C")) {
13326
info = 2;
13327
} else if (*n < 0) {
13328
info = 3;
13329
} else if (*k < 0) {
13330
info = 4;
13331
} else if (*lda < max(1,nrowa)) {
13332
info = 7;
13333
} else if (*ldb < max(1,nrowa)) {
13334
info = 9;
13335
} else if (*ldc < max(1,*n)) {
13336
info = 12;
13337
}
13338
if (info != 0) {
13339
xerbla_("SSYR2K", &info);
13340
return 0;
13341
}
13342
13343
/* Quick return if possible. */
13344
13345
if (*n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
13346
return 0;
13347
}
13348
13349
/* And when alpha.eq.zero. */
13350
13351
if (*alpha == 0.f) {
13352
if (upper) {
13353
if (*beta == 0.f) {
13354
i__1 = *n;
13355
for (j = 1; j <= i__1; ++j) {
13356
i__2 = j;
13357
for (i__ = 1; i__ <= i__2; ++i__) {
13358
c__[i__ + j * c_dim1] = 0.f;
13359
/* L10: */
13360
}
13361
/* L20: */
13362
}
13363
} else {
13364
i__1 = *n;
13365
for (j = 1; j <= i__1; ++j) {
13366
i__2 = j;
13367
for (i__ = 1; i__ <= i__2; ++i__) {
13368
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13369
/* L30: */
13370
}
13371
/* L40: */
13372
}
13373
}
13374
} else {
13375
if (*beta == 0.f) {
13376
i__1 = *n;
13377
for (j = 1; j <= i__1; ++j) {
13378
i__2 = *n;
13379
for (i__ = j; i__ <= i__2; ++i__) {
13380
c__[i__ + j * c_dim1] = 0.f;
13381
/* L50: */
13382
}
13383
/* L60: */
13384
}
13385
} else {
13386
i__1 = *n;
13387
for (j = 1; j <= i__1; ++j) {
13388
i__2 = *n;
13389
for (i__ = j; i__ <= i__2; ++i__) {
13390
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13391
/* L70: */
13392
}
13393
/* L80: */
13394
}
13395
}
13396
}
13397
return 0;
13398
}
13399
13400
/* Start the operations. */
13401
13402
if (lsame_(trans, "N")) {
13403
13404
/* Form C := alpha*A*B' + alpha*B*A' + C. */
13405
13406
if (upper) {
13407
i__1 = *n;
13408
for (j = 1; j <= i__1; ++j) {
13409
if (*beta == 0.f) {
13410
i__2 = j;
13411
for (i__ = 1; i__ <= i__2; ++i__) {
13412
c__[i__ + j * c_dim1] = 0.f;
13413
/* L90: */
13414
}
13415
} else if (*beta != 1.f) {
13416
i__2 = j;
13417
for (i__ = 1; i__ <= i__2; ++i__) {
13418
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13419
/* L100: */
13420
}
13421
}
13422
i__2 = *k;
13423
for (l = 1; l <= i__2; ++l) {
13424
if (a[j + l * a_dim1] != 0.f || b[j + l * b_dim1] != 0.f)
13425
{
13426
temp1 = *alpha * b[j + l * b_dim1];
13427
temp2 = *alpha * a[j + l * a_dim1];
13428
i__3 = j;
13429
for (i__ = 1; i__ <= i__3; ++i__) {
13430
c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
13431
i__ + l * a_dim1] * temp1 + b[i__ + l *
13432
b_dim1] * temp2;
13433
/* L110: */
13434
}
13435
}
13436
/* L120: */
13437
}
13438
/* L130: */
13439
}
13440
} else {
13441
i__1 = *n;
13442
for (j = 1; j <= i__1; ++j) {
13443
if (*beta == 0.f) {
13444
i__2 = *n;
13445
for (i__ = j; i__ <= i__2; ++i__) {
13446
c__[i__ + j * c_dim1] = 0.f;
13447
/* L140: */
13448
}
13449
} else if (*beta != 1.f) {
13450
i__2 = *n;
13451
for (i__ = j; i__ <= i__2; ++i__) {
13452
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13453
/* L150: */
13454
}
13455
}
13456
i__2 = *k;
13457
for (l = 1; l <= i__2; ++l) {
13458
if (a[j + l * a_dim1] != 0.f || b[j + l * b_dim1] != 0.f)
13459
{
13460
temp1 = *alpha * b[j + l * b_dim1];
13461
temp2 = *alpha * a[j + l * a_dim1];
13462
i__3 = *n;
13463
for (i__ = j; i__ <= i__3; ++i__) {
13464
c__[i__ + j * c_dim1] = c__[i__ + j * c_dim1] + a[
13465
i__ + l * a_dim1] * temp1 + b[i__ + l *
13466
b_dim1] * temp2;
13467
/* L160: */
13468
}
13469
}
13470
/* L170: */
13471
}
13472
/* L180: */
13473
}
13474
}
13475
} else {
13476
13477
/* Form C := alpha*A'*B + alpha*B'*A + C. */
13478
13479
if (upper) {
13480
i__1 = *n;
13481
for (j = 1; j <= i__1; ++j) {
13482
i__2 = j;
13483
for (i__ = 1; i__ <= i__2; ++i__) {
13484
temp1 = 0.f;
13485
temp2 = 0.f;
13486
i__3 = *k;
13487
for (l = 1; l <= i__3; ++l) {
13488
temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
13489
temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
13490
/* L190: */
13491
}
13492
if (*beta == 0.f) {
13493
c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
13494
temp2;
13495
} else {
13496
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
13497
+ *alpha * temp1 + *alpha * temp2;
13498
}
13499
/* L200: */
13500
}
13501
/* L210: */
13502
}
13503
} else {
13504
i__1 = *n;
13505
for (j = 1; j <= i__1; ++j) {
13506
i__2 = *n;
13507
for (i__ = j; i__ <= i__2; ++i__) {
13508
temp1 = 0.f;
13509
temp2 = 0.f;
13510
i__3 = *k;
13511
for (l = 1; l <= i__3; ++l) {
13512
temp1 += a[l + i__ * a_dim1] * b[l + j * b_dim1];
13513
temp2 += b[l + i__ * b_dim1] * a[l + j * a_dim1];
13514
/* L220: */
13515
}
13516
if (*beta == 0.f) {
13517
c__[i__ + j * c_dim1] = *alpha * temp1 + *alpha *
13518
temp2;
13519
} else {
13520
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1]
13521
+ *alpha * temp1 + *alpha * temp2;
13522
}
13523
/* L230: */
13524
}
13525
/* L240: */
13526
}
13527
}
13528
}
13529
13530
return 0;
13531
13532
/* End of SSYR2K. */
13533
13534
} /* ssyr2k_ */
13535
13536
/* Subroutine */ int ssyrk_(char *uplo, char *trans, integer *n, integer *k,
13537
real *alpha, real *a, integer *lda, real *beta, real *c__, integer *
13538
ldc)
13539
{
13540
/* System generated locals */
13541
integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3;
13542
13543
/* Local variables */
13544
static integer i__, j, l, info;
13545
static real temp;
13546
extern logical lsame_(char *, char *);
13547
static integer nrowa;
13548
static logical upper;
13549
extern /* Subroutine */ int xerbla_(char *, integer *);
13550
13551
13552
/*
13553
Purpose
13554
=======
13555
13556
SSYRK performs one of the symmetric rank k operations
13557
13558
C := alpha*A*A' + beta*C,
13559
13560
or
13561
13562
C := alpha*A'*A + beta*C,
13563
13564
where alpha and beta are scalars, C is an n by n symmetric matrix
13565
and A is an n by k matrix in the first case and a k by n matrix
13566
in the second case.
13567
13568
Arguments
13569
==========
13570
13571
UPLO - CHARACTER*1.
13572
On entry, UPLO specifies whether the upper or lower
13573
triangular part of the array C is to be referenced as
13574
follows:
13575
13576
UPLO = 'U' or 'u' Only the upper triangular part of C
13577
is to be referenced.
13578
13579
UPLO = 'L' or 'l' Only the lower triangular part of C
13580
is to be referenced.
13581
13582
Unchanged on exit.
13583
13584
TRANS - CHARACTER*1.
13585
On entry, TRANS specifies the operation to be performed as
13586
follows:
13587
13588
TRANS = 'N' or 'n' C := alpha*A*A' + beta*C.
13589
13590
TRANS = 'T' or 't' C := alpha*A'*A + beta*C.
13591
13592
TRANS = 'C' or 'c' C := alpha*A'*A + beta*C.
13593
13594
Unchanged on exit.
13595
13596
N - INTEGER.
13597
On entry, N specifies the order of the matrix C. N must be
13598
at least zero.
13599
Unchanged on exit.
13600
13601
K - INTEGER.
13602
On entry with TRANS = 'N' or 'n', K specifies the number
13603
of columns of the matrix A, and on entry with
13604
TRANS = 'T' or 't' or 'C' or 'c', K specifies the number
13605
of rows of the matrix A. K must be at least zero.
13606
Unchanged on exit.
13607
13608
ALPHA - REAL .
13609
On entry, ALPHA specifies the scalar alpha.
13610
Unchanged on exit.
13611
13612
A - REAL array of DIMENSION ( LDA, ka ), where ka is
13613
k when TRANS = 'N' or 'n', and is n otherwise.
13614
Before entry with TRANS = 'N' or 'n', the leading n by k
13615
part of the array A must contain the matrix A, otherwise
13616
the leading k by n part of the array A must contain the
13617
matrix A.
13618
Unchanged on exit.
13619
13620
LDA - INTEGER.
13621
On entry, LDA specifies the first dimension of A as declared
13622
in the calling (sub) program. When TRANS = 'N' or 'n'
13623
then LDA must be at least max( 1, n ), otherwise LDA must
13624
be at least max( 1, k ).
13625
Unchanged on exit.
13626
13627
BETA - REAL .
13628
On entry, BETA specifies the scalar beta.
13629
Unchanged on exit.
13630
13631
C - REAL array of DIMENSION ( LDC, n ).
13632
Before entry with UPLO = 'U' or 'u', the leading n by n
13633
upper triangular part of the array C must contain the upper
13634
triangular part of the symmetric matrix and the strictly
13635
lower triangular part of C is not referenced. On exit, the
13636
upper triangular part of the array C is overwritten by the
13637
upper triangular part of the updated matrix.
13638
Before entry with UPLO = 'L' or 'l', the leading n by n
13639
lower triangular part of the array C must contain the lower
13640
triangular part of the symmetric matrix and the strictly
13641
upper triangular part of C is not referenced. On exit, the
13642
lower triangular part of the array C is overwritten by the
13643
lower triangular part of the updated matrix.
13644
13645
LDC - INTEGER.
13646
On entry, LDC specifies the first dimension of C as declared
13647
in the calling (sub) program. LDC must be at least
13648
max( 1, n ).
13649
Unchanged on exit.
13650
13651
Further Details
13652
===============
13653
13654
Level 3 Blas routine.
13655
13656
-- Written on 8-February-1989.
13657
Jack Dongarra, Argonne National Laboratory.
13658
Iain Duff, AERE Harwell.
13659
Jeremy Du Croz, Numerical Algorithms Group Ltd.
13660
Sven Hammarling, Numerical Algorithms Group Ltd.
13661
13662
=====================================================================
13663
13664
13665
Test the input parameters.
13666
*/
13667
13668
/* Parameter adjustments */
13669
a_dim1 = *lda;
13670
a_offset = 1 + a_dim1;
13671
a -= a_offset;
13672
c_dim1 = *ldc;
13673
c_offset = 1 + c_dim1;
13674
c__ -= c_offset;
13675
13676
/* Function Body */
13677
if (lsame_(trans, "N")) {
13678
nrowa = *n;
13679
} else {
13680
nrowa = *k;
13681
}
13682
upper = lsame_(uplo, "U");
13683
13684
info = 0;
13685
if (! upper && ! lsame_(uplo, "L")) {
13686
info = 1;
13687
} else if (! lsame_(trans, "N") && ! lsame_(trans,
13688
"T") && ! lsame_(trans, "C")) {
13689
info = 2;
13690
} else if (*n < 0) {
13691
info = 3;
13692
} else if (*k < 0) {
13693
info = 4;
13694
} else if (*lda < max(1,nrowa)) {
13695
info = 7;
13696
} else if (*ldc < max(1,*n)) {
13697
info = 10;
13698
}
13699
if (info != 0) {
13700
xerbla_("SSYRK ", &info);
13701
return 0;
13702
}
13703
13704
/* Quick return if possible. */
13705
13706
if (*n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
13707
return 0;
13708
}
13709
13710
/* And when alpha.eq.zero. */
13711
13712
if (*alpha == 0.f) {
13713
if (upper) {
13714
if (*beta == 0.f) {
13715
i__1 = *n;
13716
for (j = 1; j <= i__1; ++j) {
13717
i__2 = j;
13718
for (i__ = 1; i__ <= i__2; ++i__) {
13719
c__[i__ + j * c_dim1] = 0.f;
13720
/* L10: */
13721
}
13722
/* L20: */
13723
}
13724
} else {
13725
i__1 = *n;
13726
for (j = 1; j <= i__1; ++j) {
13727
i__2 = j;
13728
for (i__ = 1; i__ <= i__2; ++i__) {
13729
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13730
/* L30: */
13731
}
13732
/* L40: */
13733
}
13734
}
13735
} else {
13736
if (*beta == 0.f) {
13737
i__1 = *n;
13738
for (j = 1; j <= i__1; ++j) {
13739
i__2 = *n;
13740
for (i__ = j; i__ <= i__2; ++i__) {
13741
c__[i__ + j * c_dim1] = 0.f;
13742
/* L50: */
13743
}
13744
/* L60: */
13745
}
13746
} else {
13747
i__1 = *n;
13748
for (j = 1; j <= i__1; ++j) {
13749
i__2 = *n;
13750
for (i__ = j; i__ <= i__2; ++i__) {
13751
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13752
/* L70: */
13753
}
13754
/* L80: */
13755
}
13756
}
13757
}
13758
return 0;
13759
}
13760
13761
/* Start the operations. */
13762
13763
if (lsame_(trans, "N")) {
13764
13765
/* Form C := alpha*A*A' + beta*C. */
13766
13767
if (upper) {
13768
i__1 = *n;
13769
for (j = 1; j <= i__1; ++j) {
13770
if (*beta == 0.f) {
13771
i__2 = j;
13772
for (i__ = 1; i__ <= i__2; ++i__) {
13773
c__[i__ + j * c_dim1] = 0.f;
13774
/* L90: */
13775
}
13776
} else if (*beta != 1.f) {
13777
i__2 = j;
13778
for (i__ = 1; i__ <= i__2; ++i__) {
13779
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13780
/* L100: */
13781
}
13782
}
13783
i__2 = *k;
13784
for (l = 1; l <= i__2; ++l) {
13785
if (a[j + l * a_dim1] != 0.f) {
13786
temp = *alpha * a[j + l * a_dim1];
13787
i__3 = j;
13788
for (i__ = 1; i__ <= i__3; ++i__) {
13789
c__[i__ + j * c_dim1] += temp * a[i__ + l *
13790
a_dim1];
13791
/* L110: */
13792
}
13793
}
13794
/* L120: */
13795
}
13796
/* L130: */
13797
}
13798
} else {
13799
i__1 = *n;
13800
for (j = 1; j <= i__1; ++j) {
13801
if (*beta == 0.f) {
13802
i__2 = *n;
13803
for (i__ = j; i__ <= i__2; ++i__) {
13804
c__[i__ + j * c_dim1] = 0.f;
13805
/* L140: */
13806
}
13807
} else if (*beta != 1.f) {
13808
i__2 = *n;
13809
for (i__ = j; i__ <= i__2; ++i__) {
13810
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
13811
/* L150: */
13812
}
13813
}
13814
i__2 = *k;
13815
for (l = 1; l <= i__2; ++l) {
13816
if (a[j + l * a_dim1] != 0.f) {
13817
temp = *alpha * a[j + l * a_dim1];
13818
i__3 = *n;
13819
for (i__ = j; i__ <= i__3; ++i__) {
13820
c__[i__ + j * c_dim1] += temp * a[i__ + l *
13821
a_dim1];
13822
/* L160: */
13823
}
13824
}
13825
/* L170: */
13826
}
13827
/* L180: */
13828
}
13829
}
13830
} else {
13831
13832
/* Form C := alpha*A'*A + beta*C. */
13833
13834
if (upper) {
13835
i__1 = *n;
13836
for (j = 1; j <= i__1; ++j) {
13837
i__2 = j;
13838
for (i__ = 1; i__ <= i__2; ++i__) {
13839
temp = 0.f;
13840
i__3 = *k;
13841
for (l = 1; l <= i__3; ++l) {
13842
temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
13843
/* L190: */
13844
}
13845
if (*beta == 0.f) {
13846
c__[i__ + j * c_dim1] = *alpha * temp;
13847
} else {
13848
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
13849
i__ + j * c_dim1];
13850
}
13851
/* L200: */
13852
}
13853
/* L210: */
13854
}
13855
} else {
13856
i__1 = *n;
13857
for (j = 1; j <= i__1; ++j) {
13858
i__2 = *n;
13859
for (i__ = j; i__ <= i__2; ++i__) {
13860
temp = 0.f;
13861
i__3 = *k;
13862
for (l = 1; l <= i__3; ++l) {
13863
temp += a[l + i__ * a_dim1] * a[l + j * a_dim1];
13864
/* L220: */
13865
}
13866
if (*beta == 0.f) {
13867
c__[i__ + j * c_dim1] = *alpha * temp;
13868
} else {
13869
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
13870
i__ + j * c_dim1];
13871
}
13872
/* L230: */
13873
}
13874
/* L240: */
13875
}
13876
}
13877
}
13878
13879
return 0;
13880
13881
/* End of SSYRK . */
13882
13883
} /* ssyrk_ */
13884
13885
/* Subroutine */ int strmm_(char *side, char *uplo, char *transa, char *diag,
13886
integer *m, integer *n, real *alpha, real *a, integer *lda, real *b,
13887
integer *ldb)
13888
{
13889
/* System generated locals */
13890
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
13891
13892
/* Local variables */
13893
static integer i__, j, k, info;
13894
static real temp;
13895
static logical lside;
13896
extern logical lsame_(char *, char *);
13897
static integer nrowa;
13898
static logical upper;
13899
extern /* Subroutine */ int xerbla_(char *, integer *);
13900
static logical nounit;
13901
13902
13903
/*
13904
Purpose
13905
=======
13906
13907
STRMM performs one of the matrix-matrix operations
13908
13909
B := alpha*op( A )*B, or B := alpha*B*op( A ),
13910
13911
where alpha is a scalar, B is an m by n matrix, A is a unit, or
13912
non-unit, upper or lower triangular matrix and op( A ) is one of
13913
13914
op( A ) = A or op( A ) = A'.
13915
13916
Arguments
13917
==========
13918
13919
SIDE - CHARACTER*1.
13920
On entry, SIDE specifies whether op( A ) multiplies B from
13921
the left or right as follows:
13922
13923
SIDE = 'L' or 'l' B := alpha*op( A )*B.
13924
13925
SIDE = 'R' or 'r' B := alpha*B*op( A ).
13926
13927
Unchanged on exit.
13928
13929
UPLO - CHARACTER*1.
13930
On entry, UPLO specifies whether the matrix A is an upper or
13931
lower triangular matrix as follows:
13932
13933
UPLO = 'U' or 'u' A is an upper triangular matrix.
13934
13935
UPLO = 'L' or 'l' A is a lower triangular matrix.
13936
13937
Unchanged on exit.
13938
13939
TRANSA - CHARACTER*1.
13940
On entry, TRANSA specifies the form of op( A ) to be used in
13941
the matrix multiplication as follows:
13942
13943
TRANSA = 'N' or 'n' op( A ) = A.
13944
13945
TRANSA = 'T' or 't' op( A ) = A'.
13946
13947
TRANSA = 'C' or 'c' op( A ) = A'.
13948
13949
Unchanged on exit.
13950
13951
DIAG - CHARACTER*1.
13952
On entry, DIAG specifies whether or not A is unit triangular
13953
as follows:
13954
13955
DIAG = 'U' or 'u' A is assumed to be unit triangular.
13956
13957
DIAG = 'N' or 'n' A is not assumed to be unit
13958
triangular.
13959
13960
Unchanged on exit.
13961
13962
M - INTEGER.
13963
On entry, M specifies the number of rows of B. M must be at
13964
least zero.
13965
Unchanged on exit.
13966
13967
N - INTEGER.
13968
On entry, N specifies the number of columns of B. N must be
13969
at least zero.
13970
Unchanged on exit.
13971
13972
ALPHA - REAL .
13973
On entry, ALPHA specifies the scalar alpha. When alpha is
13974
zero then A is not referenced and B need not be set before
13975
entry.
13976
Unchanged on exit.
13977
13978
A - REAL array of DIMENSION ( LDA, k ), where k is m
13979
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
13980
Before entry with UPLO = 'U' or 'u', the leading k by k
13981
upper triangular part of the array A must contain the upper
13982
triangular matrix and the strictly lower triangular part of
13983
A is not referenced.
13984
Before entry with UPLO = 'L' or 'l', the leading k by k
13985
lower triangular part of the array A must contain the lower
13986
triangular matrix and the strictly upper triangular part of
13987
A is not referenced.
13988
Note that when DIAG = 'U' or 'u', the diagonal elements of
13989
A are not referenced either, but are assumed to be unity.
13990
Unchanged on exit.
13991
13992
LDA - INTEGER.
13993
On entry, LDA specifies the first dimension of A as declared
13994
in the calling (sub) program. When SIDE = 'L' or 'l' then
13995
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
13996
then LDA must be at least max( 1, n ).
13997
Unchanged on exit.
13998
13999
B - REAL array of DIMENSION ( LDB, n ).
14000
Before entry, the leading m by n part of the array B must
14001
contain the matrix B, and on exit is overwritten by the
14002
transformed matrix.
14003
14004
LDB - INTEGER.
14005
On entry, LDB specifies the first dimension of B as declared
14006
in the calling (sub) program. LDB must be at least
14007
max( 1, m ).
14008
Unchanged on exit.
14009
14010
Further Details
14011
===============
14012
14013
Level 3 Blas routine.
14014
14015
-- Written on 8-February-1989.
14016
Jack Dongarra, Argonne National Laboratory.
14017
Iain Duff, AERE Harwell.
14018
Jeremy Du Croz, Numerical Algorithms Group Ltd.
14019
Sven Hammarling, Numerical Algorithms Group Ltd.
14020
14021
=====================================================================
14022
14023
14024
Test the input parameters.
14025
*/
14026
14027
/* Parameter adjustments */
14028
a_dim1 = *lda;
14029
a_offset = 1 + a_dim1;
14030
a -= a_offset;
14031
b_dim1 = *ldb;
14032
b_offset = 1 + b_dim1;
14033
b -= b_offset;
14034
14035
/* Function Body */
14036
lside = lsame_(side, "L");
14037
if (lside) {
14038
nrowa = *m;
14039
} else {
14040
nrowa = *n;
14041
}
14042
nounit = lsame_(diag, "N");
14043
upper = lsame_(uplo, "U");
14044
14045
info = 0;
14046
if (! lside && ! lsame_(side, "R")) {
14047
info = 1;
14048
} else if (! upper && ! lsame_(uplo, "L")) {
14049
info = 2;
14050
} else if (! lsame_(transa, "N") && ! lsame_(transa,
14051
"T") && ! lsame_(transa, "C")) {
14052
info = 3;
14053
} else if (! lsame_(diag, "U") && ! lsame_(diag,
14054
"N")) {
14055
info = 4;
14056
} else if (*m < 0) {
14057
info = 5;
14058
} else if (*n < 0) {
14059
info = 6;
14060
} else if (*lda < max(1,nrowa)) {
14061
info = 9;
14062
} else if (*ldb < max(1,*m)) {
14063
info = 11;
14064
}
14065
if (info != 0) {
14066
xerbla_("STRMM ", &info);
14067
return 0;
14068
}
14069
14070
/* Quick return if possible. */
14071
14072
if (*m == 0 || *n == 0) {
14073
return 0;
14074
}
14075
14076
/* And when alpha.eq.zero. */
14077
14078
if (*alpha == 0.f) {
14079
i__1 = *n;
14080
for (j = 1; j <= i__1; ++j) {
14081
i__2 = *m;
14082
for (i__ = 1; i__ <= i__2; ++i__) {
14083
b[i__ + j * b_dim1] = 0.f;
14084
/* L10: */
14085
}
14086
/* L20: */
14087
}
14088
return 0;
14089
}
14090
14091
/* Start the operations. */
14092
14093
if (lside) {
14094
if (lsame_(transa, "N")) {
14095
14096
/* Form B := alpha*A*B. */
14097
14098
if (upper) {
14099
i__1 = *n;
14100
for (j = 1; j <= i__1; ++j) {
14101
i__2 = *m;
14102
for (k = 1; k <= i__2; ++k) {
14103
if (b[k + j * b_dim1] != 0.f) {
14104
temp = *alpha * b[k + j * b_dim1];
14105
i__3 = k - 1;
14106
for (i__ = 1; i__ <= i__3; ++i__) {
14107
b[i__ + j * b_dim1] += temp * a[i__ + k *
14108
a_dim1];
14109
/* L30: */
14110
}
14111
if (nounit) {
14112
temp *= a[k + k * a_dim1];
14113
}
14114
b[k + j * b_dim1] = temp;
14115
}
14116
/* L40: */
14117
}
14118
/* L50: */
14119
}
14120
} else {
14121
i__1 = *n;
14122
for (j = 1; j <= i__1; ++j) {
14123
for (k = *m; k >= 1; --k) {
14124
if (b[k + j * b_dim1] != 0.f) {
14125
temp = *alpha * b[k + j * b_dim1];
14126
b[k + j * b_dim1] = temp;
14127
if (nounit) {
14128
b[k + j * b_dim1] *= a[k + k * a_dim1];
14129
}
14130
i__2 = *m;
14131
for (i__ = k + 1; i__ <= i__2; ++i__) {
14132
b[i__ + j * b_dim1] += temp * a[i__ + k *
14133
a_dim1];
14134
/* L60: */
14135
}
14136
}
14137
/* L70: */
14138
}
14139
/* L80: */
14140
}
14141
}
14142
} else {
14143
14144
/* Form B := alpha*A'*B. */
14145
14146
if (upper) {
14147
i__1 = *n;
14148
for (j = 1; j <= i__1; ++j) {
14149
for (i__ = *m; i__ >= 1; --i__) {
14150
temp = b[i__ + j * b_dim1];
14151
if (nounit) {
14152
temp *= a[i__ + i__ * a_dim1];
14153
}
14154
i__2 = i__ - 1;
14155
for (k = 1; k <= i__2; ++k) {
14156
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
14157
/* L90: */
14158
}
14159
b[i__ + j * b_dim1] = *alpha * temp;
14160
/* L100: */
14161
}
14162
/* L110: */
14163
}
14164
} else {
14165
i__1 = *n;
14166
for (j = 1; j <= i__1; ++j) {
14167
i__2 = *m;
14168
for (i__ = 1; i__ <= i__2; ++i__) {
14169
temp = b[i__ + j * b_dim1];
14170
if (nounit) {
14171
temp *= a[i__ + i__ * a_dim1];
14172
}
14173
i__3 = *m;
14174
for (k = i__ + 1; k <= i__3; ++k) {
14175
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
14176
/* L120: */
14177
}
14178
b[i__ + j * b_dim1] = *alpha * temp;
14179
/* L130: */
14180
}
14181
/* L140: */
14182
}
14183
}
14184
}
14185
} else {
14186
if (lsame_(transa, "N")) {
14187
14188
/* Form B := alpha*B*A. */
14189
14190
if (upper) {
14191
for (j = *n; j >= 1; --j) {
14192
temp = *alpha;
14193
if (nounit) {
14194
temp *= a[j + j * a_dim1];
14195
}
14196
i__1 = *m;
14197
for (i__ = 1; i__ <= i__1; ++i__) {
14198
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
14199
/* L150: */
14200
}
14201
i__1 = j - 1;
14202
for (k = 1; k <= i__1; ++k) {
14203
if (a[k + j * a_dim1] != 0.f) {
14204
temp = *alpha * a[k + j * a_dim1];
14205
i__2 = *m;
14206
for (i__ = 1; i__ <= i__2; ++i__) {
14207
b[i__ + j * b_dim1] += temp * b[i__ + k *
14208
b_dim1];
14209
/* L160: */
14210
}
14211
}
14212
/* L170: */
14213
}
14214
/* L180: */
14215
}
14216
} else {
14217
i__1 = *n;
14218
for (j = 1; j <= i__1; ++j) {
14219
temp = *alpha;
14220
if (nounit) {
14221
temp *= a[j + j * a_dim1];
14222
}
14223
i__2 = *m;
14224
for (i__ = 1; i__ <= i__2; ++i__) {
14225
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
14226
/* L190: */
14227
}
14228
i__2 = *n;
14229
for (k = j + 1; k <= i__2; ++k) {
14230
if (a[k + j * a_dim1] != 0.f) {
14231
temp = *alpha * a[k + j * a_dim1];
14232
i__3 = *m;
14233
for (i__ = 1; i__ <= i__3; ++i__) {
14234
b[i__ + j * b_dim1] += temp * b[i__ + k *
14235
b_dim1];
14236
/* L200: */
14237
}
14238
}
14239
/* L210: */
14240
}
14241
/* L220: */
14242
}
14243
}
14244
} else {
14245
14246
/* Form B := alpha*B*A'. */
14247
14248
if (upper) {
14249
i__1 = *n;
14250
for (k = 1; k <= i__1; ++k) {
14251
i__2 = k - 1;
14252
for (j = 1; j <= i__2; ++j) {
14253
if (a[j + k * a_dim1] != 0.f) {
14254
temp = *alpha * a[j + k * a_dim1];
14255
i__3 = *m;
14256
for (i__ = 1; i__ <= i__3; ++i__) {
14257
b[i__ + j * b_dim1] += temp * b[i__ + k *
14258
b_dim1];
14259
/* L230: */
14260
}
14261
}
14262
/* L240: */
14263
}
14264
temp = *alpha;
14265
if (nounit) {
14266
temp *= a[k + k * a_dim1];
14267
}
14268
if (temp != 1.f) {
14269
i__2 = *m;
14270
for (i__ = 1; i__ <= i__2; ++i__) {
14271
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
14272
/* L250: */
14273
}
14274
}
14275
/* L260: */
14276
}
14277
} else {
14278
for (k = *n; k >= 1; --k) {
14279
i__1 = *n;
14280
for (j = k + 1; j <= i__1; ++j) {
14281
if (a[j + k * a_dim1] != 0.f) {
14282
temp = *alpha * a[j + k * a_dim1];
14283
i__2 = *m;
14284
for (i__ = 1; i__ <= i__2; ++i__) {
14285
b[i__ + j * b_dim1] += temp * b[i__ + k *
14286
b_dim1];
14287
/* L270: */
14288
}
14289
}
14290
/* L280: */
14291
}
14292
temp = *alpha;
14293
if (nounit) {
14294
temp *= a[k + k * a_dim1];
14295
}
14296
if (temp != 1.f) {
14297
i__1 = *m;
14298
for (i__ = 1; i__ <= i__1; ++i__) {
14299
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
14300
/* L290: */
14301
}
14302
}
14303
/* L300: */
14304
}
14305
}
14306
}
14307
}
14308
14309
return 0;
14310
14311
/* End of STRMM . */
14312
14313
} /* strmm_ */
14314
14315
/* Subroutine */ int strmv_(char *uplo, char *trans, char *diag, integer *n,
14316
real *a, integer *lda, real *x, integer *incx)
14317
{
14318
/* System generated locals */
14319
integer a_dim1, a_offset, i__1, i__2;
14320
14321
/* Local variables */
14322
static integer i__, j, ix, jx, kx, info;
14323
static real temp;
14324
extern logical lsame_(char *, char *);
14325
extern /* Subroutine */ int xerbla_(char *, integer *);
14326
static logical nounit;
14327
14328
14329
/*
14330
Purpose
14331
=======
14332
14333
STRMV performs one of the matrix-vector operations
14334
14335
x := A*x, or x := A'*x,
14336
14337
where x is an n element vector and A is an n by n unit, or non-unit,
14338
upper or lower triangular matrix.
14339
14340
Arguments
14341
==========
14342
14343
UPLO - CHARACTER*1.
14344
On entry, UPLO specifies whether the matrix is an upper or
14345
lower triangular matrix as follows:
14346
14347
UPLO = 'U' or 'u' A is an upper triangular matrix.
14348
14349
UPLO = 'L' or 'l' A is a lower triangular matrix.
14350
14351
Unchanged on exit.
14352
14353
TRANS - CHARACTER*1.
14354
On entry, TRANS specifies the operation to be performed as
14355
follows:
14356
14357
TRANS = 'N' or 'n' x := A*x.
14358
14359
TRANS = 'T' or 't' x := A'*x.
14360
14361
TRANS = 'C' or 'c' x := A'*x.
14362
14363
Unchanged on exit.
14364
14365
DIAG - CHARACTER*1.
14366
On entry, DIAG specifies whether or not A is unit
14367
triangular as follows:
14368
14369
DIAG = 'U' or 'u' A is assumed to be unit triangular.
14370
14371
DIAG = 'N' or 'n' A is not assumed to be unit
14372
triangular.
14373
14374
Unchanged on exit.
14375
14376
N - INTEGER.
14377
On entry, N specifies the order of the matrix A.
14378
N must be at least zero.
14379
Unchanged on exit.
14380
14381
A - REAL array of DIMENSION ( LDA, n ).
14382
Before entry with UPLO = 'U' or 'u', the leading n by n
14383
upper triangular part of the array A must contain the upper
14384
triangular matrix and the strictly lower triangular part of
14385
A is not referenced.
14386
Before entry with UPLO = 'L' or 'l', the leading n by n
14387
lower triangular part of the array A must contain the lower
14388
triangular matrix and the strictly upper triangular part of
14389
A is not referenced.
14390
Note that when DIAG = 'U' or 'u', the diagonal elements of
14391
A are not referenced either, but are assumed to be unity.
14392
Unchanged on exit.
14393
14394
LDA - INTEGER.
14395
On entry, LDA specifies the first dimension of A as declared
14396
in the calling (sub) program. LDA must be at least
14397
max( 1, n ).
14398
Unchanged on exit.
14399
14400
X - REAL array of dimension at least
14401
( 1 + ( n - 1 )*abs( INCX ) ).
14402
Before entry, the incremented array X must contain the n
14403
element vector x. On exit, X is overwritten with the
14404
tranformed vector x.
14405
14406
INCX - INTEGER.
14407
On entry, INCX specifies the increment for the elements of
14408
X. INCX must not be zero.
14409
Unchanged on exit.
14410
14411
Further Details
14412
===============
14413
14414
Level 2 Blas routine.
14415
14416
-- Written on 22-October-1986.
14417
Jack Dongarra, Argonne National Lab.
14418
Jeremy Du Croz, Nag Central Office.
14419
Sven Hammarling, Nag Central Office.
14420
Richard Hanson, Sandia National Labs.
14421
14422
=====================================================================
14423
14424
14425
Test the input parameters.
14426
*/
14427
14428
/* Parameter adjustments */
14429
a_dim1 = *lda;
14430
a_offset = 1 + a_dim1;
14431
a -= a_offset;
14432
--x;
14433
14434
/* Function Body */
14435
info = 0;
14436
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
14437
info = 1;
14438
} else if (! lsame_(trans, "N") && ! lsame_(trans,
14439
"T") && ! lsame_(trans, "C")) {
14440
info = 2;
14441
} else if (! lsame_(diag, "U") && ! lsame_(diag,
14442
"N")) {
14443
info = 3;
14444
} else if (*n < 0) {
14445
info = 4;
14446
} else if (*lda < max(1,*n)) {
14447
info = 6;
14448
} else if (*incx == 0) {
14449
info = 8;
14450
}
14451
if (info != 0) {
14452
xerbla_("STRMV ", &info);
14453
return 0;
14454
}
14455
14456
/* Quick return if possible. */
14457
14458
if (*n == 0) {
14459
return 0;
14460
}
14461
14462
nounit = lsame_(diag, "N");
14463
14464
/*
14465
Set up the start point in X if the increment is not unity. This
14466
will be ( N - 1 )*INCX too small for descending loops.
14467
*/
14468
14469
if (*incx <= 0) {
14470
kx = 1 - (*n - 1) * *incx;
14471
} else if (*incx != 1) {
14472
kx = 1;
14473
}
14474
14475
/*
14476
Start the operations. In this version the elements of A are
14477
accessed sequentially with one pass through A.
14478
*/
14479
14480
if (lsame_(trans, "N")) {
14481
14482
/* Form x := A*x. */
14483
14484
if (lsame_(uplo, "U")) {
14485
if (*incx == 1) {
14486
i__1 = *n;
14487
for (j = 1; j <= i__1; ++j) {
14488
if (x[j] != 0.f) {
14489
temp = x[j];
14490
i__2 = j - 1;
14491
for (i__ = 1; i__ <= i__2; ++i__) {
14492
x[i__] += temp * a[i__ + j * a_dim1];
14493
/* L10: */
14494
}
14495
if (nounit) {
14496
x[j] *= a[j + j * a_dim1];
14497
}
14498
}
14499
/* L20: */
14500
}
14501
} else {
14502
jx = kx;
14503
i__1 = *n;
14504
for (j = 1; j <= i__1; ++j) {
14505
if (x[jx] != 0.f) {
14506
temp = x[jx];
14507
ix = kx;
14508
i__2 = j - 1;
14509
for (i__ = 1; i__ <= i__2; ++i__) {
14510
x[ix] += temp * a[i__ + j * a_dim1];
14511
ix += *incx;
14512
/* L30: */
14513
}
14514
if (nounit) {
14515
x[jx] *= a[j + j * a_dim1];
14516
}
14517
}
14518
jx += *incx;
14519
/* L40: */
14520
}
14521
}
14522
} else {
14523
if (*incx == 1) {
14524
for (j = *n; j >= 1; --j) {
14525
if (x[j] != 0.f) {
14526
temp = x[j];
14527
i__1 = j + 1;
14528
for (i__ = *n; i__ >= i__1; --i__) {
14529
x[i__] += temp * a[i__ + j * a_dim1];
14530
/* L50: */
14531
}
14532
if (nounit) {
14533
x[j] *= a[j + j * a_dim1];
14534
}
14535
}
14536
/* L60: */
14537
}
14538
} else {
14539
kx += (*n - 1) * *incx;
14540
jx = kx;
14541
for (j = *n; j >= 1; --j) {
14542
if (x[jx] != 0.f) {
14543
temp = x[jx];
14544
ix = kx;
14545
i__1 = j + 1;
14546
for (i__ = *n; i__ >= i__1; --i__) {
14547
x[ix] += temp * a[i__ + j * a_dim1];
14548
ix -= *incx;
14549
/* L70: */
14550
}
14551
if (nounit) {
14552
x[jx] *= a[j + j * a_dim1];
14553
}
14554
}
14555
jx -= *incx;
14556
/* L80: */
14557
}
14558
}
14559
}
14560
} else {
14561
14562
/* Form x := A'*x. */
14563
14564
if (lsame_(uplo, "U")) {
14565
if (*incx == 1) {
14566
for (j = *n; j >= 1; --j) {
14567
temp = x[j];
14568
if (nounit) {
14569
temp *= a[j + j * a_dim1];
14570
}
14571
for (i__ = j - 1; i__ >= 1; --i__) {
14572
temp += a[i__ + j * a_dim1] * x[i__];
14573
/* L90: */
14574
}
14575
x[j] = temp;
14576
/* L100: */
14577
}
14578
} else {
14579
jx = kx + (*n - 1) * *incx;
14580
for (j = *n; j >= 1; --j) {
14581
temp = x[jx];
14582
ix = jx;
14583
if (nounit) {
14584
temp *= a[j + j * a_dim1];
14585
}
14586
for (i__ = j - 1; i__ >= 1; --i__) {
14587
ix -= *incx;
14588
temp += a[i__ + j * a_dim1] * x[ix];
14589
/* L110: */
14590
}
14591
x[jx] = temp;
14592
jx -= *incx;
14593
/* L120: */
14594
}
14595
}
14596
} else {
14597
if (*incx == 1) {
14598
i__1 = *n;
14599
for (j = 1; j <= i__1; ++j) {
14600
temp = x[j];
14601
if (nounit) {
14602
temp *= a[j + j * a_dim1];
14603
}
14604
i__2 = *n;
14605
for (i__ = j + 1; i__ <= i__2; ++i__) {
14606
temp += a[i__ + j * a_dim1] * x[i__];
14607
/* L130: */
14608
}
14609
x[j] = temp;
14610
/* L140: */
14611
}
14612
} else {
14613
jx = kx;
14614
i__1 = *n;
14615
for (j = 1; j <= i__1; ++j) {
14616
temp = x[jx];
14617
ix = jx;
14618
if (nounit) {
14619
temp *= a[j + j * a_dim1];
14620
}
14621
i__2 = *n;
14622
for (i__ = j + 1; i__ <= i__2; ++i__) {
14623
ix += *incx;
14624
temp += a[i__ + j * a_dim1] * x[ix];
14625
/* L150: */
14626
}
14627
x[jx] = temp;
14628
jx += *incx;
14629
/* L160: */
14630
}
14631
}
14632
}
14633
}
14634
14635
return 0;
14636
14637
/* End of STRMV . */
14638
14639
} /* strmv_ */
14640
14641
/* Subroutine */ int strsm_(char *side, char *uplo, char *transa, char *diag,
14642
integer *m, integer *n, real *alpha, real *a, integer *lda, real *b,
14643
integer *ldb)
14644
{
14645
/* System generated locals */
14646
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
14647
14648
/* Local variables */
14649
static integer i__, j, k, info;
14650
static real temp;
14651
static logical lside;
14652
extern logical lsame_(char *, char *);
14653
static integer nrowa;
14654
static logical upper;
14655
extern /* Subroutine */ int xerbla_(char *, integer *);
14656
static logical nounit;
14657
14658
14659
/*
14660
Purpose
14661
=======
14662
14663
STRSM solves one of the matrix equations
14664
14665
op( A )*X = alpha*B, or X*op( A ) = alpha*B,
14666
14667
where alpha is a scalar, X and B are m by n matrices, A is a unit, or
14668
non-unit, upper or lower triangular matrix and op( A ) is one of
14669
14670
op( A ) = A or op( A ) = A'.
14671
14672
The matrix X is overwritten on B.
14673
14674
Arguments
14675
==========
14676
14677
SIDE - CHARACTER*1.
14678
On entry, SIDE specifies whether op( A ) appears on the left
14679
or right of X as follows:
14680
14681
SIDE = 'L' or 'l' op( A )*X = alpha*B.
14682
14683
SIDE = 'R' or 'r' X*op( A ) = alpha*B.
14684
14685
Unchanged on exit.
14686
14687
UPLO - CHARACTER*1.
14688
On entry, UPLO specifies whether the matrix A is an upper or
14689
lower triangular matrix as follows:
14690
14691
UPLO = 'U' or 'u' A is an upper triangular matrix.
14692
14693
UPLO = 'L' or 'l' A is a lower triangular matrix.
14694
14695
Unchanged on exit.
14696
14697
TRANSA - CHARACTER*1.
14698
On entry, TRANSA specifies the form of op( A ) to be used in
14699
the matrix multiplication as follows:
14700
14701
TRANSA = 'N' or 'n' op( A ) = A.
14702
14703
TRANSA = 'T' or 't' op( A ) = A'.
14704
14705
TRANSA = 'C' or 'c' op( A ) = A'.
14706
14707
Unchanged on exit.
14708
14709
DIAG - CHARACTER*1.
14710
On entry, DIAG specifies whether or not A is unit triangular
14711
as follows:
14712
14713
DIAG = 'U' or 'u' A is assumed to be unit triangular.
14714
14715
DIAG = 'N' or 'n' A is not assumed to be unit
14716
triangular.
14717
14718
Unchanged on exit.
14719
14720
M - INTEGER.
14721
On entry, M specifies the number of rows of B. M must be at
14722
least zero.
14723
Unchanged on exit.
14724
14725
N - INTEGER.
14726
On entry, N specifies the number of columns of B. N must be
14727
at least zero.
14728
Unchanged on exit.
14729
14730
ALPHA - REAL .
14731
On entry, ALPHA specifies the scalar alpha. When alpha is
14732
zero then A is not referenced and B need not be set before
14733
entry.
14734
Unchanged on exit.
14735
14736
A - REAL array of DIMENSION ( LDA, k ), where k is m
14737
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
14738
Before entry with UPLO = 'U' or 'u', the leading k by k
14739
upper triangular part of the array A must contain the upper
14740
triangular matrix and the strictly lower triangular part of
14741
A is not referenced.
14742
Before entry with UPLO = 'L' or 'l', the leading k by k
14743
lower triangular part of the array A must contain the lower
14744
triangular matrix and the strictly upper triangular part of
14745
A is not referenced.
14746
Note that when DIAG = 'U' or 'u', the diagonal elements of
14747
A are not referenced either, but are assumed to be unity.
14748
Unchanged on exit.
14749
14750
LDA - INTEGER.
14751
On entry, LDA specifies the first dimension of A as declared
14752
in the calling (sub) program. When SIDE = 'L' or 'l' then
14753
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
14754
then LDA must be at least max( 1, n ).
14755
Unchanged on exit.
14756
14757
B - REAL array of DIMENSION ( LDB, n ).
14758
Before entry, the leading m by n part of the array B must
14759
contain the right-hand side matrix B, and on exit is
14760
overwritten by the solution matrix X.
14761
14762
LDB - INTEGER.
14763
On entry, LDB specifies the first dimension of B as declared
14764
in the calling (sub) program. LDB must be at least
14765
max( 1, m ).
14766
Unchanged on exit.
14767
14768
Further Details
14769
===============
14770
14771
Level 3 Blas routine.
14772
14773
14774
-- Written on 8-February-1989.
14775
Jack Dongarra, Argonne National Laboratory.
14776
Iain Duff, AERE Harwell.
14777
Jeremy Du Croz, Numerical Algorithms Group Ltd.
14778
Sven Hammarling, Numerical Algorithms Group Ltd.
14779
14780
=====================================================================
14781
14782
14783
Test the input parameters.
14784
*/
14785
14786
/* Parameter adjustments */
14787
a_dim1 = *lda;
14788
a_offset = 1 + a_dim1;
14789
a -= a_offset;
14790
b_dim1 = *ldb;
14791
b_offset = 1 + b_dim1;
14792
b -= b_offset;
14793
14794
/* Function Body */
14795
lside = lsame_(side, "L");
14796
if (lside) {
14797
nrowa = *m;
14798
} else {
14799
nrowa = *n;
14800
}
14801
nounit = lsame_(diag, "N");
14802
upper = lsame_(uplo, "U");
14803
14804
info = 0;
14805
if (! lside && ! lsame_(side, "R")) {
14806
info = 1;
14807
} else if (! upper && ! lsame_(uplo, "L")) {
14808
info = 2;
14809
} else if (! lsame_(transa, "N") && ! lsame_(transa,
14810
"T") && ! lsame_(transa, "C")) {
14811
info = 3;
14812
} else if (! lsame_(diag, "U") && ! lsame_(diag,
14813
"N")) {
14814
info = 4;
14815
} else if (*m < 0) {
14816
info = 5;
14817
} else if (*n < 0) {
14818
info = 6;
14819
} else if (*lda < max(1,nrowa)) {
14820
info = 9;
14821
} else if (*ldb < max(1,*m)) {
14822
info = 11;
14823
}
14824
if (info != 0) {
14825
xerbla_("STRSM ", &info);
14826
return 0;
14827
}
14828
14829
/* Quick return if possible. */
14830
14831
if (*m == 0 || *n == 0) {
14832
return 0;
14833
}
14834
14835
/* And when alpha.eq.zero. */
14836
14837
if (*alpha == 0.f) {
14838
i__1 = *n;
14839
for (j = 1; j <= i__1; ++j) {
14840
i__2 = *m;
14841
for (i__ = 1; i__ <= i__2; ++i__) {
14842
b[i__ + j * b_dim1] = 0.f;
14843
/* L10: */
14844
}
14845
/* L20: */
14846
}
14847
return 0;
14848
}
14849
14850
/* Start the operations. */
14851
14852
if (lside) {
14853
if (lsame_(transa, "N")) {
14854
14855
/* Form B := alpha*inv( A )*B. */
14856
14857
if (upper) {
14858
i__1 = *n;
14859
for (j = 1; j <= i__1; ++j) {
14860
if (*alpha != 1.f) {
14861
i__2 = *m;
14862
for (i__ = 1; i__ <= i__2; ++i__) {
14863
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
14864
;
14865
/* L30: */
14866
}
14867
}
14868
for (k = *m; k >= 1; --k) {
14869
if (b[k + j * b_dim1] != 0.f) {
14870
if (nounit) {
14871
b[k + j * b_dim1] /= a[k + k * a_dim1];
14872
}
14873
i__2 = k - 1;
14874
for (i__ = 1; i__ <= i__2; ++i__) {
14875
b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
14876
i__ + k * a_dim1];
14877
/* L40: */
14878
}
14879
}
14880
/* L50: */
14881
}
14882
/* L60: */
14883
}
14884
} else {
14885
i__1 = *n;
14886
for (j = 1; j <= i__1; ++j) {
14887
if (*alpha != 1.f) {
14888
i__2 = *m;
14889
for (i__ = 1; i__ <= i__2; ++i__) {
14890
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
14891
;
14892
/* L70: */
14893
}
14894
}
14895
i__2 = *m;
14896
for (k = 1; k <= i__2; ++k) {
14897
if (b[k + j * b_dim1] != 0.f) {
14898
if (nounit) {
14899
b[k + j * b_dim1] /= a[k + k * a_dim1];
14900
}
14901
i__3 = *m;
14902
for (i__ = k + 1; i__ <= i__3; ++i__) {
14903
b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
14904
i__ + k * a_dim1];
14905
/* L80: */
14906
}
14907
}
14908
/* L90: */
14909
}
14910
/* L100: */
14911
}
14912
}
14913
} else {
14914
14915
/* Form B := alpha*inv( A' )*B. */
14916
14917
if (upper) {
14918
i__1 = *n;
14919
for (j = 1; j <= i__1; ++j) {
14920
i__2 = *m;
14921
for (i__ = 1; i__ <= i__2; ++i__) {
14922
temp = *alpha * b[i__ + j * b_dim1];
14923
i__3 = i__ - 1;
14924
for (k = 1; k <= i__3; ++k) {
14925
temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
14926
/* L110: */
14927
}
14928
if (nounit) {
14929
temp /= a[i__ + i__ * a_dim1];
14930
}
14931
b[i__ + j * b_dim1] = temp;
14932
/* L120: */
14933
}
14934
/* L130: */
14935
}
14936
} else {
14937
i__1 = *n;
14938
for (j = 1; j <= i__1; ++j) {
14939
for (i__ = *m; i__ >= 1; --i__) {
14940
temp = *alpha * b[i__ + j * b_dim1];
14941
i__2 = *m;
14942
for (k = i__ + 1; k <= i__2; ++k) {
14943
temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
14944
/* L140: */
14945
}
14946
if (nounit) {
14947
temp /= a[i__ + i__ * a_dim1];
14948
}
14949
b[i__ + j * b_dim1] = temp;
14950
/* L150: */
14951
}
14952
/* L160: */
14953
}
14954
}
14955
}
14956
} else {
14957
if (lsame_(transa, "N")) {
14958
14959
/* Form B := alpha*B*inv( A ). */
14960
14961
if (upper) {
14962
i__1 = *n;
14963
for (j = 1; j <= i__1; ++j) {
14964
if (*alpha != 1.f) {
14965
i__2 = *m;
14966
for (i__ = 1; i__ <= i__2; ++i__) {
14967
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
14968
;
14969
/* L170: */
14970
}
14971
}
14972
i__2 = j - 1;
14973
for (k = 1; k <= i__2; ++k) {
14974
if (a[k + j * a_dim1] != 0.f) {
14975
i__3 = *m;
14976
for (i__ = 1; i__ <= i__3; ++i__) {
14977
b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
14978
i__ + k * b_dim1];
14979
/* L180: */
14980
}
14981
}
14982
/* L190: */
14983
}
14984
if (nounit) {
14985
temp = 1.f / a[j + j * a_dim1];
14986
i__2 = *m;
14987
for (i__ = 1; i__ <= i__2; ++i__) {
14988
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
14989
/* L200: */
14990
}
14991
}
14992
/* L210: */
14993
}
14994
} else {
14995
for (j = *n; j >= 1; --j) {
14996
if (*alpha != 1.f) {
14997
i__1 = *m;
14998
for (i__ = 1; i__ <= i__1; ++i__) {
14999
b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
15000
;
15001
/* L220: */
15002
}
15003
}
15004
i__1 = *n;
15005
for (k = j + 1; k <= i__1; ++k) {
15006
if (a[k + j * a_dim1] != 0.f) {
15007
i__2 = *m;
15008
for (i__ = 1; i__ <= i__2; ++i__) {
15009
b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
15010
i__ + k * b_dim1];
15011
/* L230: */
15012
}
15013
}
15014
/* L240: */
15015
}
15016
if (nounit) {
15017
temp = 1.f / a[j + j * a_dim1];
15018
i__1 = *m;
15019
for (i__ = 1; i__ <= i__1; ++i__) {
15020
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
15021
/* L250: */
15022
}
15023
}
15024
/* L260: */
15025
}
15026
}
15027
} else {
15028
15029
/* Form B := alpha*B*inv( A' ). */
15030
15031
if (upper) {
15032
for (k = *n; k >= 1; --k) {
15033
if (nounit) {
15034
temp = 1.f / a[k + k * a_dim1];
15035
i__1 = *m;
15036
for (i__ = 1; i__ <= i__1; ++i__) {
15037
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
15038
/* L270: */
15039
}
15040
}
15041
i__1 = k - 1;
15042
for (j = 1; j <= i__1; ++j) {
15043
if (a[j + k * a_dim1] != 0.f) {
15044
temp = a[j + k * a_dim1];
15045
i__2 = *m;
15046
for (i__ = 1; i__ <= i__2; ++i__) {
15047
b[i__ + j * b_dim1] -= temp * b[i__ + k *
15048
b_dim1];
15049
/* L280: */
15050
}
15051
}
15052
/* L290: */
15053
}
15054
if (*alpha != 1.f) {
15055
i__1 = *m;
15056
for (i__ = 1; i__ <= i__1; ++i__) {
15057
b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
15058
;
15059
/* L300: */
15060
}
15061
}
15062
/* L310: */
15063
}
15064
} else {
15065
i__1 = *n;
15066
for (k = 1; k <= i__1; ++k) {
15067
if (nounit) {
15068
temp = 1.f / a[k + k * a_dim1];
15069
i__2 = *m;
15070
for (i__ = 1; i__ <= i__2; ++i__) {
15071
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
15072
/* L320: */
15073
}
15074
}
15075
i__2 = *n;
15076
for (j = k + 1; j <= i__2; ++j) {
15077
if (a[j + k * a_dim1] != 0.f) {
15078
temp = a[j + k * a_dim1];
15079
i__3 = *m;
15080
for (i__ = 1; i__ <= i__3; ++i__) {
15081
b[i__ + j * b_dim1] -= temp * b[i__ + k *
15082
b_dim1];
15083
/* L330: */
15084
}
15085
}
15086
/* L340: */
15087
}
15088
if (*alpha != 1.f) {
15089
i__2 = *m;
15090
for (i__ = 1; i__ <= i__2; ++i__) {
15091
b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
15092
;
15093
/* L350: */
15094
}
15095
}
15096
/* L360: */
15097
}
15098
}
15099
}
15100
}
15101
15102
return 0;
15103
15104
/* End of STRSM . */
15105
15106
} /* strsm_ */
15107
15108
/* Subroutine */ int zaxpy_(integer *n, doublecomplex *za, doublecomplex *zx,
15109
integer *incx, doublecomplex *zy, integer *incy)
15110
{
15111
/* System generated locals */
15112
integer i__1, i__2, i__3, i__4;
15113
doublecomplex z__1, z__2;
15114
15115
/* Local variables */
15116
static integer i__, ix, iy;
15117
extern doublereal dcabs1_(doublecomplex *);
15118
15119
15120
/*
15121
Purpose
15122
=======
15123
15124
ZAXPY constant times a vector plus a vector.
15125
15126
Further Details
15127
===============
15128
15129
jack dongarra, 3/11/78.
15130
modified 12/3/93, array(1) declarations changed to array(*)
15131
15132
=====================================================================
15133
*/
15134
15135
/* Parameter adjustments */
15136
--zy;
15137
--zx;
15138
15139
/* Function Body */
15140
if (*n <= 0) {
15141
return 0;
15142
}
15143
if (dcabs1_(za) == 0.) {
15144
return 0;
15145
}
15146
if (*incx == 1 && *incy == 1) {
15147
goto L20;
15148
}
15149
15150
/*
15151
code for unequal increments or equal increments
15152
not equal to 1
15153
*/
15154
15155
ix = 1;
15156
iy = 1;
15157
if (*incx < 0) {
15158
ix = (-(*n) + 1) * *incx + 1;
15159
}
15160
if (*incy < 0) {
15161
iy = (-(*n) + 1) * *incy + 1;
15162
}
15163
i__1 = *n;
15164
for (i__ = 1; i__ <= i__1; ++i__) {
15165
i__2 = iy;
15166
i__3 = iy;
15167
i__4 = ix;
15168
z__2.r = za->r * zx[i__4].r - za->i * zx[i__4].i, z__2.i = za->r * zx[
15169
i__4].i + za->i * zx[i__4].r;
15170
z__1.r = zy[i__3].r + z__2.r, z__1.i = zy[i__3].i + z__2.i;
15171
zy[i__2].r = z__1.r, zy[i__2].i = z__1.i;
15172
ix += *incx;
15173
iy += *incy;
15174
/* L10: */
15175
}
15176
return 0;
15177
15178
/* code for both increments equal to 1 */
15179
15180
L20:
15181
i__1 = *n;
15182
for (i__ = 1; i__ <= i__1; ++i__) {
15183
i__2 = i__;
15184
i__3 = i__;
15185
i__4 = i__;
15186
z__2.r = za->r * zx[i__4].r - za->i * zx[i__4].i, z__2.i = za->r * zx[
15187
i__4].i + za->i * zx[i__4].r;
15188
z__1.r = zy[i__3].r + z__2.r, z__1.i = zy[i__3].i + z__2.i;
15189
zy[i__2].r = z__1.r, zy[i__2].i = z__1.i;
15190
/* L30: */
15191
}
15192
return 0;
15193
} /* zaxpy_ */
15194
15195
/* Subroutine */ int zcopy_(integer *n, doublecomplex *zx, integer *incx,
15196
doublecomplex *zy, integer *incy)
15197
{
15198
/* System generated locals */
15199
integer i__1, i__2, i__3;
15200
15201
/* Local variables */
15202
static integer i__, ix, iy;
15203
15204
15205
/*
15206
Purpose
15207
=======
15208
15209
ZCOPY copies a vector, x, to a vector, y.
15210
15211
Further Details
15212
===============
15213
15214
jack dongarra, linpack, 4/11/78.
15215
modified 12/3/93, array(1) declarations changed to array(*)
15216
15217
=====================================================================
15218
*/
15219
15220
/* Parameter adjustments */
15221
--zy;
15222
--zx;
15223
15224
/* Function Body */
15225
if (*n <= 0) {
15226
return 0;
15227
}
15228
if (*incx == 1 && *incy == 1) {
15229
goto L20;
15230
}
15231
15232
/*
15233
code for unequal increments or equal increments
15234
not equal to 1
15235
*/
15236
15237
ix = 1;
15238
iy = 1;
15239
if (*incx < 0) {
15240
ix = (-(*n) + 1) * *incx + 1;
15241
}
15242
if (*incy < 0) {
15243
iy = (-(*n) + 1) * *incy + 1;
15244
}
15245
i__1 = *n;
15246
for (i__ = 1; i__ <= i__1; ++i__) {
15247
i__2 = iy;
15248
i__3 = ix;
15249
zy[i__2].r = zx[i__3].r, zy[i__2].i = zx[i__3].i;
15250
ix += *incx;
15251
iy += *incy;
15252
/* L10: */
15253
}
15254
return 0;
15255
15256
/* code for both increments equal to 1 */
15257
15258
L20:
15259
i__1 = *n;
15260
for (i__ = 1; i__ <= i__1; ++i__) {
15261
i__2 = i__;
15262
i__3 = i__;
15263
zy[i__2].r = zx[i__3].r, zy[i__2].i = zx[i__3].i;
15264
/* L30: */
15265
}
15266
return 0;
15267
} /* zcopy_ */
15268
15269
/* Double Complex */ VOID zdotc_(doublecomplex * ret_val, integer *n,
15270
doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy)
15271
{
15272
/* System generated locals */
15273
integer i__1, i__2;
15274
doublecomplex z__1, z__2, z__3;
15275
15276
/* Local variables */
15277
static integer i__, ix, iy;
15278
static doublecomplex ztemp;
15279
15280
15281
/*
15282
Purpose
15283
=======
15284
15285
ZDOTC forms the dot product of a vector.
15286
15287
Further Details
15288
===============
15289
15290
jack dongarra, 3/11/78.
15291
modified 12/3/93, array(1) declarations changed to array(*)
15292
15293
=====================================================================
15294
*/
15295
15296
/* Parameter adjustments */
15297
--zy;
15298
--zx;
15299
15300
/* Function Body */
15301
ztemp.r = 0., ztemp.i = 0.;
15302
ret_val->r = 0., ret_val->i = 0.;
15303
if (*n <= 0) {
15304
return ;
15305
}
15306
if (*incx == 1 && *incy == 1) {
15307
goto L20;
15308
}
15309
15310
/*
15311
code for unequal increments or equal increments
15312
not equal to 1
15313
*/
15314
15315
ix = 1;
15316
iy = 1;
15317
if (*incx < 0) {
15318
ix = (-(*n) + 1) * *incx + 1;
15319
}
15320
if (*incy < 0) {
15321
iy = (-(*n) + 1) * *incy + 1;
15322
}
15323
i__1 = *n;
15324
for (i__ = 1; i__ <= i__1; ++i__) {
15325
d_cnjg(&z__3, &zx[ix]);
15326
i__2 = iy;
15327
z__2.r = z__3.r * zy[i__2].r - z__3.i * zy[i__2].i, z__2.i = z__3.r *
15328
zy[i__2].i + z__3.i * zy[i__2].r;
15329
z__1.r = ztemp.r + z__2.r, z__1.i = ztemp.i + z__2.i;
15330
ztemp.r = z__1.r, ztemp.i = z__1.i;
15331
ix += *incx;
15332
iy += *incy;
15333
/* L10: */
15334
}
15335
ret_val->r = ztemp.r, ret_val->i = ztemp.i;
15336
return ;
15337
15338
/* code for both increments equal to 1 */
15339
15340
L20:
15341
i__1 = *n;
15342
for (i__ = 1; i__ <= i__1; ++i__) {
15343
d_cnjg(&z__3, &zx[i__]);
15344
i__2 = i__;
15345
z__2.r = z__3.r * zy[i__2].r - z__3.i * zy[i__2].i, z__2.i = z__3.r *
15346
zy[i__2].i + z__3.i * zy[i__2].r;
15347
z__1.r = ztemp.r + z__2.r, z__1.i = ztemp.i + z__2.i;
15348
ztemp.r = z__1.r, ztemp.i = z__1.i;
15349
/* L30: */
15350
}
15351
ret_val->r = ztemp.r, ret_val->i = ztemp.i;
15352
return ;
15353
} /* zdotc_ */
15354
15355
/* Double Complex */ VOID zdotu_(doublecomplex * ret_val, integer *n,
15356
doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy)
15357
{
15358
/* System generated locals */
15359
integer i__1, i__2, i__3;
15360
doublecomplex z__1, z__2;
15361
15362
/* Local variables */
15363
static integer i__, ix, iy;
15364
static doublecomplex ztemp;
15365
15366
15367
/*
15368
Purpose
15369
=======
15370
15371
ZDOTU forms the dot product of two vectors.
15372
15373
Further Details
15374
===============
15375
15376
jack dongarra, 3/11/78.
15377
modified 12/3/93, array(1) declarations changed to array(*)
15378
15379
=====================================================================
15380
*/
15381
15382
/* Parameter adjustments */
15383
--zy;
15384
--zx;
15385
15386
/* Function Body */
15387
ztemp.r = 0., ztemp.i = 0.;
15388
ret_val->r = 0., ret_val->i = 0.;
15389
if (*n <= 0) {
15390
return ;
15391
}
15392
if (*incx == 1 && *incy == 1) {
15393
goto L20;
15394
}
15395
15396
/*
15397
code for unequal increments or equal increments
15398
not equal to 1
15399
*/
15400
15401
ix = 1;
15402
iy = 1;
15403
if (*incx < 0) {
15404
ix = (-(*n) + 1) * *incx + 1;
15405
}
15406
if (*incy < 0) {
15407
iy = (-(*n) + 1) * *incy + 1;
15408
}
15409
i__1 = *n;
15410
for (i__ = 1; i__ <= i__1; ++i__) {
15411
i__2 = ix;
15412
i__3 = iy;
15413
z__2.r = zx[i__2].r * zy[i__3].r - zx[i__2].i * zy[i__3].i, z__2.i =
15414
zx[i__2].r * zy[i__3].i + zx[i__2].i * zy[i__3].r;
15415
z__1.r = ztemp.r + z__2.r, z__1.i = ztemp.i + z__2.i;
15416
ztemp.r = z__1.r, ztemp.i = z__1.i;
15417
ix += *incx;
15418
iy += *incy;
15419
/* L10: */
15420
}
15421
ret_val->r = ztemp.r, ret_val->i = ztemp.i;
15422
return ;
15423
15424
/* code for both increments equal to 1 */
15425
15426
L20:
15427
i__1 = *n;
15428
for (i__ = 1; i__ <= i__1; ++i__) {
15429
i__2 = i__;
15430
i__3 = i__;
15431
z__2.r = zx[i__2].r * zy[i__3].r - zx[i__2].i * zy[i__3].i, z__2.i =
15432
zx[i__2].r * zy[i__3].i + zx[i__2].i * zy[i__3].r;
15433
z__1.r = ztemp.r + z__2.r, z__1.i = ztemp.i + z__2.i;
15434
ztemp.r = z__1.r, ztemp.i = z__1.i;
15435
/* L30: */
15436
}
15437
ret_val->r = ztemp.r, ret_val->i = ztemp.i;
15438
return ;
15439
} /* zdotu_ */
15440
15441
/* Subroutine */ int zdrot_(integer *n, doublecomplex *cx, integer *incx,
15442
doublecomplex *cy, integer *incy, doublereal *c__, doublereal *s)
15443
{
15444
/* System generated locals */
15445
integer i__1, i__2, i__3, i__4;
15446
doublecomplex z__1, z__2, z__3;
15447
15448
/* Local variables */
15449
static integer i__, ix, iy;
15450
static doublecomplex ctemp;
15451
15452
15453
/*
15454
Purpose
15455
=======
15456
15457
Applies a plane rotation, where the cos and sin (c and s) are real
15458
and the vectors cx and cy are complex.
15459
jack dongarra, linpack, 3/11/78.
15460
15461
Arguments
15462
==========
15463
15464
N (input) INTEGER
15465
On entry, N specifies the order of the vectors cx and cy.
15466
N must be at least zero.
15467
Unchanged on exit.
15468
15469
CX (input) COMPLEX*16 array, dimension at least
15470
( 1 + ( N - 1 )*abs( INCX ) ).
15471
Before entry, the incremented array CX must contain the n
15472
element vector cx. On exit, CX is overwritten by the updated
15473
vector cx.
15474
15475
INCX (input) INTEGER
15476
On entry, INCX specifies the increment for the elements of
15477
CX. INCX must not be zero.
15478
Unchanged on exit.
15479
15480
CY (input) COMPLEX*16 array, dimension at least
15481
( 1 + ( N - 1 )*abs( INCY ) ).
15482
Before entry, the incremented array CY must contain the n
15483
element vector cy. On exit, CY is overwritten by the updated
15484
vector cy.
15485
15486
INCY (input) INTEGER
15487
On entry, INCY specifies the increment for the elements of
15488
CY. INCY must not be zero.
15489
Unchanged on exit.
15490
15491
C (input) DOUBLE PRECISION
15492
On entry, C specifies the cosine, cos.
15493
Unchanged on exit.
15494
15495
S (input) DOUBLE PRECISION
15496
On entry, S specifies the sine, sin.
15497
Unchanged on exit.
15498
15499
=====================================================================
15500
*/
15501
15502
15503
/* Parameter adjustments */
15504
--cy;
15505
--cx;
15506
15507
/* Function Body */
15508
if (*n <= 0) {
15509
return 0;
15510
}
15511
if (*incx == 1 && *incy == 1) {
15512
goto L20;
15513
}
15514
15515
/*
15516
code for unequal increments or equal increments not equal
15517
to 1
15518
*/
15519
15520
ix = 1;
15521
iy = 1;
15522
if (*incx < 0) {
15523
ix = (-(*n) + 1) * *incx + 1;
15524
}
15525
if (*incy < 0) {
15526
iy = (-(*n) + 1) * *incy + 1;
15527
}
15528
i__1 = *n;
15529
for (i__ = 1; i__ <= i__1; ++i__) {
15530
i__2 = ix;
15531
z__2.r = *c__ * cx[i__2].r, z__2.i = *c__ * cx[i__2].i;
15532
i__3 = iy;
15533
z__3.r = *s * cy[i__3].r, z__3.i = *s * cy[i__3].i;
15534
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
15535
ctemp.r = z__1.r, ctemp.i = z__1.i;
15536
i__2 = iy;
15537
i__3 = iy;
15538
z__2.r = *c__ * cy[i__3].r, z__2.i = *c__ * cy[i__3].i;
15539
i__4 = ix;
15540
z__3.r = *s * cx[i__4].r, z__3.i = *s * cx[i__4].i;
15541
z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
15542
cy[i__2].r = z__1.r, cy[i__2].i = z__1.i;
15543
i__2 = ix;
15544
cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
15545
ix += *incx;
15546
iy += *incy;
15547
/* L10: */
15548
}
15549
return 0;
15550
15551
/* code for both increments equal to 1 */
15552
15553
L20:
15554
i__1 = *n;
15555
for (i__ = 1; i__ <= i__1; ++i__) {
15556
i__2 = i__;
15557
z__2.r = *c__ * cx[i__2].r, z__2.i = *c__ * cx[i__2].i;
15558
i__3 = i__;
15559
z__3.r = *s * cy[i__3].r, z__3.i = *s * cy[i__3].i;
15560
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
15561
ctemp.r = z__1.r, ctemp.i = z__1.i;
15562
i__2 = i__;
15563
i__3 = i__;
15564
z__2.r = *c__ * cy[i__3].r, z__2.i = *c__ * cy[i__3].i;
15565
i__4 = i__;
15566
z__3.r = *s * cx[i__4].r, z__3.i = *s * cx[i__4].i;
15567
z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
15568
cy[i__2].r = z__1.r, cy[i__2].i = z__1.i;
15569
i__2 = i__;
15570
cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
15571
/* L30: */
15572
}
15573
return 0;
15574
} /* zdrot_ */
15575
15576
/* Subroutine */ int zdscal_(integer *n, doublereal *da, doublecomplex *zx,
15577
integer *incx)
15578
{
15579
/* System generated locals */
15580
integer i__1, i__2, i__3;
15581
doublecomplex z__1, z__2;
15582
15583
/* Local variables */
15584
static integer i__, ix;
15585
15586
15587
/*
15588
Purpose
15589
=======
15590
15591
ZDSCAL scales a vector by a constant.
15592
15593
Further Details
15594
===============
15595
15596
jack dongarra, 3/11/78.
15597
modified 3/93 to return if incx .le. 0.
15598
modified 12/3/93, array(1) declarations changed to array(*)
15599
15600
=====================================================================
15601
*/
15602
15603
/* Parameter adjustments */
15604
--zx;
15605
15606
/* Function Body */
15607
if (*n <= 0 || *incx <= 0) {
15608
return 0;
15609
}
15610
if (*incx == 1) {
15611
goto L20;
15612
}
15613
15614
/* code for increment not equal to 1 */
15615
15616
ix = 1;
15617
i__1 = *n;
15618
for (i__ = 1; i__ <= i__1; ++i__) {
15619
i__2 = ix;
15620
z__2.r = *da, z__2.i = 0.;
15621
i__3 = ix;
15622
z__1.r = z__2.r * zx[i__3].r - z__2.i * zx[i__3].i, z__1.i = z__2.r *
15623
zx[i__3].i + z__2.i * zx[i__3].r;
15624
zx[i__2].r = z__1.r, zx[i__2].i = z__1.i;
15625
ix += *incx;
15626
/* L10: */
15627
}
15628
return 0;
15629
15630
/* code for increment equal to 1 */
15631
15632
L20:
15633
i__1 = *n;
15634
for (i__ = 1; i__ <= i__1; ++i__) {
15635
i__2 = i__;
15636
z__2.r = *da, z__2.i = 0.;
15637
i__3 = i__;
15638
z__1.r = z__2.r * zx[i__3].r - z__2.i * zx[i__3].i, z__1.i = z__2.r *
15639
zx[i__3].i + z__2.i * zx[i__3].r;
15640
zx[i__2].r = z__1.r, zx[i__2].i = z__1.i;
15641
/* L30: */
15642
}
15643
return 0;
15644
} /* zdscal_ */
15645
15646
/* Subroutine */ int zgemm_(char *transa, char *transb, integer *m, integer *
15647
n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda,
15648
doublecomplex *b, integer *ldb, doublecomplex *beta, doublecomplex *
15649
c__, integer *ldc)
15650
{
15651
/* System generated locals */
15652
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
15653
i__3, i__4, i__5, i__6;
15654
doublecomplex z__1, z__2, z__3, z__4;
15655
15656
/* Local variables */
15657
static integer i__, j, l, info;
15658
static logical nota, notb;
15659
static doublecomplex temp;
15660
static logical conja, conjb;
15661
extern logical lsame_(char *, char *);
15662
static integer nrowa, nrowb;
15663
extern /* Subroutine */ int xerbla_(char *, integer *);
15664
15665
15666
/*
15667
Purpose
15668
=======
15669
15670
ZGEMM performs one of the matrix-matrix operations
15671
15672
C := alpha*op( A )*op( B ) + beta*C,
15673
15674
where op( X ) is one of
15675
15676
op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ),
15677
15678
alpha and beta are scalars, and A, B and C are matrices, with op( A )
15679
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
15680
15681
Arguments
15682
==========
15683
15684
TRANSA - CHARACTER*1.
15685
On entry, TRANSA specifies the form of op( A ) to be used in
15686
the matrix multiplication as follows:
15687
15688
TRANSA = 'N' or 'n', op( A ) = A.
15689
15690
TRANSA = 'T' or 't', op( A ) = A'.
15691
15692
TRANSA = 'C' or 'c', op( A ) = conjg( A' ).
15693
15694
Unchanged on exit.
15695
15696
TRANSB - CHARACTER*1.
15697
On entry, TRANSB specifies the form of op( B ) to be used in
15698
the matrix multiplication as follows:
15699
15700
TRANSB = 'N' or 'n', op( B ) = B.
15701
15702
TRANSB = 'T' or 't', op( B ) = B'.
15703
15704
TRANSB = 'C' or 'c', op( B ) = conjg( B' ).
15705
15706
Unchanged on exit.
15707
15708
M - INTEGER.
15709
On entry, M specifies the number of rows of the matrix
15710
op( A ) and of the matrix C. M must be at least zero.
15711
Unchanged on exit.
15712
15713
N - INTEGER.
15714
On entry, N specifies the number of columns of the matrix
15715
op( B ) and the number of columns of the matrix C. N must be
15716
at least zero.
15717
Unchanged on exit.
15718
15719
K - INTEGER.
15720
On entry, K specifies the number of columns of the matrix
15721
op( A ) and the number of rows of the matrix op( B ). K must
15722
be at least zero.
15723
Unchanged on exit.
15724
15725
ALPHA - COMPLEX*16 .
15726
On entry, ALPHA specifies the scalar alpha.
15727
Unchanged on exit.
15728
15729
A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is
15730
k when TRANSA = 'N' or 'n', and is m otherwise.
15731
Before entry with TRANSA = 'N' or 'n', the leading m by k
15732
part of the array A must contain the matrix A, otherwise
15733
the leading k by m part of the array A must contain the
15734
matrix A.
15735
Unchanged on exit.
15736
15737
LDA - INTEGER.
15738
On entry, LDA specifies the first dimension of A as declared
15739
in the calling (sub) program. When TRANSA = 'N' or 'n' then
15740
LDA must be at least max( 1, m ), otherwise LDA must be at
15741
least max( 1, k ).
15742
Unchanged on exit.
15743
15744
B - COMPLEX*16 array of DIMENSION ( LDB, kb ), where kb is
15745
n when TRANSB = 'N' or 'n', and is k otherwise.
15746
Before entry with TRANSB = 'N' or 'n', the leading k by n
15747
part of the array B must contain the matrix B, otherwise
15748
the leading n by k part of the array B must contain the
15749
matrix B.
15750
Unchanged on exit.
15751
15752
LDB - INTEGER.
15753
On entry, LDB specifies the first dimension of B as declared
15754
in the calling (sub) program. When TRANSB = 'N' or 'n' then
15755
LDB must be at least max( 1, k ), otherwise LDB must be at
15756
least max( 1, n ).
15757
Unchanged on exit.
15758
15759
BETA - COMPLEX*16 .
15760
On entry, BETA specifies the scalar beta. When BETA is
15761
supplied as zero then C need not be set on input.
15762
Unchanged on exit.
15763
15764
C - COMPLEX*16 array of DIMENSION ( LDC, n ).
15765
Before entry, the leading m by n part of the array C must
15766
contain the matrix C, except when beta is zero, in which
15767
case C need not be set on entry.
15768
On exit, the array C is overwritten by the m by n matrix
15769
( alpha*op( A )*op( B ) + beta*C ).
15770
15771
LDC - INTEGER.
15772
On entry, LDC specifies the first dimension of C as declared
15773
in the calling (sub) program. LDC must be at least
15774
max( 1, m ).
15775
Unchanged on exit.
15776
15777
Further Details
15778
===============
15779
15780
Level 3 Blas routine.
15781
15782
-- Written on 8-February-1989.
15783
Jack Dongarra, Argonne National Laboratory.
15784
Iain Duff, AERE Harwell.
15785
Jeremy Du Croz, Numerical Algorithms Group Ltd.
15786
Sven Hammarling, Numerical Algorithms Group Ltd.
15787
15788
=====================================================================
15789
15790
15791
Set NOTA and NOTB as true if A and B respectively are not
15792
conjugated or transposed, set CONJA and CONJB as true if A and
15793
B respectively are to be transposed but not conjugated and set
15794
NROWA and NROWB as the number of rows and columns of A
15795
and the number of rows of B respectively.
15796
*/
15797
15798
/* Parameter adjustments */
15799
a_dim1 = *lda;
15800
a_offset = 1 + a_dim1;
15801
a -= a_offset;
15802
b_dim1 = *ldb;
15803
b_offset = 1 + b_dim1;
15804
b -= b_offset;
15805
c_dim1 = *ldc;
15806
c_offset = 1 + c_dim1;
15807
c__ -= c_offset;
15808
15809
/* Function Body */
15810
nota = lsame_(transa, "N");
15811
notb = lsame_(transb, "N");
15812
conja = lsame_(transa, "C");
15813
conjb = lsame_(transb, "C");
15814
if (nota) {
15815
nrowa = *m;
15816
} else {
15817
nrowa = *k;
15818
}
15819
if (notb) {
15820
nrowb = *k;
15821
} else {
15822
nrowb = *n;
15823
}
15824
15825
/* Test the input parameters. */
15826
15827
info = 0;
15828
if (! nota && ! conja && ! lsame_(transa, "T")) {
15829
info = 1;
15830
} else if (! notb && ! conjb && ! lsame_(transb, "T")) {
15831
info = 2;
15832
} else if (*m < 0) {
15833
info = 3;
15834
} else if (*n < 0) {
15835
info = 4;
15836
} else if (*k < 0) {
15837
info = 5;
15838
} else if (*lda < max(1,nrowa)) {
15839
info = 8;
15840
} else if (*ldb < max(1,nrowb)) {
15841
info = 10;
15842
} else if (*ldc < max(1,*m)) {
15843
info = 13;
15844
}
15845
if (info != 0) {
15846
xerbla_("ZGEMM ", &info);
15847
return 0;
15848
}
15849
15850
/* Quick return if possible. */
15851
15852
if (*m == 0 || *n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) &&
15853
(beta->r == 1. && beta->i == 0.)) {
15854
return 0;
15855
}
15856
15857
/* And when alpha.eq.zero. */
15858
15859
if (alpha->r == 0. && alpha->i == 0.) {
15860
if (beta->r == 0. && beta->i == 0.) {
15861
i__1 = *n;
15862
for (j = 1; j <= i__1; ++j) {
15863
i__2 = *m;
15864
for (i__ = 1; i__ <= i__2; ++i__) {
15865
i__3 = i__ + j * c_dim1;
15866
c__[i__3].r = 0., c__[i__3].i = 0.;
15867
/* L10: */
15868
}
15869
/* L20: */
15870
}
15871
} else {
15872
i__1 = *n;
15873
for (j = 1; j <= i__1; ++j) {
15874
i__2 = *m;
15875
for (i__ = 1; i__ <= i__2; ++i__) {
15876
i__3 = i__ + j * c_dim1;
15877
i__4 = i__ + j * c_dim1;
15878
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
15879
z__1.i = beta->r * c__[i__4].i + beta->i * c__[
15880
i__4].r;
15881
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
15882
/* L30: */
15883
}
15884
/* L40: */
15885
}
15886
}
15887
return 0;
15888
}
15889
15890
/* Start the operations. */
15891
15892
if (notb) {
15893
if (nota) {
15894
15895
/* Form C := alpha*A*B + beta*C. */
15896
15897
i__1 = *n;
15898
for (j = 1; j <= i__1; ++j) {
15899
if (beta->r == 0. && beta->i == 0.) {
15900
i__2 = *m;
15901
for (i__ = 1; i__ <= i__2; ++i__) {
15902
i__3 = i__ + j * c_dim1;
15903
c__[i__3].r = 0., c__[i__3].i = 0.;
15904
/* L50: */
15905
}
15906
} else if (beta->r != 1. || beta->i != 0.) {
15907
i__2 = *m;
15908
for (i__ = 1; i__ <= i__2; ++i__) {
15909
i__3 = i__ + j * c_dim1;
15910
i__4 = i__ + j * c_dim1;
15911
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
15912
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
15913
c__[i__4].r;
15914
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
15915
/* L60: */
15916
}
15917
}
15918
i__2 = *k;
15919
for (l = 1; l <= i__2; ++l) {
15920
i__3 = l + j * b_dim1;
15921
if (b[i__3].r != 0. || b[i__3].i != 0.) {
15922
i__3 = l + j * b_dim1;
15923
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
15924
z__1.i = alpha->r * b[i__3].i + alpha->i * b[
15925
i__3].r;
15926
temp.r = z__1.r, temp.i = z__1.i;
15927
i__3 = *m;
15928
for (i__ = 1; i__ <= i__3; ++i__) {
15929
i__4 = i__ + j * c_dim1;
15930
i__5 = i__ + j * c_dim1;
15931
i__6 = i__ + l * a_dim1;
15932
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
15933
z__2.i = temp.r * a[i__6].i + temp.i * a[
15934
i__6].r;
15935
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
15936
.i + z__2.i;
15937
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
15938
/* L70: */
15939
}
15940
}
15941
/* L80: */
15942
}
15943
/* L90: */
15944
}
15945
} else if (conja) {
15946
15947
/* Form C := alpha*conjg( A' )*B + beta*C. */
15948
15949
i__1 = *n;
15950
for (j = 1; j <= i__1; ++j) {
15951
i__2 = *m;
15952
for (i__ = 1; i__ <= i__2; ++i__) {
15953
temp.r = 0., temp.i = 0.;
15954
i__3 = *k;
15955
for (l = 1; l <= i__3; ++l) {
15956
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
15957
i__4 = l + j * b_dim1;
15958
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
15959
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
15960
.r;
15961
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
15962
temp.r = z__1.r, temp.i = z__1.i;
15963
/* L100: */
15964
}
15965
if (beta->r == 0. && beta->i == 0.) {
15966
i__3 = i__ + j * c_dim1;
15967
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
15968
z__1.i = alpha->r * temp.i + alpha->i *
15969
temp.r;
15970
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
15971
} else {
15972
i__3 = i__ + j * c_dim1;
15973
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
15974
z__2.i = alpha->r * temp.i + alpha->i *
15975
temp.r;
15976
i__4 = i__ + j * c_dim1;
15977
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
15978
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
15979
c__[i__4].r;
15980
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
15981
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
15982
}
15983
/* L110: */
15984
}
15985
/* L120: */
15986
}
15987
} else {
15988
15989
/* Form C := alpha*A'*B + beta*C */
15990
15991
i__1 = *n;
15992
for (j = 1; j <= i__1; ++j) {
15993
i__2 = *m;
15994
for (i__ = 1; i__ <= i__2; ++i__) {
15995
temp.r = 0., temp.i = 0.;
15996
i__3 = *k;
15997
for (l = 1; l <= i__3; ++l) {
15998
i__4 = l + i__ * a_dim1;
15999
i__5 = l + j * b_dim1;
16000
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
16001
.i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
16002
.i * b[i__5].r;
16003
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16004
temp.r = z__1.r, temp.i = z__1.i;
16005
/* L130: */
16006
}
16007
if (beta->r == 0. && beta->i == 0.) {
16008
i__3 = i__ + j * c_dim1;
16009
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
16010
z__1.i = alpha->r * temp.i + alpha->i *
16011
temp.r;
16012
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16013
} else {
16014
i__3 = i__ + j * c_dim1;
16015
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
16016
z__2.i = alpha->r * temp.i + alpha->i *
16017
temp.r;
16018
i__4 = i__ + j * c_dim1;
16019
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16020
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
16021
c__[i__4].r;
16022
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
16023
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16024
}
16025
/* L140: */
16026
}
16027
/* L150: */
16028
}
16029
}
16030
} else if (nota) {
16031
if (conjb) {
16032
16033
/* Form C := alpha*A*conjg( B' ) + beta*C. */
16034
16035
i__1 = *n;
16036
for (j = 1; j <= i__1; ++j) {
16037
if (beta->r == 0. && beta->i == 0.) {
16038
i__2 = *m;
16039
for (i__ = 1; i__ <= i__2; ++i__) {
16040
i__3 = i__ + j * c_dim1;
16041
c__[i__3].r = 0., c__[i__3].i = 0.;
16042
/* L160: */
16043
}
16044
} else if (beta->r != 1. || beta->i != 0.) {
16045
i__2 = *m;
16046
for (i__ = 1; i__ <= i__2; ++i__) {
16047
i__3 = i__ + j * c_dim1;
16048
i__4 = i__ + j * c_dim1;
16049
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16050
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
16051
c__[i__4].r;
16052
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16053
/* L170: */
16054
}
16055
}
16056
i__2 = *k;
16057
for (l = 1; l <= i__2; ++l) {
16058
i__3 = j + l * b_dim1;
16059
if (b[i__3].r != 0. || b[i__3].i != 0.) {
16060
d_cnjg(&z__2, &b[j + l * b_dim1]);
16061
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i,
16062
z__1.i = alpha->r * z__2.i + alpha->i *
16063
z__2.r;
16064
temp.r = z__1.r, temp.i = z__1.i;
16065
i__3 = *m;
16066
for (i__ = 1; i__ <= i__3; ++i__) {
16067
i__4 = i__ + j * c_dim1;
16068
i__5 = i__ + j * c_dim1;
16069
i__6 = i__ + l * a_dim1;
16070
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
16071
z__2.i = temp.r * a[i__6].i + temp.i * a[
16072
i__6].r;
16073
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
16074
.i + z__2.i;
16075
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
16076
/* L180: */
16077
}
16078
}
16079
/* L190: */
16080
}
16081
/* L200: */
16082
}
16083
} else {
16084
16085
/* Form C := alpha*A*B' + beta*C */
16086
16087
i__1 = *n;
16088
for (j = 1; j <= i__1; ++j) {
16089
if (beta->r == 0. && beta->i == 0.) {
16090
i__2 = *m;
16091
for (i__ = 1; i__ <= i__2; ++i__) {
16092
i__3 = i__ + j * c_dim1;
16093
c__[i__3].r = 0., c__[i__3].i = 0.;
16094
/* L210: */
16095
}
16096
} else if (beta->r != 1. || beta->i != 0.) {
16097
i__2 = *m;
16098
for (i__ = 1; i__ <= i__2; ++i__) {
16099
i__3 = i__ + j * c_dim1;
16100
i__4 = i__ + j * c_dim1;
16101
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16102
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
16103
c__[i__4].r;
16104
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16105
/* L220: */
16106
}
16107
}
16108
i__2 = *k;
16109
for (l = 1; l <= i__2; ++l) {
16110
i__3 = j + l * b_dim1;
16111
if (b[i__3].r != 0. || b[i__3].i != 0.) {
16112
i__3 = j + l * b_dim1;
16113
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
16114
z__1.i = alpha->r * b[i__3].i + alpha->i * b[
16115
i__3].r;
16116
temp.r = z__1.r, temp.i = z__1.i;
16117
i__3 = *m;
16118
for (i__ = 1; i__ <= i__3; ++i__) {
16119
i__4 = i__ + j * c_dim1;
16120
i__5 = i__ + j * c_dim1;
16121
i__6 = i__ + l * a_dim1;
16122
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
16123
z__2.i = temp.r * a[i__6].i + temp.i * a[
16124
i__6].r;
16125
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
16126
.i + z__2.i;
16127
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
16128
/* L230: */
16129
}
16130
}
16131
/* L240: */
16132
}
16133
/* L250: */
16134
}
16135
}
16136
} else if (conja) {
16137
if (conjb) {
16138
16139
/* Form C := alpha*conjg( A' )*conjg( B' ) + beta*C. */
16140
16141
i__1 = *n;
16142
for (j = 1; j <= i__1; ++j) {
16143
i__2 = *m;
16144
for (i__ = 1; i__ <= i__2; ++i__) {
16145
temp.r = 0., temp.i = 0.;
16146
i__3 = *k;
16147
for (l = 1; l <= i__3; ++l) {
16148
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
16149
d_cnjg(&z__4, &b[j + l * b_dim1]);
16150
z__2.r = z__3.r * z__4.r - z__3.i * z__4.i, z__2.i =
16151
z__3.r * z__4.i + z__3.i * z__4.r;
16152
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16153
temp.r = z__1.r, temp.i = z__1.i;
16154
/* L260: */
16155
}
16156
if (beta->r == 0. && beta->i == 0.) {
16157
i__3 = i__ + j * c_dim1;
16158
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
16159
z__1.i = alpha->r * temp.i + alpha->i *
16160
temp.r;
16161
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16162
} else {
16163
i__3 = i__ + j * c_dim1;
16164
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
16165
z__2.i = alpha->r * temp.i + alpha->i *
16166
temp.r;
16167
i__4 = i__ + j * c_dim1;
16168
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16169
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
16170
c__[i__4].r;
16171
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
16172
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16173
}
16174
/* L270: */
16175
}
16176
/* L280: */
16177
}
16178
} else {
16179
16180
/* Form C := alpha*conjg( A' )*B' + beta*C */
16181
16182
i__1 = *n;
16183
for (j = 1; j <= i__1; ++j) {
16184
i__2 = *m;
16185
for (i__ = 1; i__ <= i__2; ++i__) {
16186
temp.r = 0., temp.i = 0.;
16187
i__3 = *k;
16188
for (l = 1; l <= i__3; ++l) {
16189
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
16190
i__4 = j + l * b_dim1;
16191
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
16192
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
16193
.r;
16194
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16195
temp.r = z__1.r, temp.i = z__1.i;
16196
/* L290: */
16197
}
16198
if (beta->r == 0. && beta->i == 0.) {
16199
i__3 = i__ + j * c_dim1;
16200
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
16201
z__1.i = alpha->r * temp.i + alpha->i *
16202
temp.r;
16203
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16204
} else {
16205
i__3 = i__ + j * c_dim1;
16206
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
16207
z__2.i = alpha->r * temp.i + alpha->i *
16208
temp.r;
16209
i__4 = i__ + j * c_dim1;
16210
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16211
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
16212
c__[i__4].r;
16213
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
16214
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16215
}
16216
/* L300: */
16217
}
16218
/* L310: */
16219
}
16220
}
16221
} else {
16222
if (conjb) {
16223
16224
/* Form C := alpha*A'*conjg( B' ) + beta*C */
16225
16226
i__1 = *n;
16227
for (j = 1; j <= i__1; ++j) {
16228
i__2 = *m;
16229
for (i__ = 1; i__ <= i__2; ++i__) {
16230
temp.r = 0., temp.i = 0.;
16231
i__3 = *k;
16232
for (l = 1; l <= i__3; ++l) {
16233
i__4 = l + i__ * a_dim1;
16234
d_cnjg(&z__3, &b[j + l * b_dim1]);
16235
z__2.r = a[i__4].r * z__3.r - a[i__4].i * z__3.i,
16236
z__2.i = a[i__4].r * z__3.i + a[i__4].i *
16237
z__3.r;
16238
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16239
temp.r = z__1.r, temp.i = z__1.i;
16240
/* L320: */
16241
}
16242
if (beta->r == 0. && beta->i == 0.) {
16243
i__3 = i__ + j * c_dim1;
16244
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
16245
z__1.i = alpha->r * temp.i + alpha->i *
16246
temp.r;
16247
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16248
} else {
16249
i__3 = i__ + j * c_dim1;
16250
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
16251
z__2.i = alpha->r * temp.i + alpha->i *
16252
temp.r;
16253
i__4 = i__ + j * c_dim1;
16254
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16255
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
16256
c__[i__4].r;
16257
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
16258
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16259
}
16260
/* L330: */
16261
}
16262
/* L340: */
16263
}
16264
} else {
16265
16266
/* Form C := alpha*A'*B' + beta*C */
16267
16268
i__1 = *n;
16269
for (j = 1; j <= i__1; ++j) {
16270
i__2 = *m;
16271
for (i__ = 1; i__ <= i__2; ++i__) {
16272
temp.r = 0., temp.i = 0.;
16273
i__3 = *k;
16274
for (l = 1; l <= i__3; ++l) {
16275
i__4 = l + i__ * a_dim1;
16276
i__5 = j + l * b_dim1;
16277
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
16278
.i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
16279
.i * b[i__5].r;
16280
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16281
temp.r = z__1.r, temp.i = z__1.i;
16282
/* L350: */
16283
}
16284
if (beta->r == 0. && beta->i == 0.) {
16285
i__3 = i__ + j * c_dim1;
16286
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
16287
z__1.i = alpha->r * temp.i + alpha->i *
16288
temp.r;
16289
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16290
} else {
16291
i__3 = i__ + j * c_dim1;
16292
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
16293
z__2.i = alpha->r * temp.i + alpha->i *
16294
temp.r;
16295
i__4 = i__ + j * c_dim1;
16296
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
16297
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
16298
c__[i__4].r;
16299
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
16300
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
16301
}
16302
/* L360: */
16303
}
16304
/* L370: */
16305
}
16306
}
16307
}
16308
16309
return 0;
16310
16311
/* End of ZGEMM . */
16312
16313
} /* zgemm_ */
16314
16315
/* Subroutine */ int zgemv_(char *trans, integer *m, integer *n,
16316
doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
16317
x, integer *incx, doublecomplex *beta, doublecomplex *y, integer *
16318
incy)
16319
{
16320
/* System generated locals */
16321
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
16322
doublecomplex z__1, z__2, z__3;
16323
16324
/* Local variables */
16325
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
16326
static doublecomplex temp;
16327
static integer lenx, leny;
16328
extern logical lsame_(char *, char *);
16329
extern /* Subroutine */ int xerbla_(char *, integer *);
16330
static logical noconj;
16331
16332
16333
/*
16334
Purpose
16335
=======
16336
16337
ZGEMV performs one of the matrix-vector operations
16338
16339
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or
16340
16341
y := alpha*conjg( A' )*x + beta*y,
16342
16343
where alpha and beta are scalars, x and y are vectors and A is an
16344
m by n matrix.
16345
16346
Arguments
16347
==========
16348
16349
TRANS - CHARACTER*1.
16350
On entry, TRANS specifies the operation to be performed as
16351
follows:
16352
16353
TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
16354
16355
TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
16356
16357
TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y.
16358
16359
Unchanged on exit.
16360
16361
M - INTEGER.
16362
On entry, M specifies the number of rows of the matrix A.
16363
M must be at least zero.
16364
Unchanged on exit.
16365
16366
N - INTEGER.
16367
On entry, N specifies the number of columns of the matrix A.
16368
N must be at least zero.
16369
Unchanged on exit.
16370
16371
ALPHA - COMPLEX*16 .
16372
On entry, ALPHA specifies the scalar alpha.
16373
Unchanged on exit.
16374
16375
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
16376
Before entry, the leading m by n part of the array A must
16377
contain the matrix of coefficients.
16378
Unchanged on exit.
16379
16380
LDA - INTEGER.
16381
On entry, LDA specifies the first dimension of A as declared
16382
in the calling (sub) program. LDA must be at least
16383
max( 1, m ).
16384
Unchanged on exit.
16385
16386
X - COMPLEX*16 array of DIMENSION at least
16387
( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
16388
and at least
16389
( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
16390
Before entry, the incremented array X must contain the
16391
vector x.
16392
Unchanged on exit.
16393
16394
INCX - INTEGER.
16395
On entry, INCX specifies the increment for the elements of
16396
X. INCX must not be zero.
16397
Unchanged on exit.
16398
16399
BETA - COMPLEX*16 .
16400
On entry, BETA specifies the scalar beta. When BETA is
16401
supplied as zero then Y need not be set on input.
16402
Unchanged on exit.
16403
16404
Y - COMPLEX*16 array of DIMENSION at least
16405
( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
16406
and at least
16407
( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
16408
Before entry with BETA non-zero, the incremented array Y
16409
must contain the vector y. On exit, Y is overwritten by the
16410
updated vector y.
16411
16412
INCY - INTEGER.
16413
On entry, INCY specifies the increment for the elements of
16414
Y. INCY must not be zero.
16415
Unchanged on exit.
16416
16417
Further Details
16418
===============
16419
16420
Level 2 Blas routine.
16421
16422
-- Written on 22-October-1986.
16423
Jack Dongarra, Argonne National Lab.
16424
Jeremy Du Croz, Nag Central Office.
16425
Sven Hammarling, Nag Central Office.
16426
Richard Hanson, Sandia National Labs.
16427
16428
=====================================================================
16429
16430
16431
Test the input parameters.
16432
*/
16433
16434
/* Parameter adjustments */
16435
a_dim1 = *lda;
16436
a_offset = 1 + a_dim1;
16437
a -= a_offset;
16438
--x;
16439
--y;
16440
16441
/* Function Body */
16442
info = 0;
16443
if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
16444
) {
16445
info = 1;
16446
} else if (*m < 0) {
16447
info = 2;
16448
} else if (*n < 0) {
16449
info = 3;
16450
} else if (*lda < max(1,*m)) {
16451
info = 6;
16452
} else if (*incx == 0) {
16453
info = 8;
16454
} else if (*incy == 0) {
16455
info = 11;
16456
}
16457
if (info != 0) {
16458
xerbla_("ZGEMV ", &info);
16459
return 0;
16460
}
16461
16462
/* Quick return if possible. */
16463
16464
if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0. && (beta->r ==
16465
1. && beta->i == 0.)) {
16466
return 0;
16467
}
16468
16469
noconj = lsame_(trans, "T");
16470
16471
/*
16472
Set LENX and LENY, the lengths of the vectors x and y, and set
16473
up the start points in X and Y.
16474
*/
16475
16476
if (lsame_(trans, "N")) {
16477
lenx = *n;
16478
leny = *m;
16479
} else {
16480
lenx = *m;
16481
leny = *n;
16482
}
16483
if (*incx > 0) {
16484
kx = 1;
16485
} else {
16486
kx = 1 - (lenx - 1) * *incx;
16487
}
16488
if (*incy > 0) {
16489
ky = 1;
16490
} else {
16491
ky = 1 - (leny - 1) * *incy;
16492
}
16493
16494
/*
16495
Start the operations. In this version the elements of A are
16496
accessed sequentially with one pass through A.
16497
16498
First form y := beta*y.
16499
*/
16500
16501
if (beta->r != 1. || beta->i != 0.) {
16502
if (*incy == 1) {
16503
if (beta->r == 0. && beta->i == 0.) {
16504
i__1 = leny;
16505
for (i__ = 1; i__ <= i__1; ++i__) {
16506
i__2 = i__;
16507
y[i__2].r = 0., y[i__2].i = 0.;
16508
/* L10: */
16509
}
16510
} else {
16511
i__1 = leny;
16512
for (i__ = 1; i__ <= i__1; ++i__) {
16513
i__2 = i__;
16514
i__3 = i__;
16515
z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
16516
z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
16517
.r;
16518
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
16519
/* L20: */
16520
}
16521
}
16522
} else {
16523
iy = ky;
16524
if (beta->r == 0. && beta->i == 0.) {
16525
i__1 = leny;
16526
for (i__ = 1; i__ <= i__1; ++i__) {
16527
i__2 = iy;
16528
y[i__2].r = 0., y[i__2].i = 0.;
16529
iy += *incy;
16530
/* L30: */
16531
}
16532
} else {
16533
i__1 = leny;
16534
for (i__ = 1; i__ <= i__1; ++i__) {
16535
i__2 = iy;
16536
i__3 = iy;
16537
z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
16538
z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
16539
.r;
16540
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
16541
iy += *incy;
16542
/* L40: */
16543
}
16544
}
16545
}
16546
}
16547
if (alpha->r == 0. && alpha->i == 0.) {
16548
return 0;
16549
}
16550
if (lsame_(trans, "N")) {
16551
16552
/* Form y := alpha*A*x + y. */
16553
16554
jx = kx;
16555
if (*incy == 1) {
16556
i__1 = *n;
16557
for (j = 1; j <= i__1; ++j) {
16558
i__2 = jx;
16559
if (x[i__2].r != 0. || x[i__2].i != 0.) {
16560
i__2 = jx;
16561
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
16562
z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
16563
.r;
16564
temp.r = z__1.r, temp.i = z__1.i;
16565
i__2 = *m;
16566
for (i__ = 1; i__ <= i__2; ++i__) {
16567
i__3 = i__;
16568
i__4 = i__;
16569
i__5 = i__ + j * a_dim1;
16570
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
16571
z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
16572
.r;
16573
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i +
16574
z__2.i;
16575
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
16576
/* L50: */
16577
}
16578
}
16579
jx += *incx;
16580
/* L60: */
16581
}
16582
} else {
16583
i__1 = *n;
16584
for (j = 1; j <= i__1; ++j) {
16585
i__2 = jx;
16586
if (x[i__2].r != 0. || x[i__2].i != 0.) {
16587
i__2 = jx;
16588
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
16589
z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
16590
.r;
16591
temp.r = z__1.r, temp.i = z__1.i;
16592
iy = ky;
16593
i__2 = *m;
16594
for (i__ = 1; i__ <= i__2; ++i__) {
16595
i__3 = iy;
16596
i__4 = iy;
16597
i__5 = i__ + j * a_dim1;
16598
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
16599
z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
16600
.r;
16601
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i +
16602
z__2.i;
16603
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
16604
iy += *incy;
16605
/* L70: */
16606
}
16607
}
16608
jx += *incx;
16609
/* L80: */
16610
}
16611
}
16612
} else {
16613
16614
/* Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y. */
16615
16616
jy = ky;
16617
if (*incx == 1) {
16618
i__1 = *n;
16619
for (j = 1; j <= i__1; ++j) {
16620
temp.r = 0., temp.i = 0.;
16621
if (noconj) {
16622
i__2 = *m;
16623
for (i__ = 1; i__ <= i__2; ++i__) {
16624
i__3 = i__ + j * a_dim1;
16625
i__4 = i__;
16626
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
16627
.i, z__2.i = a[i__3].r * x[i__4].i + a[i__3]
16628
.i * x[i__4].r;
16629
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16630
temp.r = z__1.r, temp.i = z__1.i;
16631
/* L90: */
16632
}
16633
} else {
16634
i__2 = *m;
16635
for (i__ = 1; i__ <= i__2; ++i__) {
16636
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
16637
i__3 = i__;
16638
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
16639
z__2.i = z__3.r * x[i__3].i + z__3.i * x[i__3]
16640
.r;
16641
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16642
temp.r = z__1.r, temp.i = z__1.i;
16643
/* L100: */
16644
}
16645
}
16646
i__2 = jy;
16647
i__3 = jy;
16648
z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i =
16649
alpha->r * temp.i + alpha->i * temp.r;
16650
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
16651
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
16652
jy += *incy;
16653
/* L110: */
16654
}
16655
} else {
16656
i__1 = *n;
16657
for (j = 1; j <= i__1; ++j) {
16658
temp.r = 0., temp.i = 0.;
16659
ix = kx;
16660
if (noconj) {
16661
i__2 = *m;
16662
for (i__ = 1; i__ <= i__2; ++i__) {
16663
i__3 = i__ + j * a_dim1;
16664
i__4 = ix;
16665
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
16666
.i, z__2.i = a[i__3].r * x[i__4].i + a[i__3]
16667
.i * x[i__4].r;
16668
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16669
temp.r = z__1.r, temp.i = z__1.i;
16670
ix += *incx;
16671
/* L120: */
16672
}
16673
} else {
16674
i__2 = *m;
16675
for (i__ = 1; i__ <= i__2; ++i__) {
16676
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
16677
i__3 = ix;
16678
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
16679
z__2.i = z__3.r * x[i__3].i + z__3.i * x[i__3]
16680
.r;
16681
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
16682
temp.r = z__1.r, temp.i = z__1.i;
16683
ix += *incx;
16684
/* L130: */
16685
}
16686
}
16687
i__2 = jy;
16688
i__3 = jy;
16689
z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i =
16690
alpha->r * temp.i + alpha->i * temp.r;
16691
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
16692
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
16693
jy += *incy;
16694
/* L140: */
16695
}
16696
}
16697
}
16698
16699
return 0;
16700
16701
/* End of ZGEMV . */
16702
16703
} /* zgemv_ */
16704
16705
/* Subroutine */ int zgerc_(integer *m, integer *n, doublecomplex *alpha,
16706
doublecomplex *x, integer *incx, doublecomplex *y, integer *incy,
16707
doublecomplex *a, integer *lda)
16708
{
16709
/* System generated locals */
16710
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
16711
doublecomplex z__1, z__2;
16712
16713
/* Local variables */
16714
static integer i__, j, ix, jy, kx, info;
16715
static doublecomplex temp;
16716
extern /* Subroutine */ int xerbla_(char *, integer *);
16717
16718
16719
/*
16720
Purpose
16721
=======
16722
16723
ZGERC performs the rank 1 operation
16724
16725
A := alpha*x*conjg( y' ) + A,
16726
16727
where alpha is a scalar, x is an m element vector, y is an n element
16728
vector and A is an m by n matrix.
16729
16730
Arguments
16731
==========
16732
16733
M - INTEGER.
16734
On entry, M specifies the number of rows of the matrix A.
16735
M must be at least zero.
16736
Unchanged on exit.
16737
16738
N - INTEGER.
16739
On entry, N specifies the number of columns of the matrix A.
16740
N must be at least zero.
16741
Unchanged on exit.
16742
16743
ALPHA - COMPLEX*16 .
16744
On entry, ALPHA specifies the scalar alpha.
16745
Unchanged on exit.
16746
16747
X - COMPLEX*16 array of dimension at least
16748
( 1 + ( m - 1 )*abs( INCX ) ).
16749
Before entry, the incremented array X must contain the m
16750
element vector x.
16751
Unchanged on exit.
16752
16753
INCX - INTEGER.
16754
On entry, INCX specifies the increment for the elements of
16755
X. INCX must not be zero.
16756
Unchanged on exit.
16757
16758
Y - COMPLEX*16 array of dimension at least
16759
( 1 + ( n - 1 )*abs( INCY ) ).
16760
Before entry, the incremented array Y must contain the n
16761
element vector y.
16762
Unchanged on exit.
16763
16764
INCY - INTEGER.
16765
On entry, INCY specifies the increment for the elements of
16766
Y. INCY must not be zero.
16767
Unchanged on exit.
16768
16769
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
16770
Before entry, the leading m by n part of the array A must
16771
contain the matrix of coefficients. On exit, A is
16772
overwritten by the updated matrix.
16773
16774
LDA - INTEGER.
16775
On entry, LDA specifies the first dimension of A as declared
16776
in the calling (sub) program. LDA must be at least
16777
max( 1, m ).
16778
Unchanged on exit.
16779
16780
Further Details
16781
===============
16782
16783
Level 2 Blas routine.
16784
16785
-- Written on 22-October-1986.
16786
Jack Dongarra, Argonne National Lab.
16787
Jeremy Du Croz, Nag Central Office.
16788
Sven Hammarling, Nag Central Office.
16789
Richard Hanson, Sandia National Labs.
16790
16791
=====================================================================
16792
16793
16794
Test the input parameters.
16795
*/
16796
16797
/* Parameter adjustments */
16798
--x;
16799
--y;
16800
a_dim1 = *lda;
16801
a_offset = 1 + a_dim1;
16802
a -= a_offset;
16803
16804
/* Function Body */
16805
info = 0;
16806
if (*m < 0) {
16807
info = 1;
16808
} else if (*n < 0) {
16809
info = 2;
16810
} else if (*incx == 0) {
16811
info = 5;
16812
} else if (*incy == 0) {
16813
info = 7;
16814
} else if (*lda < max(1,*m)) {
16815
info = 9;
16816
}
16817
if (info != 0) {
16818
xerbla_("ZGERC ", &info);
16819
return 0;
16820
}
16821
16822
/* Quick return if possible. */
16823
16824
if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0.) {
16825
return 0;
16826
}
16827
16828
/*
16829
Start the operations. In this version the elements of A are
16830
accessed sequentially with one pass through A.
16831
*/
16832
16833
if (*incy > 0) {
16834
jy = 1;
16835
} else {
16836
jy = 1 - (*n - 1) * *incy;
16837
}
16838
if (*incx == 1) {
16839
i__1 = *n;
16840
for (j = 1; j <= i__1; ++j) {
16841
i__2 = jy;
16842
if (y[i__2].r != 0. || y[i__2].i != 0.) {
16843
d_cnjg(&z__2, &y[jy]);
16844
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
16845
alpha->r * z__2.i + alpha->i * z__2.r;
16846
temp.r = z__1.r, temp.i = z__1.i;
16847
i__2 = *m;
16848
for (i__ = 1; i__ <= i__2; ++i__) {
16849
i__3 = i__ + j * a_dim1;
16850
i__4 = i__ + j * a_dim1;
16851
i__5 = i__;
16852
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, z__2.i =
16853
x[i__5].r * temp.i + x[i__5].i * temp.r;
16854
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + z__2.i;
16855
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
16856
/* L10: */
16857
}
16858
}
16859
jy += *incy;
16860
/* L20: */
16861
}
16862
} else {
16863
if (*incx > 0) {
16864
kx = 1;
16865
} else {
16866
kx = 1 - (*m - 1) * *incx;
16867
}
16868
i__1 = *n;
16869
for (j = 1; j <= i__1; ++j) {
16870
i__2 = jy;
16871
if (y[i__2].r != 0. || y[i__2].i != 0.) {
16872
d_cnjg(&z__2, &y[jy]);
16873
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
16874
alpha->r * z__2.i + alpha->i * z__2.r;
16875
temp.r = z__1.r, temp.i = z__1.i;
16876
ix = kx;
16877
i__2 = *m;
16878
for (i__ = 1; i__ <= i__2; ++i__) {
16879
i__3 = i__ + j * a_dim1;
16880
i__4 = i__ + j * a_dim1;
16881
i__5 = ix;
16882
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, z__2.i =
16883
x[i__5].r * temp.i + x[i__5].i * temp.r;
16884
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + z__2.i;
16885
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
16886
ix += *incx;
16887
/* L30: */
16888
}
16889
}
16890
jy += *incy;
16891
/* L40: */
16892
}
16893
}
16894
16895
return 0;
16896
16897
/* End of ZGERC . */
16898
16899
} /* zgerc_ */
16900
16901
/* Subroutine */ int zgeru_(integer *m, integer *n, doublecomplex *alpha,
16902
doublecomplex *x, integer *incx, doublecomplex *y, integer *incy,
16903
doublecomplex *a, integer *lda)
16904
{
16905
/* System generated locals */
16906
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
16907
doublecomplex z__1, z__2;
16908
16909
/* Local variables */
16910
static integer i__, j, ix, jy, kx, info;
16911
static doublecomplex temp;
16912
extern /* Subroutine */ int xerbla_(char *, integer *);
16913
16914
16915
/*
16916
Purpose
16917
=======
16918
16919
ZGERU performs the rank 1 operation
16920
16921
A := alpha*x*y' + A,
16922
16923
where alpha is a scalar, x is an m element vector, y is an n element
16924
vector and A is an m by n matrix.
16925
16926
Arguments
16927
==========
16928
16929
M - INTEGER.
16930
On entry, M specifies the number of rows of the matrix A.
16931
M must be at least zero.
16932
Unchanged on exit.
16933
16934
N - INTEGER.
16935
On entry, N specifies the number of columns of the matrix A.
16936
N must be at least zero.
16937
Unchanged on exit.
16938
16939
ALPHA - COMPLEX*16 .
16940
On entry, ALPHA specifies the scalar alpha.
16941
Unchanged on exit.
16942
16943
X - COMPLEX*16 array of dimension at least
16944
( 1 + ( m - 1 )*abs( INCX ) ).
16945
Before entry, the incremented array X must contain the m
16946
element vector x.
16947
Unchanged on exit.
16948
16949
INCX - INTEGER.
16950
On entry, INCX specifies the increment for the elements of
16951
X. INCX must not be zero.
16952
Unchanged on exit.
16953
16954
Y - COMPLEX*16 array of dimension at least
16955
( 1 + ( n - 1 )*abs( INCY ) ).
16956
Before entry, the incremented array Y must contain the n
16957
element vector y.
16958
Unchanged on exit.
16959
16960
INCY - INTEGER.
16961
On entry, INCY specifies the increment for the elements of
16962
Y. INCY must not be zero.
16963
Unchanged on exit.
16964
16965
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
16966
Before entry, the leading m by n part of the array A must
16967
contain the matrix of coefficients. On exit, A is
16968
overwritten by the updated matrix.
16969
16970
LDA - INTEGER.
16971
On entry, LDA specifies the first dimension of A as declared
16972
in the calling (sub) program. LDA must be at least
16973
max( 1, m ).
16974
Unchanged on exit.
16975
16976
Further Details
16977
===============
16978
16979
Level 2 Blas routine.
16980
16981
-- Written on 22-October-1986.
16982
Jack Dongarra, Argonne National Lab.
16983
Jeremy Du Croz, Nag Central Office.
16984
Sven Hammarling, Nag Central Office.
16985
Richard Hanson, Sandia National Labs.
16986
16987
=====================================================================
16988
16989
16990
Test the input parameters.
16991
*/
16992
16993
/* Parameter adjustments */
16994
--x;
16995
--y;
16996
a_dim1 = *lda;
16997
a_offset = 1 + a_dim1;
16998
a -= a_offset;
16999
17000
/* Function Body */
17001
info = 0;
17002
if (*m < 0) {
17003
info = 1;
17004
} else if (*n < 0) {
17005
info = 2;
17006
} else if (*incx == 0) {
17007
info = 5;
17008
} else if (*incy == 0) {
17009
info = 7;
17010
} else if (*lda < max(1,*m)) {
17011
info = 9;
17012
}
17013
if (info != 0) {
17014
xerbla_("ZGERU ", &info);
17015
return 0;
17016
}
17017
17018
/* Quick return if possible. */
17019
17020
if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0.) {
17021
return 0;
17022
}
17023
17024
/*
17025
Start the operations. In this version the elements of A are
17026
accessed sequentially with one pass through A.
17027
*/
17028
17029
if (*incy > 0) {
17030
jy = 1;
17031
} else {
17032
jy = 1 - (*n - 1) * *incy;
17033
}
17034
if (*incx == 1) {
17035
i__1 = *n;
17036
for (j = 1; j <= i__1; ++j) {
17037
i__2 = jy;
17038
if (y[i__2].r != 0. || y[i__2].i != 0.) {
17039
i__2 = jy;
17040
z__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, z__1.i =
17041
alpha->r * y[i__2].i + alpha->i * y[i__2].r;
17042
temp.r = z__1.r, temp.i = z__1.i;
17043
i__2 = *m;
17044
for (i__ = 1; i__ <= i__2; ++i__) {
17045
i__3 = i__ + j * a_dim1;
17046
i__4 = i__ + j * a_dim1;
17047
i__5 = i__;
17048
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, z__2.i =
17049
x[i__5].r * temp.i + x[i__5].i * temp.r;
17050
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + z__2.i;
17051
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17052
/* L10: */
17053
}
17054
}
17055
jy += *incy;
17056
/* L20: */
17057
}
17058
} else {
17059
if (*incx > 0) {
17060
kx = 1;
17061
} else {
17062
kx = 1 - (*m - 1) * *incx;
17063
}
17064
i__1 = *n;
17065
for (j = 1; j <= i__1; ++j) {
17066
i__2 = jy;
17067
if (y[i__2].r != 0. || y[i__2].i != 0.) {
17068
i__2 = jy;
17069
z__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, z__1.i =
17070
alpha->r * y[i__2].i + alpha->i * y[i__2].r;
17071
temp.r = z__1.r, temp.i = z__1.i;
17072
ix = kx;
17073
i__2 = *m;
17074
for (i__ = 1; i__ <= i__2; ++i__) {
17075
i__3 = i__ + j * a_dim1;
17076
i__4 = i__ + j * a_dim1;
17077
i__5 = ix;
17078
z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, z__2.i =
17079
x[i__5].r * temp.i + x[i__5].i * temp.r;
17080
z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + z__2.i;
17081
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17082
ix += *incx;
17083
/* L30: */
17084
}
17085
}
17086
jy += *incy;
17087
/* L40: */
17088
}
17089
}
17090
17091
return 0;
17092
17093
/* End of ZGERU . */
17094
17095
} /* zgeru_ */
17096
17097
/* Subroutine */ int zhemv_(char *uplo, integer *n, doublecomplex *alpha,
17098
doublecomplex *a, integer *lda, doublecomplex *x, integer *incx,
17099
doublecomplex *beta, doublecomplex *y, integer *incy)
17100
{
17101
/* System generated locals */
17102
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
17103
doublereal d__1;
17104
doublecomplex z__1, z__2, z__3, z__4;
17105
17106
/* Local variables */
17107
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
17108
static doublecomplex temp1, temp2;
17109
extern logical lsame_(char *, char *);
17110
extern /* Subroutine */ int xerbla_(char *, integer *);
17111
17112
17113
/*
17114
Purpose
17115
=======
17116
17117
ZHEMV performs the matrix-vector operation
17118
17119
y := alpha*A*x + beta*y,
17120
17121
where alpha and beta are scalars, x and y are n element vectors and
17122
A is an n by n hermitian matrix.
17123
17124
Arguments
17125
==========
17126
17127
UPLO - CHARACTER*1.
17128
On entry, UPLO specifies whether the upper or lower
17129
triangular part of the array A is to be referenced as
17130
follows:
17131
17132
UPLO = 'U' or 'u' Only the upper triangular part of A
17133
is to be referenced.
17134
17135
UPLO = 'L' or 'l' Only the lower triangular part of A
17136
is to be referenced.
17137
17138
Unchanged on exit.
17139
17140
N - INTEGER.
17141
On entry, N specifies the order of the matrix A.
17142
N must be at least zero.
17143
Unchanged on exit.
17144
17145
ALPHA - COMPLEX*16 .
17146
On entry, ALPHA specifies the scalar alpha.
17147
Unchanged on exit.
17148
17149
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
17150
Before entry with UPLO = 'U' or 'u', the leading n by n
17151
upper triangular part of the array A must contain the upper
17152
triangular part of the hermitian matrix and the strictly
17153
lower triangular part of A is not referenced.
17154
Before entry with UPLO = 'L' or 'l', the leading n by n
17155
lower triangular part of the array A must contain the lower
17156
triangular part of the hermitian matrix and the strictly
17157
upper triangular part of A is not referenced.
17158
Note that the imaginary parts of the diagonal elements need
17159
not be set and are assumed to be zero.
17160
Unchanged on exit.
17161
17162
LDA - INTEGER.
17163
On entry, LDA specifies the first dimension of A as declared
17164
in the calling (sub) program. LDA must be at least
17165
max( 1, n ).
17166
Unchanged on exit.
17167
17168
X - COMPLEX*16 array of dimension at least
17169
( 1 + ( n - 1 )*abs( INCX ) ).
17170
Before entry, the incremented array X must contain the n
17171
element vector x.
17172
Unchanged on exit.
17173
17174
INCX - INTEGER.
17175
On entry, INCX specifies the increment for the elements of
17176
X. INCX must not be zero.
17177
Unchanged on exit.
17178
17179
BETA - COMPLEX*16 .
17180
On entry, BETA specifies the scalar beta. When BETA is
17181
supplied as zero then Y need not be set on input.
17182
Unchanged on exit.
17183
17184
Y - COMPLEX*16 array of dimension at least
17185
( 1 + ( n - 1 )*abs( INCY ) ).
17186
Before entry, the incremented array Y must contain the n
17187
element vector y. On exit, Y is overwritten by the updated
17188
vector y.
17189
17190
INCY - INTEGER.
17191
On entry, INCY specifies the increment for the elements of
17192
Y. INCY must not be zero.
17193
Unchanged on exit.
17194
17195
Further Details
17196
===============
17197
17198
Level 2 Blas routine.
17199
17200
-- Written on 22-October-1986.
17201
Jack Dongarra, Argonne National Lab.
17202
Jeremy Du Croz, Nag Central Office.
17203
Sven Hammarling, Nag Central Office.
17204
Richard Hanson, Sandia National Labs.
17205
17206
=====================================================================
17207
17208
17209
Test the input parameters.
17210
*/
17211
17212
/* Parameter adjustments */
17213
a_dim1 = *lda;
17214
a_offset = 1 + a_dim1;
17215
a -= a_offset;
17216
--x;
17217
--y;
17218
17219
/* Function Body */
17220
info = 0;
17221
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
17222
info = 1;
17223
} else if (*n < 0) {
17224
info = 2;
17225
} else if (*lda < max(1,*n)) {
17226
info = 5;
17227
} else if (*incx == 0) {
17228
info = 7;
17229
} else if (*incy == 0) {
17230
info = 10;
17231
}
17232
if (info != 0) {
17233
xerbla_("ZHEMV ", &info);
17234
return 0;
17235
}
17236
17237
/* Quick return if possible. */
17238
17239
if (*n == 0 || alpha->r == 0. && alpha->i == 0. && (beta->r == 1. &&
17240
beta->i == 0.)) {
17241
return 0;
17242
}
17243
17244
/* Set up the start points in X and Y. */
17245
17246
if (*incx > 0) {
17247
kx = 1;
17248
} else {
17249
kx = 1 - (*n - 1) * *incx;
17250
}
17251
if (*incy > 0) {
17252
ky = 1;
17253
} else {
17254
ky = 1 - (*n - 1) * *incy;
17255
}
17256
17257
/*
17258
Start the operations. In this version the elements of A are
17259
accessed sequentially with one pass through the triangular part
17260
of A.
17261
17262
First form y := beta*y.
17263
*/
17264
17265
if (beta->r != 1. || beta->i != 0.) {
17266
if (*incy == 1) {
17267
if (beta->r == 0. && beta->i == 0.) {
17268
i__1 = *n;
17269
for (i__ = 1; i__ <= i__1; ++i__) {
17270
i__2 = i__;
17271
y[i__2].r = 0., y[i__2].i = 0.;
17272
/* L10: */
17273
}
17274
} else {
17275
i__1 = *n;
17276
for (i__ = 1; i__ <= i__1; ++i__) {
17277
i__2 = i__;
17278
i__3 = i__;
17279
z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
17280
z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
17281
.r;
17282
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17283
/* L20: */
17284
}
17285
}
17286
} else {
17287
iy = ky;
17288
if (beta->r == 0. && beta->i == 0.) {
17289
i__1 = *n;
17290
for (i__ = 1; i__ <= i__1; ++i__) {
17291
i__2 = iy;
17292
y[i__2].r = 0., y[i__2].i = 0.;
17293
iy += *incy;
17294
/* L30: */
17295
}
17296
} else {
17297
i__1 = *n;
17298
for (i__ = 1; i__ <= i__1; ++i__) {
17299
i__2 = iy;
17300
i__3 = iy;
17301
z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
17302
z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
17303
.r;
17304
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17305
iy += *incy;
17306
/* L40: */
17307
}
17308
}
17309
}
17310
}
17311
if (alpha->r == 0. && alpha->i == 0.) {
17312
return 0;
17313
}
17314
if (lsame_(uplo, "U")) {
17315
17316
/* Form y when A is stored in upper triangle. */
17317
17318
if (*incx == 1 && *incy == 1) {
17319
i__1 = *n;
17320
for (j = 1; j <= i__1; ++j) {
17321
i__2 = j;
17322
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, z__1.i =
17323
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
17324
temp1.r = z__1.r, temp1.i = z__1.i;
17325
temp2.r = 0., temp2.i = 0.;
17326
i__2 = j - 1;
17327
for (i__ = 1; i__ <= i__2; ++i__) {
17328
i__3 = i__;
17329
i__4 = i__;
17330
i__5 = i__ + j * a_dim1;
17331
z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
17332
z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
17333
.r;
17334
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
17335
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
17336
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
17337
i__3 = i__;
17338
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i, z__2.i =
17339
z__3.r * x[i__3].i + z__3.i * x[i__3].r;
17340
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
17341
temp2.r = z__1.r, temp2.i = z__1.i;
17342
/* L50: */
17343
}
17344
i__2 = j;
17345
i__3 = j;
17346
i__4 = j + j * a_dim1;
17347
d__1 = a[i__4].r;
17348
z__3.r = d__1 * temp1.r, z__3.i = d__1 * temp1.i;
17349
z__2.r = y[i__3].r + z__3.r, z__2.i = y[i__3].i + z__3.i;
17350
z__4.r = alpha->r * temp2.r - alpha->i * temp2.i, z__4.i =
17351
alpha->r * temp2.i + alpha->i * temp2.r;
17352
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17353
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17354
/* L60: */
17355
}
17356
} else {
17357
jx = kx;
17358
jy = ky;
17359
i__1 = *n;
17360
for (j = 1; j <= i__1; ++j) {
17361
i__2 = jx;
17362
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, z__1.i =
17363
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
17364
temp1.r = z__1.r, temp1.i = z__1.i;
17365
temp2.r = 0., temp2.i = 0.;
17366
ix = kx;
17367
iy = ky;
17368
i__2 = j - 1;
17369
for (i__ = 1; i__ <= i__2; ++i__) {
17370
i__3 = iy;
17371
i__4 = iy;
17372
i__5 = i__ + j * a_dim1;
17373
z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
17374
z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
17375
.r;
17376
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
17377
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
17378
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
17379
i__3 = ix;
17380
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i, z__2.i =
17381
z__3.r * x[i__3].i + z__3.i * x[i__3].r;
17382
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
17383
temp2.r = z__1.r, temp2.i = z__1.i;
17384
ix += *incx;
17385
iy += *incy;
17386
/* L70: */
17387
}
17388
i__2 = jy;
17389
i__3 = jy;
17390
i__4 = j + j * a_dim1;
17391
d__1 = a[i__4].r;
17392
z__3.r = d__1 * temp1.r, z__3.i = d__1 * temp1.i;
17393
z__2.r = y[i__3].r + z__3.r, z__2.i = y[i__3].i + z__3.i;
17394
z__4.r = alpha->r * temp2.r - alpha->i * temp2.i, z__4.i =
17395
alpha->r * temp2.i + alpha->i * temp2.r;
17396
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17397
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17398
jx += *incx;
17399
jy += *incy;
17400
/* L80: */
17401
}
17402
}
17403
} else {
17404
17405
/* Form y when A is stored in lower triangle. */
17406
17407
if (*incx == 1 && *incy == 1) {
17408
i__1 = *n;
17409
for (j = 1; j <= i__1; ++j) {
17410
i__2 = j;
17411
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, z__1.i =
17412
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
17413
temp1.r = z__1.r, temp1.i = z__1.i;
17414
temp2.r = 0., temp2.i = 0.;
17415
i__2 = j;
17416
i__3 = j;
17417
i__4 = j + j * a_dim1;
17418
d__1 = a[i__4].r;
17419
z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
17420
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
17421
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17422
i__2 = *n;
17423
for (i__ = j + 1; i__ <= i__2; ++i__) {
17424
i__3 = i__;
17425
i__4 = i__;
17426
i__5 = i__ + j * a_dim1;
17427
z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
17428
z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
17429
.r;
17430
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
17431
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
17432
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
17433
i__3 = i__;
17434
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i, z__2.i =
17435
z__3.r * x[i__3].i + z__3.i * x[i__3].r;
17436
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
17437
temp2.r = z__1.r, temp2.i = z__1.i;
17438
/* L90: */
17439
}
17440
i__2 = j;
17441
i__3 = j;
17442
z__2.r = alpha->r * temp2.r - alpha->i * temp2.i, z__2.i =
17443
alpha->r * temp2.i + alpha->i * temp2.r;
17444
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
17445
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17446
/* L100: */
17447
}
17448
} else {
17449
jx = kx;
17450
jy = ky;
17451
i__1 = *n;
17452
for (j = 1; j <= i__1; ++j) {
17453
i__2 = jx;
17454
z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, z__1.i =
17455
alpha->r * x[i__2].i + alpha->i * x[i__2].r;
17456
temp1.r = z__1.r, temp1.i = z__1.i;
17457
temp2.r = 0., temp2.i = 0.;
17458
i__2 = jy;
17459
i__3 = jy;
17460
i__4 = j + j * a_dim1;
17461
d__1 = a[i__4].r;
17462
z__2.r = d__1 * temp1.r, z__2.i = d__1 * temp1.i;
17463
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
17464
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17465
ix = jx;
17466
iy = jy;
17467
i__2 = *n;
17468
for (i__ = j + 1; i__ <= i__2; ++i__) {
17469
ix += *incx;
17470
iy += *incy;
17471
i__3 = iy;
17472
i__4 = iy;
17473
i__5 = i__ + j * a_dim1;
17474
z__2.r = temp1.r * a[i__5].r - temp1.i * a[i__5].i,
17475
z__2.i = temp1.r * a[i__5].i + temp1.i * a[i__5]
17476
.r;
17477
z__1.r = y[i__4].r + z__2.r, z__1.i = y[i__4].i + z__2.i;
17478
y[i__3].r = z__1.r, y[i__3].i = z__1.i;
17479
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
17480
i__3 = ix;
17481
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i, z__2.i =
17482
z__3.r * x[i__3].i + z__3.i * x[i__3].r;
17483
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
17484
temp2.r = z__1.r, temp2.i = z__1.i;
17485
/* L110: */
17486
}
17487
i__2 = jy;
17488
i__3 = jy;
17489
z__2.r = alpha->r * temp2.r - alpha->i * temp2.i, z__2.i =
17490
alpha->r * temp2.i + alpha->i * temp2.r;
17491
z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
17492
y[i__2].r = z__1.r, y[i__2].i = z__1.i;
17493
jx += *incx;
17494
jy += *incy;
17495
/* L120: */
17496
}
17497
}
17498
}
17499
17500
return 0;
17501
17502
/* End of ZHEMV . */
17503
17504
} /* zhemv_ */
17505
17506
/* Subroutine */ int zher2_(char *uplo, integer *n, doublecomplex *alpha,
17507
doublecomplex *x, integer *incx, doublecomplex *y, integer *incy,
17508
doublecomplex *a, integer *lda)
17509
{
17510
/* System generated locals */
17511
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
17512
doublereal d__1;
17513
doublecomplex z__1, z__2, z__3, z__4;
17514
17515
/* Local variables */
17516
static integer i__, j, ix, iy, jx, jy, kx, ky, info;
17517
static doublecomplex temp1, temp2;
17518
extern logical lsame_(char *, char *);
17519
extern /* Subroutine */ int xerbla_(char *, integer *);
17520
17521
17522
/*
17523
Purpose
17524
=======
17525
17526
ZHER2 performs the hermitian rank 2 operation
17527
17528
A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
17529
17530
where alpha is a scalar, x and y are n element vectors and A is an n
17531
by n hermitian matrix.
17532
17533
Arguments
17534
==========
17535
17536
UPLO - CHARACTER*1.
17537
On entry, UPLO specifies whether the upper or lower
17538
triangular part of the array A is to be referenced as
17539
follows:
17540
17541
UPLO = 'U' or 'u' Only the upper triangular part of A
17542
is to be referenced.
17543
17544
UPLO = 'L' or 'l' Only the lower triangular part of A
17545
is to be referenced.
17546
17547
Unchanged on exit.
17548
17549
N - INTEGER.
17550
On entry, N specifies the order of the matrix A.
17551
N must be at least zero.
17552
Unchanged on exit.
17553
17554
ALPHA - COMPLEX*16 .
17555
On entry, ALPHA specifies the scalar alpha.
17556
Unchanged on exit.
17557
17558
X - COMPLEX*16 array of dimension at least
17559
( 1 + ( n - 1 )*abs( INCX ) ).
17560
Before entry, the incremented array X must contain the n
17561
element vector x.
17562
Unchanged on exit.
17563
17564
INCX - INTEGER.
17565
On entry, INCX specifies the increment for the elements of
17566
X. INCX must not be zero.
17567
Unchanged on exit.
17568
17569
Y - COMPLEX*16 array of dimension at least
17570
( 1 + ( n - 1 )*abs( INCY ) ).
17571
Before entry, the incremented array Y must contain the n
17572
element vector y.
17573
Unchanged on exit.
17574
17575
INCY - INTEGER.
17576
On entry, INCY specifies the increment for the elements of
17577
Y. INCY must not be zero.
17578
Unchanged on exit.
17579
17580
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
17581
Before entry with UPLO = 'U' or 'u', the leading n by n
17582
upper triangular part of the array A must contain the upper
17583
triangular part of the hermitian matrix and the strictly
17584
lower triangular part of A is not referenced. On exit, the
17585
upper triangular part of the array A is overwritten by the
17586
upper triangular part of the updated matrix.
17587
Before entry with UPLO = 'L' or 'l', the leading n by n
17588
lower triangular part of the array A must contain the lower
17589
triangular part of the hermitian matrix and the strictly
17590
upper triangular part of A is not referenced. On exit, the
17591
lower triangular part of the array A is overwritten by the
17592
lower triangular part of the updated matrix.
17593
Note that the imaginary parts of the diagonal elements need
17594
not be set, they are assumed to be zero, and on exit they
17595
are set to zero.
17596
17597
LDA - INTEGER.
17598
On entry, LDA specifies the first dimension of A as declared
17599
in the calling (sub) program. LDA must be at least
17600
max( 1, n ).
17601
Unchanged on exit.
17602
17603
Further Details
17604
===============
17605
17606
Level 2 Blas routine.
17607
17608
-- Written on 22-October-1986.
17609
Jack Dongarra, Argonne National Lab.
17610
Jeremy Du Croz, Nag Central Office.
17611
Sven Hammarling, Nag Central Office.
17612
Richard Hanson, Sandia National Labs.
17613
17614
=====================================================================
17615
17616
17617
Test the input parameters.
17618
*/
17619
17620
/* Parameter adjustments */
17621
--x;
17622
--y;
17623
a_dim1 = *lda;
17624
a_offset = 1 + a_dim1;
17625
a -= a_offset;
17626
17627
/* Function Body */
17628
info = 0;
17629
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
17630
info = 1;
17631
} else if (*n < 0) {
17632
info = 2;
17633
} else if (*incx == 0) {
17634
info = 5;
17635
} else if (*incy == 0) {
17636
info = 7;
17637
} else if (*lda < max(1,*n)) {
17638
info = 9;
17639
}
17640
if (info != 0) {
17641
xerbla_("ZHER2 ", &info);
17642
return 0;
17643
}
17644
17645
/* Quick return if possible. */
17646
17647
if (*n == 0 || alpha->r == 0. && alpha->i == 0.) {
17648
return 0;
17649
}
17650
17651
/*
17652
Set up the start points in X and Y if the increments are not both
17653
unity.
17654
*/
17655
17656
if (*incx != 1 || *incy != 1) {
17657
if (*incx > 0) {
17658
kx = 1;
17659
} else {
17660
kx = 1 - (*n - 1) * *incx;
17661
}
17662
if (*incy > 0) {
17663
ky = 1;
17664
} else {
17665
ky = 1 - (*n - 1) * *incy;
17666
}
17667
jx = kx;
17668
jy = ky;
17669
}
17670
17671
/*
17672
Start the operations. In this version the elements of A are
17673
accessed sequentially with one pass through the triangular part
17674
of A.
17675
*/
17676
17677
if (lsame_(uplo, "U")) {
17678
17679
/* Form A when A is stored in the upper triangle. */
17680
17681
if (*incx == 1 && *incy == 1) {
17682
i__1 = *n;
17683
for (j = 1; j <= i__1; ++j) {
17684
i__2 = j;
17685
i__3 = j;
17686
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
17687
y[i__3].i != 0.)) {
17688
d_cnjg(&z__2, &y[j]);
17689
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
17690
alpha->r * z__2.i + alpha->i * z__2.r;
17691
temp1.r = z__1.r, temp1.i = z__1.i;
17692
i__2 = j;
17693
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
17694
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
17695
.r;
17696
d_cnjg(&z__1, &z__2);
17697
temp2.r = z__1.r, temp2.i = z__1.i;
17698
i__2 = j - 1;
17699
for (i__ = 1; i__ <= i__2; ++i__) {
17700
i__3 = i__ + j * a_dim1;
17701
i__4 = i__ + j * a_dim1;
17702
i__5 = i__;
17703
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
17704
z__3.i = x[i__5].r * temp1.i + x[i__5].i *
17705
temp1.r;
17706
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
17707
z__3.i;
17708
i__6 = i__;
17709
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
17710
z__4.i = y[i__6].r * temp2.i + y[i__6].i *
17711
temp2.r;
17712
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17713
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17714
/* L10: */
17715
}
17716
i__2 = j + j * a_dim1;
17717
i__3 = j + j * a_dim1;
17718
i__4 = j;
17719
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
17720
z__2.i = x[i__4].r * temp1.i + x[i__4].i *
17721
temp1.r;
17722
i__5 = j;
17723
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
17724
z__3.i = y[i__5].r * temp2.i + y[i__5].i *
17725
temp2.r;
17726
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
17727
d__1 = a[i__3].r + z__1.r;
17728
a[i__2].r = d__1, a[i__2].i = 0.;
17729
} else {
17730
i__2 = j + j * a_dim1;
17731
i__3 = j + j * a_dim1;
17732
d__1 = a[i__3].r;
17733
a[i__2].r = d__1, a[i__2].i = 0.;
17734
}
17735
/* L20: */
17736
}
17737
} else {
17738
i__1 = *n;
17739
for (j = 1; j <= i__1; ++j) {
17740
i__2 = jx;
17741
i__3 = jy;
17742
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
17743
y[i__3].i != 0.)) {
17744
d_cnjg(&z__2, &y[jy]);
17745
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
17746
alpha->r * z__2.i + alpha->i * z__2.r;
17747
temp1.r = z__1.r, temp1.i = z__1.i;
17748
i__2 = jx;
17749
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
17750
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
17751
.r;
17752
d_cnjg(&z__1, &z__2);
17753
temp2.r = z__1.r, temp2.i = z__1.i;
17754
ix = kx;
17755
iy = ky;
17756
i__2 = j - 1;
17757
for (i__ = 1; i__ <= i__2; ++i__) {
17758
i__3 = i__ + j * a_dim1;
17759
i__4 = i__ + j * a_dim1;
17760
i__5 = ix;
17761
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
17762
z__3.i = x[i__5].r * temp1.i + x[i__5].i *
17763
temp1.r;
17764
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
17765
z__3.i;
17766
i__6 = iy;
17767
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
17768
z__4.i = y[i__6].r * temp2.i + y[i__6].i *
17769
temp2.r;
17770
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17771
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17772
ix += *incx;
17773
iy += *incy;
17774
/* L30: */
17775
}
17776
i__2 = j + j * a_dim1;
17777
i__3 = j + j * a_dim1;
17778
i__4 = jx;
17779
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
17780
z__2.i = x[i__4].r * temp1.i + x[i__4].i *
17781
temp1.r;
17782
i__5 = jy;
17783
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
17784
z__3.i = y[i__5].r * temp2.i + y[i__5].i *
17785
temp2.r;
17786
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
17787
d__1 = a[i__3].r + z__1.r;
17788
a[i__2].r = d__1, a[i__2].i = 0.;
17789
} else {
17790
i__2 = j + j * a_dim1;
17791
i__3 = j + j * a_dim1;
17792
d__1 = a[i__3].r;
17793
a[i__2].r = d__1, a[i__2].i = 0.;
17794
}
17795
jx += *incx;
17796
jy += *incy;
17797
/* L40: */
17798
}
17799
}
17800
} else {
17801
17802
/* Form A when A is stored in the lower triangle. */
17803
17804
if (*incx == 1 && *incy == 1) {
17805
i__1 = *n;
17806
for (j = 1; j <= i__1; ++j) {
17807
i__2 = j;
17808
i__3 = j;
17809
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
17810
y[i__3].i != 0.)) {
17811
d_cnjg(&z__2, &y[j]);
17812
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
17813
alpha->r * z__2.i + alpha->i * z__2.r;
17814
temp1.r = z__1.r, temp1.i = z__1.i;
17815
i__2 = j;
17816
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
17817
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
17818
.r;
17819
d_cnjg(&z__1, &z__2);
17820
temp2.r = z__1.r, temp2.i = z__1.i;
17821
i__2 = j + j * a_dim1;
17822
i__3 = j + j * a_dim1;
17823
i__4 = j;
17824
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
17825
z__2.i = x[i__4].r * temp1.i + x[i__4].i *
17826
temp1.r;
17827
i__5 = j;
17828
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
17829
z__3.i = y[i__5].r * temp2.i + y[i__5].i *
17830
temp2.r;
17831
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
17832
d__1 = a[i__3].r + z__1.r;
17833
a[i__2].r = d__1, a[i__2].i = 0.;
17834
i__2 = *n;
17835
for (i__ = j + 1; i__ <= i__2; ++i__) {
17836
i__3 = i__ + j * a_dim1;
17837
i__4 = i__ + j * a_dim1;
17838
i__5 = i__;
17839
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
17840
z__3.i = x[i__5].r * temp1.i + x[i__5].i *
17841
temp1.r;
17842
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
17843
z__3.i;
17844
i__6 = i__;
17845
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
17846
z__4.i = y[i__6].r * temp2.i + y[i__6].i *
17847
temp2.r;
17848
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17849
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17850
/* L50: */
17851
}
17852
} else {
17853
i__2 = j + j * a_dim1;
17854
i__3 = j + j * a_dim1;
17855
d__1 = a[i__3].r;
17856
a[i__2].r = d__1, a[i__2].i = 0.;
17857
}
17858
/* L60: */
17859
}
17860
} else {
17861
i__1 = *n;
17862
for (j = 1; j <= i__1; ++j) {
17863
i__2 = jx;
17864
i__3 = jy;
17865
if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. ||
17866
y[i__3].i != 0.)) {
17867
d_cnjg(&z__2, &y[jy]);
17868
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
17869
alpha->r * z__2.i + alpha->i * z__2.r;
17870
temp1.r = z__1.r, temp1.i = z__1.i;
17871
i__2 = jx;
17872
z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
17873
z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
17874
.r;
17875
d_cnjg(&z__1, &z__2);
17876
temp2.r = z__1.r, temp2.i = z__1.i;
17877
i__2 = j + j * a_dim1;
17878
i__3 = j + j * a_dim1;
17879
i__4 = jx;
17880
z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i,
17881
z__2.i = x[i__4].r * temp1.i + x[i__4].i *
17882
temp1.r;
17883
i__5 = jy;
17884
z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i,
17885
z__3.i = y[i__5].r * temp2.i + y[i__5].i *
17886
temp2.r;
17887
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
17888
d__1 = a[i__3].r + z__1.r;
17889
a[i__2].r = d__1, a[i__2].i = 0.;
17890
ix = jx;
17891
iy = jy;
17892
i__2 = *n;
17893
for (i__ = j + 1; i__ <= i__2; ++i__) {
17894
ix += *incx;
17895
iy += *incy;
17896
i__3 = i__ + j * a_dim1;
17897
i__4 = i__ + j * a_dim1;
17898
i__5 = ix;
17899
z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i,
17900
z__3.i = x[i__5].r * temp1.i + x[i__5].i *
17901
temp1.r;
17902
z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i +
17903
z__3.i;
17904
i__6 = iy;
17905
z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i,
17906
z__4.i = y[i__6].r * temp2.i + y[i__6].i *
17907
temp2.r;
17908
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
17909
a[i__3].r = z__1.r, a[i__3].i = z__1.i;
17910
/* L70: */
17911
}
17912
} else {
17913
i__2 = j + j * a_dim1;
17914
i__3 = j + j * a_dim1;
17915
d__1 = a[i__3].r;
17916
a[i__2].r = d__1, a[i__2].i = 0.;
17917
}
17918
jx += *incx;
17919
jy += *incy;
17920
/* L80: */
17921
}
17922
}
17923
}
17924
17925
return 0;
17926
17927
/* End of ZHER2 . */
17928
17929
} /* zher2_ */
17930
17931
/* Subroutine */ int zher2k_(char *uplo, char *trans, integer *n, integer *k,
17932
doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *
17933
b, integer *ldb, doublereal *beta, doublecomplex *c__, integer *ldc)
17934
{
17935
/* System generated locals */
17936
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
17937
i__3, i__4, i__5, i__6, i__7;
17938
doublereal d__1;
17939
doublecomplex z__1, z__2, z__3, z__4, z__5, z__6;
17940
17941
/* Local variables */
17942
static integer i__, j, l, info;
17943
static doublecomplex temp1, temp2;
17944
extern logical lsame_(char *, char *);
17945
static integer nrowa;
17946
static logical upper;
17947
extern /* Subroutine */ int xerbla_(char *, integer *);
17948
17949
17950
/*
17951
Purpose
17952
=======
17953
17954
ZHER2K performs one of the hermitian rank 2k operations
17955
17956
C := alpha*A*conjg( B' ) + conjg( alpha )*B*conjg( A' ) + beta*C,
17957
17958
or
17959
17960
C := alpha*conjg( A' )*B + conjg( alpha )*conjg( B' )*A + beta*C,
17961
17962
where alpha and beta are scalars with beta real, C is an n by n
17963
hermitian matrix and A and B are n by k matrices in the first case
17964
and k by n matrices in the second case.
17965
17966
Arguments
17967
==========
17968
17969
UPLO - CHARACTER*1.
17970
On entry, UPLO specifies whether the upper or lower
17971
triangular part of the array C is to be referenced as
17972
follows:
17973
17974
UPLO = 'U' or 'u' Only the upper triangular part of C
17975
is to be referenced.
17976
17977
UPLO = 'L' or 'l' Only the lower triangular part of C
17978
is to be referenced.
17979
17980
Unchanged on exit.
17981
17982
TRANS - CHARACTER*1.
17983
On entry, TRANS specifies the operation to be performed as
17984
follows:
17985
17986
TRANS = 'N' or 'n' C := alpha*A*conjg( B' ) +
17987
conjg( alpha )*B*conjg( A' ) +
17988
beta*C.
17989
17990
TRANS = 'C' or 'c' C := alpha*conjg( A' )*B +
17991
conjg( alpha )*conjg( B' )*A +
17992
beta*C.
17993
17994
Unchanged on exit.
17995
17996
N - INTEGER.
17997
On entry, N specifies the order of the matrix C. N must be
17998
at least zero.
17999
Unchanged on exit.
18000
18001
K - INTEGER.
18002
On entry with TRANS = 'N' or 'n', K specifies the number
18003
of columns of the matrices A and B, and on entry with
18004
TRANS = 'C' or 'c', K specifies the number of rows of the
18005
matrices A and B. K must be at least zero.
18006
Unchanged on exit.
18007
18008
ALPHA - COMPLEX*16 .
18009
On entry, ALPHA specifies the scalar alpha.
18010
Unchanged on exit.
18011
18012
A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is
18013
k when TRANS = 'N' or 'n', and is n otherwise.
18014
Before entry with TRANS = 'N' or 'n', the leading n by k
18015
part of the array A must contain the matrix A, otherwise
18016
the leading k by n part of the array A must contain the
18017
matrix A.
18018
Unchanged on exit.
18019
18020
LDA - INTEGER.
18021
On entry, LDA specifies the first dimension of A as declared
18022
in the calling (sub) program. When TRANS = 'N' or 'n'
18023
then LDA must be at least max( 1, n ), otherwise LDA must
18024
be at least max( 1, k ).
18025
Unchanged on exit.
18026
18027
B - COMPLEX*16 array of DIMENSION ( LDB, kb ), where kb is
18028
k when TRANS = 'N' or 'n', and is n otherwise.
18029
Before entry with TRANS = 'N' or 'n', the leading n by k
18030
part of the array B must contain the matrix B, otherwise
18031
the leading k by n part of the array B must contain the
18032
matrix B.
18033
Unchanged on exit.
18034
18035
LDB - INTEGER.
18036
On entry, LDB specifies the first dimension of B as declared
18037
in the calling (sub) program. When TRANS = 'N' or 'n'
18038
then LDB must be at least max( 1, n ), otherwise LDB must
18039
be at least max( 1, k ).
18040
Unchanged on exit.
18041
18042
BETA - DOUBLE PRECISION .
18043
On entry, BETA specifies the scalar beta.
18044
Unchanged on exit.
18045
18046
C - COMPLEX*16 array of DIMENSION ( LDC, n ).
18047
Before entry with UPLO = 'U' or 'u', the leading n by n
18048
upper triangular part of the array C must contain the upper
18049
triangular part of the hermitian matrix and the strictly
18050
lower triangular part of C is not referenced. On exit, the
18051
upper triangular part of the array C is overwritten by the
18052
upper triangular part of the updated matrix.
18053
Before entry with UPLO = 'L' or 'l', the leading n by n
18054
lower triangular part of the array C must contain the lower
18055
triangular part of the hermitian matrix and the strictly
18056
upper triangular part of C is not referenced. On exit, the
18057
lower triangular part of the array C is overwritten by the
18058
lower triangular part of the updated matrix.
18059
Note that the imaginary parts of the diagonal elements need
18060
not be set, they are assumed to be zero, and on exit they
18061
are set to zero.
18062
18063
LDC - INTEGER.
18064
On entry, LDC specifies the first dimension of C as declared
18065
in the calling (sub) program. LDC must be at least
18066
max( 1, n ).
18067
Unchanged on exit.
18068
18069
Further Details
18070
===============
18071
18072
Level 3 Blas routine.
18073
18074
-- Written on 8-February-1989.
18075
Jack Dongarra, Argonne National Laboratory.
18076
Iain Duff, AERE Harwell.
18077
Jeremy Du Croz, Numerical Algorithms Group Ltd.
18078
Sven Hammarling, Numerical Algorithms Group Ltd.
18079
18080
-- Modified 8-Nov-93 to set C(J,J) to DBLE( C(J,J) ) when BETA = 1.
18081
Ed Anderson, Cray Research Inc.
18082
18083
=====================================================================
18084
18085
18086
Test the input parameters.
18087
*/
18088
18089
/* Parameter adjustments */
18090
a_dim1 = *lda;
18091
a_offset = 1 + a_dim1;
18092
a -= a_offset;
18093
b_dim1 = *ldb;
18094
b_offset = 1 + b_dim1;
18095
b -= b_offset;
18096
c_dim1 = *ldc;
18097
c_offset = 1 + c_dim1;
18098
c__ -= c_offset;
18099
18100
/* Function Body */
18101
if (lsame_(trans, "N")) {
18102
nrowa = *n;
18103
} else {
18104
nrowa = *k;
18105
}
18106
upper = lsame_(uplo, "U");
18107
18108
info = 0;
18109
if (! upper && ! lsame_(uplo, "L")) {
18110
info = 1;
18111
} else if (! lsame_(trans, "N") && ! lsame_(trans,
18112
"C")) {
18113
info = 2;
18114
} else if (*n < 0) {
18115
info = 3;
18116
} else if (*k < 0) {
18117
info = 4;
18118
} else if (*lda < max(1,nrowa)) {
18119
info = 7;
18120
} else if (*ldb < max(1,nrowa)) {
18121
info = 9;
18122
} else if (*ldc < max(1,*n)) {
18123
info = 12;
18124
}
18125
if (info != 0) {
18126
xerbla_("ZHER2K", &info);
18127
return 0;
18128
}
18129
18130
/* Quick return if possible. */
18131
18132
if (*n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) && *beta ==
18133
1.) {
18134
return 0;
18135
}
18136
18137
/* And when alpha.eq.zero. */
18138
18139
if (alpha->r == 0. && alpha->i == 0.) {
18140
if (upper) {
18141
if (*beta == 0.) {
18142
i__1 = *n;
18143
for (j = 1; j <= i__1; ++j) {
18144
i__2 = j;
18145
for (i__ = 1; i__ <= i__2; ++i__) {
18146
i__3 = i__ + j * c_dim1;
18147
c__[i__3].r = 0., c__[i__3].i = 0.;
18148
/* L10: */
18149
}
18150
/* L20: */
18151
}
18152
} else {
18153
i__1 = *n;
18154
for (j = 1; j <= i__1; ++j) {
18155
i__2 = j - 1;
18156
for (i__ = 1; i__ <= i__2; ++i__) {
18157
i__3 = i__ + j * c_dim1;
18158
i__4 = i__ + j * c_dim1;
18159
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18160
i__4].i;
18161
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18162
/* L30: */
18163
}
18164
i__2 = j + j * c_dim1;
18165
i__3 = j + j * c_dim1;
18166
d__1 = *beta * c__[i__3].r;
18167
c__[i__2].r = d__1, c__[i__2].i = 0.;
18168
/* L40: */
18169
}
18170
}
18171
} else {
18172
if (*beta == 0.) {
18173
i__1 = *n;
18174
for (j = 1; j <= i__1; ++j) {
18175
i__2 = *n;
18176
for (i__ = j; i__ <= i__2; ++i__) {
18177
i__3 = i__ + j * c_dim1;
18178
c__[i__3].r = 0., c__[i__3].i = 0.;
18179
/* L50: */
18180
}
18181
/* L60: */
18182
}
18183
} else {
18184
i__1 = *n;
18185
for (j = 1; j <= i__1; ++j) {
18186
i__2 = j + j * c_dim1;
18187
i__3 = j + j * c_dim1;
18188
d__1 = *beta * c__[i__3].r;
18189
c__[i__2].r = d__1, c__[i__2].i = 0.;
18190
i__2 = *n;
18191
for (i__ = j + 1; i__ <= i__2; ++i__) {
18192
i__3 = i__ + j * c_dim1;
18193
i__4 = i__ + j * c_dim1;
18194
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18195
i__4].i;
18196
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18197
/* L70: */
18198
}
18199
/* L80: */
18200
}
18201
}
18202
}
18203
return 0;
18204
}
18205
18206
/* Start the operations. */
18207
18208
if (lsame_(trans, "N")) {
18209
18210
/*
18211
Form C := alpha*A*conjg( B' ) + conjg( alpha )*B*conjg( A' ) +
18212
C.
18213
*/
18214
18215
if (upper) {
18216
i__1 = *n;
18217
for (j = 1; j <= i__1; ++j) {
18218
if (*beta == 0.) {
18219
i__2 = j;
18220
for (i__ = 1; i__ <= i__2; ++i__) {
18221
i__3 = i__ + j * c_dim1;
18222
c__[i__3].r = 0., c__[i__3].i = 0.;
18223
/* L90: */
18224
}
18225
} else if (*beta != 1.) {
18226
i__2 = j - 1;
18227
for (i__ = 1; i__ <= i__2; ++i__) {
18228
i__3 = i__ + j * c_dim1;
18229
i__4 = i__ + j * c_dim1;
18230
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18231
i__4].i;
18232
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18233
/* L100: */
18234
}
18235
i__2 = j + j * c_dim1;
18236
i__3 = j + j * c_dim1;
18237
d__1 = *beta * c__[i__3].r;
18238
c__[i__2].r = d__1, c__[i__2].i = 0.;
18239
} else {
18240
i__2 = j + j * c_dim1;
18241
i__3 = j + j * c_dim1;
18242
d__1 = c__[i__3].r;
18243
c__[i__2].r = d__1, c__[i__2].i = 0.;
18244
}
18245
i__2 = *k;
18246
for (l = 1; l <= i__2; ++l) {
18247
i__3 = j + l * a_dim1;
18248
i__4 = j + l * b_dim1;
18249
if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
18250
0. || b[i__4].i != 0.)) {
18251
d_cnjg(&z__2, &b[j + l * b_dim1]);
18252
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i,
18253
z__1.i = alpha->r * z__2.i + alpha->i *
18254
z__2.r;
18255
temp1.r = z__1.r, temp1.i = z__1.i;
18256
i__3 = j + l * a_dim1;
18257
z__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
18258
z__2.i = alpha->r * a[i__3].i + alpha->i * a[
18259
i__3].r;
18260
d_cnjg(&z__1, &z__2);
18261
temp2.r = z__1.r, temp2.i = z__1.i;
18262
i__3 = j - 1;
18263
for (i__ = 1; i__ <= i__3; ++i__) {
18264
i__4 = i__ + j * c_dim1;
18265
i__5 = i__ + j * c_dim1;
18266
i__6 = i__ + l * a_dim1;
18267
z__3.r = a[i__6].r * temp1.r - a[i__6].i *
18268
temp1.i, z__3.i = a[i__6].r * temp1.i + a[
18269
i__6].i * temp1.r;
18270
z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
18271
.i + z__3.i;
18272
i__7 = i__ + l * b_dim1;
18273
z__4.r = b[i__7].r * temp2.r - b[i__7].i *
18274
temp2.i, z__4.i = b[i__7].r * temp2.i + b[
18275
i__7].i * temp2.r;
18276
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
18277
z__4.i;
18278
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
18279
/* L110: */
18280
}
18281
i__3 = j + j * c_dim1;
18282
i__4 = j + j * c_dim1;
18283
i__5 = j + l * a_dim1;
18284
z__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
18285
z__2.i = a[i__5].r * temp1.i + a[i__5].i *
18286
temp1.r;
18287
i__6 = j + l * b_dim1;
18288
z__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
18289
z__3.i = b[i__6].r * temp2.i + b[i__6].i *
18290
temp2.r;
18291
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
18292
d__1 = c__[i__4].r + z__1.r;
18293
c__[i__3].r = d__1, c__[i__3].i = 0.;
18294
}
18295
/* L120: */
18296
}
18297
/* L130: */
18298
}
18299
} else {
18300
i__1 = *n;
18301
for (j = 1; j <= i__1; ++j) {
18302
if (*beta == 0.) {
18303
i__2 = *n;
18304
for (i__ = j; i__ <= i__2; ++i__) {
18305
i__3 = i__ + j * c_dim1;
18306
c__[i__3].r = 0., c__[i__3].i = 0.;
18307
/* L140: */
18308
}
18309
} else if (*beta != 1.) {
18310
i__2 = *n;
18311
for (i__ = j + 1; i__ <= i__2; ++i__) {
18312
i__3 = i__ + j * c_dim1;
18313
i__4 = i__ + j * c_dim1;
18314
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18315
i__4].i;
18316
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18317
/* L150: */
18318
}
18319
i__2 = j + j * c_dim1;
18320
i__3 = j + j * c_dim1;
18321
d__1 = *beta * c__[i__3].r;
18322
c__[i__2].r = d__1, c__[i__2].i = 0.;
18323
} else {
18324
i__2 = j + j * c_dim1;
18325
i__3 = j + j * c_dim1;
18326
d__1 = c__[i__3].r;
18327
c__[i__2].r = d__1, c__[i__2].i = 0.;
18328
}
18329
i__2 = *k;
18330
for (l = 1; l <= i__2; ++l) {
18331
i__3 = j + l * a_dim1;
18332
i__4 = j + l * b_dim1;
18333
if (a[i__3].r != 0. || a[i__3].i != 0. || (b[i__4].r !=
18334
0. || b[i__4].i != 0.)) {
18335
d_cnjg(&z__2, &b[j + l * b_dim1]);
18336
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i,
18337
z__1.i = alpha->r * z__2.i + alpha->i *
18338
z__2.r;
18339
temp1.r = z__1.r, temp1.i = z__1.i;
18340
i__3 = j + l * a_dim1;
18341
z__2.r = alpha->r * a[i__3].r - alpha->i * a[i__3].i,
18342
z__2.i = alpha->r * a[i__3].i + alpha->i * a[
18343
i__3].r;
18344
d_cnjg(&z__1, &z__2);
18345
temp2.r = z__1.r, temp2.i = z__1.i;
18346
i__3 = *n;
18347
for (i__ = j + 1; i__ <= i__3; ++i__) {
18348
i__4 = i__ + j * c_dim1;
18349
i__5 = i__ + j * c_dim1;
18350
i__6 = i__ + l * a_dim1;
18351
z__3.r = a[i__6].r * temp1.r - a[i__6].i *
18352
temp1.i, z__3.i = a[i__6].r * temp1.i + a[
18353
i__6].i * temp1.r;
18354
z__2.r = c__[i__5].r + z__3.r, z__2.i = c__[i__5]
18355
.i + z__3.i;
18356
i__7 = i__ + l * b_dim1;
18357
z__4.r = b[i__7].r * temp2.r - b[i__7].i *
18358
temp2.i, z__4.i = b[i__7].r * temp2.i + b[
18359
i__7].i * temp2.r;
18360
z__1.r = z__2.r + z__4.r, z__1.i = z__2.i +
18361
z__4.i;
18362
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
18363
/* L160: */
18364
}
18365
i__3 = j + j * c_dim1;
18366
i__4 = j + j * c_dim1;
18367
i__5 = j + l * a_dim1;
18368
z__2.r = a[i__5].r * temp1.r - a[i__5].i * temp1.i,
18369
z__2.i = a[i__5].r * temp1.i + a[i__5].i *
18370
temp1.r;
18371
i__6 = j + l * b_dim1;
18372
z__3.r = b[i__6].r * temp2.r - b[i__6].i * temp2.i,
18373
z__3.i = b[i__6].r * temp2.i + b[i__6].i *
18374
temp2.r;
18375
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
18376
d__1 = c__[i__4].r + z__1.r;
18377
c__[i__3].r = d__1, c__[i__3].i = 0.;
18378
}
18379
/* L170: */
18380
}
18381
/* L180: */
18382
}
18383
}
18384
} else {
18385
18386
/*
18387
Form C := alpha*conjg( A' )*B + conjg( alpha )*conjg( B' )*A +
18388
C.
18389
*/
18390
18391
if (upper) {
18392
i__1 = *n;
18393
for (j = 1; j <= i__1; ++j) {
18394
i__2 = j;
18395
for (i__ = 1; i__ <= i__2; ++i__) {
18396
temp1.r = 0., temp1.i = 0.;
18397
temp2.r = 0., temp2.i = 0.;
18398
i__3 = *k;
18399
for (l = 1; l <= i__3; ++l) {
18400
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
18401
i__4 = l + j * b_dim1;
18402
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
18403
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
18404
.r;
18405
z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
18406
temp1.r = z__1.r, temp1.i = z__1.i;
18407
d_cnjg(&z__3, &b[l + i__ * b_dim1]);
18408
i__4 = l + j * a_dim1;
18409
z__2.r = z__3.r * a[i__4].r - z__3.i * a[i__4].i,
18410
z__2.i = z__3.r * a[i__4].i + z__3.i * a[i__4]
18411
.r;
18412
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
18413
temp2.r = z__1.r, temp2.i = z__1.i;
18414
/* L190: */
18415
}
18416
if (i__ == j) {
18417
if (*beta == 0.) {
18418
i__3 = j + j * c_dim1;
18419
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18420
z__2.i = alpha->r * temp1.i + alpha->i *
18421
temp1.r;
18422
d_cnjg(&z__4, alpha);
18423
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18424
z__3.i = z__4.r * temp2.i + z__4.i *
18425
temp2.r;
18426
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18427
z__3.i;
18428
d__1 = z__1.r;
18429
c__[i__3].r = d__1, c__[i__3].i = 0.;
18430
} else {
18431
i__3 = j + j * c_dim1;
18432
i__4 = j + j * c_dim1;
18433
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18434
z__2.i = alpha->r * temp1.i + alpha->i *
18435
temp1.r;
18436
d_cnjg(&z__4, alpha);
18437
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18438
z__3.i = z__4.r * temp2.i + z__4.i *
18439
temp2.r;
18440
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18441
z__3.i;
18442
d__1 = *beta * c__[i__4].r + z__1.r;
18443
c__[i__3].r = d__1, c__[i__3].i = 0.;
18444
}
18445
} else {
18446
if (*beta == 0.) {
18447
i__3 = i__ + j * c_dim1;
18448
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18449
z__2.i = alpha->r * temp1.i + alpha->i *
18450
temp1.r;
18451
d_cnjg(&z__4, alpha);
18452
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18453
z__3.i = z__4.r * temp2.i + z__4.i *
18454
temp2.r;
18455
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18456
z__3.i;
18457
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18458
} else {
18459
i__3 = i__ + j * c_dim1;
18460
i__4 = i__ + j * c_dim1;
18461
z__3.r = *beta * c__[i__4].r, z__3.i = *beta *
18462
c__[i__4].i;
18463
z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
18464
z__4.i = alpha->r * temp1.i + alpha->i *
18465
temp1.r;
18466
z__2.r = z__3.r + z__4.r, z__2.i = z__3.i +
18467
z__4.i;
18468
d_cnjg(&z__6, alpha);
18469
z__5.r = z__6.r * temp2.r - z__6.i * temp2.i,
18470
z__5.i = z__6.r * temp2.i + z__6.i *
18471
temp2.r;
18472
z__1.r = z__2.r + z__5.r, z__1.i = z__2.i +
18473
z__5.i;
18474
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18475
}
18476
}
18477
/* L200: */
18478
}
18479
/* L210: */
18480
}
18481
} else {
18482
i__1 = *n;
18483
for (j = 1; j <= i__1; ++j) {
18484
i__2 = *n;
18485
for (i__ = j; i__ <= i__2; ++i__) {
18486
temp1.r = 0., temp1.i = 0.;
18487
temp2.r = 0., temp2.i = 0.;
18488
i__3 = *k;
18489
for (l = 1; l <= i__3; ++l) {
18490
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
18491
i__4 = l + j * b_dim1;
18492
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
18493
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
18494
.r;
18495
z__1.r = temp1.r + z__2.r, z__1.i = temp1.i + z__2.i;
18496
temp1.r = z__1.r, temp1.i = z__1.i;
18497
d_cnjg(&z__3, &b[l + i__ * b_dim1]);
18498
i__4 = l + j * a_dim1;
18499
z__2.r = z__3.r * a[i__4].r - z__3.i * a[i__4].i,
18500
z__2.i = z__3.r * a[i__4].i + z__3.i * a[i__4]
18501
.r;
18502
z__1.r = temp2.r + z__2.r, z__1.i = temp2.i + z__2.i;
18503
temp2.r = z__1.r, temp2.i = z__1.i;
18504
/* L220: */
18505
}
18506
if (i__ == j) {
18507
if (*beta == 0.) {
18508
i__3 = j + j * c_dim1;
18509
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18510
z__2.i = alpha->r * temp1.i + alpha->i *
18511
temp1.r;
18512
d_cnjg(&z__4, alpha);
18513
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18514
z__3.i = z__4.r * temp2.i + z__4.i *
18515
temp2.r;
18516
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18517
z__3.i;
18518
d__1 = z__1.r;
18519
c__[i__3].r = d__1, c__[i__3].i = 0.;
18520
} else {
18521
i__3 = j + j * c_dim1;
18522
i__4 = j + j * c_dim1;
18523
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18524
z__2.i = alpha->r * temp1.i + alpha->i *
18525
temp1.r;
18526
d_cnjg(&z__4, alpha);
18527
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18528
z__3.i = z__4.r * temp2.i + z__4.i *
18529
temp2.r;
18530
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18531
z__3.i;
18532
d__1 = *beta * c__[i__4].r + z__1.r;
18533
c__[i__3].r = d__1, c__[i__3].i = 0.;
18534
}
18535
} else {
18536
if (*beta == 0.) {
18537
i__3 = i__ + j * c_dim1;
18538
z__2.r = alpha->r * temp1.r - alpha->i * temp1.i,
18539
z__2.i = alpha->r * temp1.i + alpha->i *
18540
temp1.r;
18541
d_cnjg(&z__4, alpha);
18542
z__3.r = z__4.r * temp2.r - z__4.i * temp2.i,
18543
z__3.i = z__4.r * temp2.i + z__4.i *
18544
temp2.r;
18545
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i +
18546
z__3.i;
18547
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18548
} else {
18549
i__3 = i__ + j * c_dim1;
18550
i__4 = i__ + j * c_dim1;
18551
z__3.r = *beta * c__[i__4].r, z__3.i = *beta *
18552
c__[i__4].i;
18553
z__4.r = alpha->r * temp1.r - alpha->i * temp1.i,
18554
z__4.i = alpha->r * temp1.i + alpha->i *
18555
temp1.r;
18556
z__2.r = z__3.r + z__4.r, z__2.i = z__3.i +
18557
z__4.i;
18558
d_cnjg(&z__6, alpha);
18559
z__5.r = z__6.r * temp2.r - z__6.i * temp2.i,
18560
z__5.i = z__6.r * temp2.i + z__6.i *
18561
temp2.r;
18562
z__1.r = z__2.r + z__5.r, z__1.i = z__2.i +
18563
z__5.i;
18564
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18565
}
18566
}
18567
/* L230: */
18568
}
18569
/* L240: */
18570
}
18571
}
18572
}
18573
18574
return 0;
18575
18576
/* End of ZHER2K. */
18577
18578
} /* zher2k_ */
18579
18580
/* Subroutine */ int zherk_(char *uplo, char *trans, integer *n, integer *k,
18581
doublereal *alpha, doublecomplex *a, integer *lda, doublereal *beta,
18582
doublecomplex *c__, integer *ldc)
18583
{
18584
/* System generated locals */
18585
integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3, i__4, i__5,
18586
i__6;
18587
doublereal d__1;
18588
doublecomplex z__1, z__2, z__3;
18589
18590
/* Local variables */
18591
static integer i__, j, l, info;
18592
static doublecomplex temp;
18593
extern logical lsame_(char *, char *);
18594
static integer nrowa;
18595
static doublereal rtemp;
18596
static logical upper;
18597
extern /* Subroutine */ int xerbla_(char *, integer *);
18598
18599
18600
/*
18601
Purpose
18602
=======
18603
18604
ZHERK performs one of the hermitian rank k operations
18605
18606
C := alpha*A*conjg( A' ) + beta*C,
18607
18608
or
18609
18610
C := alpha*conjg( A' )*A + beta*C,
18611
18612
where alpha and beta are real scalars, C is an n by n hermitian
18613
matrix and A is an n by k matrix in the first case and a k by n
18614
matrix in the second case.
18615
18616
Arguments
18617
==========
18618
18619
UPLO - CHARACTER*1.
18620
On entry, UPLO specifies whether the upper or lower
18621
triangular part of the array C is to be referenced as
18622
follows:
18623
18624
UPLO = 'U' or 'u' Only the upper triangular part of C
18625
is to be referenced.
18626
18627
UPLO = 'L' or 'l' Only the lower triangular part of C
18628
is to be referenced.
18629
18630
Unchanged on exit.
18631
18632
TRANS - CHARACTER*1.
18633
On entry, TRANS specifies the operation to be performed as
18634
follows:
18635
18636
TRANS = 'N' or 'n' C := alpha*A*conjg( A' ) + beta*C.
18637
18638
TRANS = 'C' or 'c' C := alpha*conjg( A' )*A + beta*C.
18639
18640
Unchanged on exit.
18641
18642
N - INTEGER.
18643
On entry, N specifies the order of the matrix C. N must be
18644
at least zero.
18645
Unchanged on exit.
18646
18647
K - INTEGER.
18648
On entry with TRANS = 'N' or 'n', K specifies the number
18649
of columns of the matrix A, and on entry with
18650
TRANS = 'C' or 'c', K specifies the number of rows of the
18651
matrix A. K must be at least zero.
18652
Unchanged on exit.
18653
18654
ALPHA - DOUBLE PRECISION .
18655
On entry, ALPHA specifies the scalar alpha.
18656
Unchanged on exit.
18657
18658
A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is
18659
k when TRANS = 'N' or 'n', and is n otherwise.
18660
Before entry with TRANS = 'N' or 'n', the leading n by k
18661
part of the array A must contain the matrix A, otherwise
18662
the leading k by n part of the array A must contain the
18663
matrix A.
18664
Unchanged on exit.
18665
18666
LDA - INTEGER.
18667
On entry, LDA specifies the first dimension of A as declared
18668
in the calling (sub) program. When TRANS = 'N' or 'n'
18669
then LDA must be at least max( 1, n ), otherwise LDA must
18670
be at least max( 1, k ).
18671
Unchanged on exit.
18672
18673
BETA - DOUBLE PRECISION.
18674
On entry, BETA specifies the scalar beta.
18675
Unchanged on exit.
18676
18677
C - COMPLEX*16 array of DIMENSION ( LDC, n ).
18678
Before entry with UPLO = 'U' or 'u', the leading n by n
18679
upper triangular part of the array C must contain the upper
18680
triangular part of the hermitian matrix and the strictly
18681
lower triangular part of C is not referenced. On exit, the
18682
upper triangular part of the array C is overwritten by the
18683
upper triangular part of the updated matrix.
18684
Before entry with UPLO = 'L' or 'l', the leading n by n
18685
lower triangular part of the array C must contain the lower
18686
triangular part of the hermitian matrix and the strictly
18687
upper triangular part of C is not referenced. On exit, the
18688
lower triangular part of the array C is overwritten by the
18689
lower triangular part of the updated matrix.
18690
Note that the imaginary parts of the diagonal elements need
18691
not be set, they are assumed to be zero, and on exit they
18692
are set to zero.
18693
18694
LDC - INTEGER.
18695
On entry, LDC specifies the first dimension of C as declared
18696
in the calling (sub) program. LDC must be at least
18697
max( 1, n ).
18698
Unchanged on exit.
18699
18700
Further Details
18701
===============
18702
18703
Level 3 Blas routine.
18704
18705
-- Written on 8-February-1989.
18706
Jack Dongarra, Argonne National Laboratory.
18707
Iain Duff, AERE Harwell.
18708
Jeremy Du Croz, Numerical Algorithms Group Ltd.
18709
Sven Hammarling, Numerical Algorithms Group Ltd.
18710
18711
-- Modified 8-Nov-93 to set C(J,J) to DBLE( C(J,J) ) when BETA = 1.
18712
Ed Anderson, Cray Research Inc.
18713
18714
=====================================================================
18715
18716
18717
Test the input parameters.
18718
*/
18719
18720
/* Parameter adjustments */
18721
a_dim1 = *lda;
18722
a_offset = 1 + a_dim1;
18723
a -= a_offset;
18724
c_dim1 = *ldc;
18725
c_offset = 1 + c_dim1;
18726
c__ -= c_offset;
18727
18728
/* Function Body */
18729
if (lsame_(trans, "N")) {
18730
nrowa = *n;
18731
} else {
18732
nrowa = *k;
18733
}
18734
upper = lsame_(uplo, "U");
18735
18736
info = 0;
18737
if (! upper && ! lsame_(uplo, "L")) {
18738
info = 1;
18739
} else if (! lsame_(trans, "N") && ! lsame_(trans,
18740
"C")) {
18741
info = 2;
18742
} else if (*n < 0) {
18743
info = 3;
18744
} else if (*k < 0) {
18745
info = 4;
18746
} else if (*lda < max(1,nrowa)) {
18747
info = 7;
18748
} else if (*ldc < max(1,*n)) {
18749
info = 10;
18750
}
18751
if (info != 0) {
18752
xerbla_("ZHERK ", &info);
18753
return 0;
18754
}
18755
18756
/* Quick return if possible. */
18757
18758
if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
18759
return 0;
18760
}
18761
18762
/* And when alpha.eq.zero. */
18763
18764
if (*alpha == 0.) {
18765
if (upper) {
18766
if (*beta == 0.) {
18767
i__1 = *n;
18768
for (j = 1; j <= i__1; ++j) {
18769
i__2 = j;
18770
for (i__ = 1; i__ <= i__2; ++i__) {
18771
i__3 = i__ + j * c_dim1;
18772
c__[i__3].r = 0., c__[i__3].i = 0.;
18773
/* L10: */
18774
}
18775
/* L20: */
18776
}
18777
} else {
18778
i__1 = *n;
18779
for (j = 1; j <= i__1; ++j) {
18780
i__2 = j - 1;
18781
for (i__ = 1; i__ <= i__2; ++i__) {
18782
i__3 = i__ + j * c_dim1;
18783
i__4 = i__ + j * c_dim1;
18784
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18785
i__4].i;
18786
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18787
/* L30: */
18788
}
18789
i__2 = j + j * c_dim1;
18790
i__3 = j + j * c_dim1;
18791
d__1 = *beta * c__[i__3].r;
18792
c__[i__2].r = d__1, c__[i__2].i = 0.;
18793
/* L40: */
18794
}
18795
}
18796
} else {
18797
if (*beta == 0.) {
18798
i__1 = *n;
18799
for (j = 1; j <= i__1; ++j) {
18800
i__2 = *n;
18801
for (i__ = j; i__ <= i__2; ++i__) {
18802
i__3 = i__ + j * c_dim1;
18803
c__[i__3].r = 0., c__[i__3].i = 0.;
18804
/* L50: */
18805
}
18806
/* L60: */
18807
}
18808
} else {
18809
i__1 = *n;
18810
for (j = 1; j <= i__1; ++j) {
18811
i__2 = j + j * c_dim1;
18812
i__3 = j + j * c_dim1;
18813
d__1 = *beta * c__[i__3].r;
18814
c__[i__2].r = d__1, c__[i__2].i = 0.;
18815
i__2 = *n;
18816
for (i__ = j + 1; i__ <= i__2; ++i__) {
18817
i__3 = i__ + j * c_dim1;
18818
i__4 = i__ + j * c_dim1;
18819
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18820
i__4].i;
18821
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18822
/* L70: */
18823
}
18824
/* L80: */
18825
}
18826
}
18827
}
18828
return 0;
18829
}
18830
18831
/* Start the operations. */
18832
18833
if (lsame_(trans, "N")) {
18834
18835
/* Form C := alpha*A*conjg( A' ) + beta*C. */
18836
18837
if (upper) {
18838
i__1 = *n;
18839
for (j = 1; j <= i__1; ++j) {
18840
if (*beta == 0.) {
18841
i__2 = j;
18842
for (i__ = 1; i__ <= i__2; ++i__) {
18843
i__3 = i__ + j * c_dim1;
18844
c__[i__3].r = 0., c__[i__3].i = 0.;
18845
/* L90: */
18846
}
18847
} else if (*beta != 1.) {
18848
i__2 = j - 1;
18849
for (i__ = 1; i__ <= i__2; ++i__) {
18850
i__3 = i__ + j * c_dim1;
18851
i__4 = i__ + j * c_dim1;
18852
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18853
i__4].i;
18854
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18855
/* L100: */
18856
}
18857
i__2 = j + j * c_dim1;
18858
i__3 = j + j * c_dim1;
18859
d__1 = *beta * c__[i__3].r;
18860
c__[i__2].r = d__1, c__[i__2].i = 0.;
18861
} else {
18862
i__2 = j + j * c_dim1;
18863
i__3 = j + j * c_dim1;
18864
d__1 = c__[i__3].r;
18865
c__[i__2].r = d__1, c__[i__2].i = 0.;
18866
}
18867
i__2 = *k;
18868
for (l = 1; l <= i__2; ++l) {
18869
i__3 = j + l * a_dim1;
18870
if (a[i__3].r != 0. || a[i__3].i != 0.) {
18871
d_cnjg(&z__2, &a[j + l * a_dim1]);
18872
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
18873
temp.r = z__1.r, temp.i = z__1.i;
18874
i__3 = j - 1;
18875
for (i__ = 1; i__ <= i__3; ++i__) {
18876
i__4 = i__ + j * c_dim1;
18877
i__5 = i__ + j * c_dim1;
18878
i__6 = i__ + l * a_dim1;
18879
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
18880
z__2.i = temp.r * a[i__6].i + temp.i * a[
18881
i__6].r;
18882
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
18883
.i + z__2.i;
18884
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
18885
/* L110: */
18886
}
18887
i__3 = j + j * c_dim1;
18888
i__4 = j + j * c_dim1;
18889
i__5 = i__ + l * a_dim1;
18890
z__1.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
18891
z__1.i = temp.r * a[i__5].i + temp.i * a[i__5]
18892
.r;
18893
d__1 = c__[i__4].r + z__1.r;
18894
c__[i__3].r = d__1, c__[i__3].i = 0.;
18895
}
18896
/* L120: */
18897
}
18898
/* L130: */
18899
}
18900
} else {
18901
i__1 = *n;
18902
for (j = 1; j <= i__1; ++j) {
18903
if (*beta == 0.) {
18904
i__2 = *n;
18905
for (i__ = j; i__ <= i__2; ++i__) {
18906
i__3 = i__ + j * c_dim1;
18907
c__[i__3].r = 0., c__[i__3].i = 0.;
18908
/* L140: */
18909
}
18910
} else if (*beta != 1.) {
18911
i__2 = j + j * c_dim1;
18912
i__3 = j + j * c_dim1;
18913
d__1 = *beta * c__[i__3].r;
18914
c__[i__2].r = d__1, c__[i__2].i = 0.;
18915
i__2 = *n;
18916
for (i__ = j + 1; i__ <= i__2; ++i__) {
18917
i__3 = i__ + j * c_dim1;
18918
i__4 = i__ + j * c_dim1;
18919
z__1.r = *beta * c__[i__4].r, z__1.i = *beta * c__[
18920
i__4].i;
18921
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18922
/* L150: */
18923
}
18924
} else {
18925
i__2 = j + j * c_dim1;
18926
i__3 = j + j * c_dim1;
18927
d__1 = c__[i__3].r;
18928
c__[i__2].r = d__1, c__[i__2].i = 0.;
18929
}
18930
i__2 = *k;
18931
for (l = 1; l <= i__2; ++l) {
18932
i__3 = j + l * a_dim1;
18933
if (a[i__3].r != 0. || a[i__3].i != 0.) {
18934
d_cnjg(&z__2, &a[j + l * a_dim1]);
18935
z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
18936
temp.r = z__1.r, temp.i = z__1.i;
18937
i__3 = j + j * c_dim1;
18938
i__4 = j + j * c_dim1;
18939
i__5 = j + l * a_dim1;
18940
z__1.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
18941
z__1.i = temp.r * a[i__5].i + temp.i * a[i__5]
18942
.r;
18943
d__1 = c__[i__4].r + z__1.r;
18944
c__[i__3].r = d__1, c__[i__3].i = 0.;
18945
i__3 = *n;
18946
for (i__ = j + 1; i__ <= i__3; ++i__) {
18947
i__4 = i__ + j * c_dim1;
18948
i__5 = i__ + j * c_dim1;
18949
i__6 = i__ + l * a_dim1;
18950
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
18951
z__2.i = temp.r * a[i__6].i + temp.i * a[
18952
i__6].r;
18953
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5]
18954
.i + z__2.i;
18955
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
18956
/* L160: */
18957
}
18958
}
18959
/* L170: */
18960
}
18961
/* L180: */
18962
}
18963
}
18964
} else {
18965
18966
/* Form C := alpha*conjg( A' )*A + beta*C. */
18967
18968
if (upper) {
18969
i__1 = *n;
18970
for (j = 1; j <= i__1; ++j) {
18971
i__2 = j - 1;
18972
for (i__ = 1; i__ <= i__2; ++i__) {
18973
temp.r = 0., temp.i = 0.;
18974
i__3 = *k;
18975
for (l = 1; l <= i__3; ++l) {
18976
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
18977
i__4 = l + j * a_dim1;
18978
z__2.r = z__3.r * a[i__4].r - z__3.i * a[i__4].i,
18979
z__2.i = z__3.r * a[i__4].i + z__3.i * a[i__4]
18980
.r;
18981
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
18982
temp.r = z__1.r, temp.i = z__1.i;
18983
/* L190: */
18984
}
18985
if (*beta == 0.) {
18986
i__3 = i__ + j * c_dim1;
18987
z__1.r = *alpha * temp.r, z__1.i = *alpha * temp.i;
18988
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18989
} else {
18990
i__3 = i__ + j * c_dim1;
18991
z__2.r = *alpha * temp.r, z__2.i = *alpha * temp.i;
18992
i__4 = i__ + j * c_dim1;
18993
z__3.r = *beta * c__[i__4].r, z__3.i = *beta * c__[
18994
i__4].i;
18995
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
18996
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
18997
}
18998
/* L200: */
18999
}
19000
rtemp = 0.;
19001
i__2 = *k;
19002
for (l = 1; l <= i__2; ++l) {
19003
d_cnjg(&z__3, &a[l + j * a_dim1]);
19004
i__3 = l + j * a_dim1;
19005
z__2.r = z__3.r * a[i__3].r - z__3.i * a[i__3].i, z__2.i =
19006
z__3.r * a[i__3].i + z__3.i * a[i__3].r;
19007
z__1.r = rtemp + z__2.r, z__1.i = z__2.i;
19008
rtemp = z__1.r;
19009
/* L210: */
19010
}
19011
if (*beta == 0.) {
19012
i__2 = j + j * c_dim1;
19013
d__1 = *alpha * rtemp;
19014
c__[i__2].r = d__1, c__[i__2].i = 0.;
19015
} else {
19016
i__2 = j + j * c_dim1;
19017
i__3 = j + j * c_dim1;
19018
d__1 = *alpha * rtemp + *beta * c__[i__3].r;
19019
c__[i__2].r = d__1, c__[i__2].i = 0.;
19020
}
19021
/* L220: */
19022
}
19023
} else {
19024
i__1 = *n;
19025
for (j = 1; j <= i__1; ++j) {
19026
rtemp = 0.;
19027
i__2 = *k;
19028
for (l = 1; l <= i__2; ++l) {
19029
d_cnjg(&z__3, &a[l + j * a_dim1]);
19030
i__3 = l + j * a_dim1;
19031
z__2.r = z__3.r * a[i__3].r - z__3.i * a[i__3].i, z__2.i =
19032
z__3.r * a[i__3].i + z__3.i * a[i__3].r;
19033
z__1.r = rtemp + z__2.r, z__1.i = z__2.i;
19034
rtemp = z__1.r;
19035
/* L230: */
19036
}
19037
if (*beta == 0.) {
19038
i__2 = j + j * c_dim1;
19039
d__1 = *alpha * rtemp;
19040
c__[i__2].r = d__1, c__[i__2].i = 0.;
19041
} else {
19042
i__2 = j + j * c_dim1;
19043
i__3 = j + j * c_dim1;
19044
d__1 = *alpha * rtemp + *beta * c__[i__3].r;
19045
c__[i__2].r = d__1, c__[i__2].i = 0.;
19046
}
19047
i__2 = *n;
19048
for (i__ = j + 1; i__ <= i__2; ++i__) {
19049
temp.r = 0., temp.i = 0.;
19050
i__3 = *k;
19051
for (l = 1; l <= i__3; ++l) {
19052
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
19053
i__4 = l + j * a_dim1;
19054
z__2.r = z__3.r * a[i__4].r - z__3.i * a[i__4].i,
19055
z__2.i = z__3.r * a[i__4].i + z__3.i * a[i__4]
19056
.r;
19057
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
19058
temp.r = z__1.r, temp.i = z__1.i;
19059
/* L240: */
19060
}
19061
if (*beta == 0.) {
19062
i__3 = i__ + j * c_dim1;
19063
z__1.r = *alpha * temp.r, z__1.i = *alpha * temp.i;
19064
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
19065
} else {
19066
i__3 = i__ + j * c_dim1;
19067
z__2.r = *alpha * temp.r, z__2.i = *alpha * temp.i;
19068
i__4 = i__ + j * c_dim1;
19069
z__3.r = *beta * c__[i__4].r, z__3.i = *beta * c__[
19070
i__4].i;
19071
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
19072
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
19073
}
19074
/* L250: */
19075
}
19076
/* L260: */
19077
}
19078
}
19079
}
19080
19081
return 0;
19082
19083
/* End of ZHERK . */
19084
19085
} /* zherk_ */
19086
19087
/* Subroutine */ int zscal_(integer *n, doublecomplex *za, doublecomplex *zx,
19088
integer *incx)
19089
{
19090
/* System generated locals */
19091
integer i__1, i__2, i__3;
19092
doublecomplex z__1;
19093
19094
/* Local variables */
19095
static integer i__, ix;
19096
19097
19098
/*
19099
Purpose
19100
=======
19101
19102
ZSCAL scales a vector by a constant.
19103
19104
Further Details
19105
===============
19106
19107
jack dongarra, 3/11/78.
19108
modified 3/93 to return if incx .le. 0.
19109
modified 12/3/93, array(1) declarations changed to array(*)
19110
19111
=====================================================================
19112
*/
19113
19114
/* Parameter adjustments */
19115
--zx;
19116
19117
/* Function Body */
19118
if (*n <= 0 || *incx <= 0) {
19119
return 0;
19120
}
19121
if (*incx == 1) {
19122
goto L20;
19123
}
19124
19125
/* code for increment not equal to 1 */
19126
19127
ix = 1;
19128
i__1 = *n;
19129
for (i__ = 1; i__ <= i__1; ++i__) {
19130
i__2 = ix;
19131
i__3 = ix;
19132
z__1.r = za->r * zx[i__3].r - za->i * zx[i__3].i, z__1.i = za->r * zx[
19133
i__3].i + za->i * zx[i__3].r;
19134
zx[i__2].r = z__1.r, zx[i__2].i = z__1.i;
19135
ix += *incx;
19136
/* L10: */
19137
}
19138
return 0;
19139
19140
/* code for increment equal to 1 */
19141
19142
L20:
19143
i__1 = *n;
19144
for (i__ = 1; i__ <= i__1; ++i__) {
19145
i__2 = i__;
19146
i__3 = i__;
19147
z__1.r = za->r * zx[i__3].r - za->i * zx[i__3].i, z__1.i = za->r * zx[
19148
i__3].i + za->i * zx[i__3].r;
19149
zx[i__2].r = z__1.r, zx[i__2].i = z__1.i;
19150
/* L30: */
19151
}
19152
return 0;
19153
} /* zscal_ */
19154
19155
/* Subroutine */ int zswap_(integer *n, doublecomplex *zx, integer *incx,
19156
doublecomplex *zy, integer *incy)
19157
{
19158
/* System generated locals */
19159
integer i__1, i__2, i__3;
19160
19161
/* Local variables */
19162
static integer i__, ix, iy;
19163
static doublecomplex ztemp;
19164
19165
19166
/*
19167
Purpose
19168
=======
19169
19170
ZSWAP interchanges two vectors.
19171
19172
Further Details
19173
===============
19174
19175
jack dongarra, 3/11/78.
19176
modified 12/3/93, array(1) declarations changed to array(*)
19177
19178
=====================================================================
19179
*/
19180
19181
/* Parameter adjustments */
19182
--zy;
19183
--zx;
19184
19185
/* Function Body */
19186
if (*n <= 0) {
19187
return 0;
19188
}
19189
if (*incx == 1 && *incy == 1) {
19190
goto L20;
19191
}
19192
19193
/*
19194
code for unequal increments or equal increments not equal
19195
to 1
19196
*/
19197
19198
ix = 1;
19199
iy = 1;
19200
if (*incx < 0) {
19201
ix = (-(*n) + 1) * *incx + 1;
19202
}
19203
if (*incy < 0) {
19204
iy = (-(*n) + 1) * *incy + 1;
19205
}
19206
i__1 = *n;
19207
for (i__ = 1; i__ <= i__1; ++i__) {
19208
i__2 = ix;
19209
ztemp.r = zx[i__2].r, ztemp.i = zx[i__2].i;
19210
i__2 = ix;
19211
i__3 = iy;
19212
zx[i__2].r = zy[i__3].r, zx[i__2].i = zy[i__3].i;
19213
i__2 = iy;
19214
zy[i__2].r = ztemp.r, zy[i__2].i = ztemp.i;
19215
ix += *incx;
19216
iy += *incy;
19217
/* L10: */
19218
}
19219
return 0;
19220
19221
/* code for both increments equal to 1 */
19222
L20:
19223
i__1 = *n;
19224
for (i__ = 1; i__ <= i__1; ++i__) {
19225
i__2 = i__;
19226
ztemp.r = zx[i__2].r, ztemp.i = zx[i__2].i;
19227
i__2 = i__;
19228
i__3 = i__;
19229
zx[i__2].r = zy[i__3].r, zx[i__2].i = zy[i__3].i;
19230
i__2 = i__;
19231
zy[i__2].r = ztemp.r, zy[i__2].i = ztemp.i;
19232
/* L30: */
19233
}
19234
return 0;
19235
} /* zswap_ */
19236
19237
/* Subroutine */ int ztrmm_(char *side, char *uplo, char *transa, char *diag,
19238
integer *m, integer *n, doublecomplex *alpha, doublecomplex *a,
19239
integer *lda, doublecomplex *b, integer *ldb)
19240
{
19241
/* System generated locals */
19242
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4, i__5,
19243
i__6;
19244
doublecomplex z__1, z__2, z__3;
19245
19246
/* Local variables */
19247
static integer i__, j, k, info;
19248
static doublecomplex temp;
19249
static logical lside;
19250
extern logical lsame_(char *, char *);
19251
static integer nrowa;
19252
static logical upper;
19253
extern /* Subroutine */ int xerbla_(char *, integer *);
19254
static logical noconj, nounit;
19255
19256
19257
/*
19258
Purpose
19259
=======
19260
19261
ZTRMM performs one of the matrix-matrix operations
19262
19263
B := alpha*op( A )*B, or B := alpha*B*op( A )
19264
19265
where alpha is a scalar, B is an m by n matrix, A is a unit, or
19266
non-unit, upper or lower triangular matrix and op( A ) is one of
19267
19268
op( A ) = A or op( A ) = A' or op( A ) = conjg( A' ).
19269
19270
Arguments
19271
==========
19272
19273
SIDE - CHARACTER*1.
19274
On entry, SIDE specifies whether op( A ) multiplies B from
19275
the left or right as follows:
19276
19277
SIDE = 'L' or 'l' B := alpha*op( A )*B.
19278
19279
SIDE = 'R' or 'r' B := alpha*B*op( A ).
19280
19281
Unchanged on exit.
19282
19283
UPLO - CHARACTER*1.
19284
On entry, UPLO specifies whether the matrix A is an upper or
19285
lower triangular matrix as follows:
19286
19287
UPLO = 'U' or 'u' A is an upper triangular matrix.
19288
19289
UPLO = 'L' or 'l' A is a lower triangular matrix.
19290
19291
Unchanged on exit.
19292
19293
TRANSA - CHARACTER*1.
19294
On entry, TRANSA specifies the form of op( A ) to be used in
19295
the matrix multiplication as follows:
19296
19297
TRANSA = 'N' or 'n' op( A ) = A.
19298
19299
TRANSA = 'T' or 't' op( A ) = A'.
19300
19301
TRANSA = 'C' or 'c' op( A ) = conjg( A' ).
19302
19303
Unchanged on exit.
19304
19305
DIAG - CHARACTER*1.
19306
On entry, DIAG specifies whether or not A is unit triangular
19307
as follows:
19308
19309
DIAG = 'U' or 'u' A is assumed to be unit triangular.
19310
19311
DIAG = 'N' or 'n' A is not assumed to be unit
19312
triangular.
19313
19314
Unchanged on exit.
19315
19316
M - INTEGER.
19317
On entry, M specifies the number of rows of B. M must be at
19318
least zero.
19319
Unchanged on exit.
19320
19321
N - INTEGER.
19322
On entry, N specifies the number of columns of B. N must be
19323
at least zero.
19324
Unchanged on exit.
19325
19326
ALPHA - COMPLEX*16 .
19327
On entry, ALPHA specifies the scalar alpha. When alpha is
19328
zero then A is not referenced and B need not be set before
19329
entry.
19330
Unchanged on exit.
19331
19332
A - COMPLEX*16 array of DIMENSION ( LDA, k ), where k is m
19333
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
19334
Before entry with UPLO = 'U' or 'u', the leading k by k
19335
upper triangular part of the array A must contain the upper
19336
triangular matrix and the strictly lower triangular part of
19337
A is not referenced.
19338
Before entry with UPLO = 'L' or 'l', the leading k by k
19339
lower triangular part of the array A must contain the lower
19340
triangular matrix and the strictly upper triangular part of
19341
A is not referenced.
19342
Note that when DIAG = 'U' or 'u', the diagonal elements of
19343
A are not referenced either, but are assumed to be unity.
19344
Unchanged on exit.
19345
19346
LDA - INTEGER.
19347
On entry, LDA specifies the first dimension of A as declared
19348
in the calling (sub) program. When SIDE = 'L' or 'l' then
19349
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
19350
then LDA must be at least max( 1, n ).
19351
Unchanged on exit.
19352
19353
B - COMPLEX*16 array of DIMENSION ( LDB, n ).
19354
Before entry, the leading m by n part of the array B must
19355
contain the matrix B, and on exit is overwritten by the
19356
transformed matrix.
19357
19358
LDB - INTEGER.
19359
On entry, LDB specifies the first dimension of B as declared
19360
in the calling (sub) program. LDB must be at least
19361
max( 1, m ).
19362
Unchanged on exit.
19363
19364
Further Details
19365
===============
19366
19367
Level 3 Blas routine.
19368
19369
-- Written on 8-February-1989.
19370
Jack Dongarra, Argonne National Laboratory.
19371
Iain Duff, AERE Harwell.
19372
Jeremy Du Croz, Numerical Algorithms Group Ltd.
19373
Sven Hammarling, Numerical Algorithms Group Ltd.
19374
19375
=====================================================================
19376
19377
19378
Test the input parameters.
19379
*/
19380
19381
/* Parameter adjustments */
19382
a_dim1 = *lda;
19383
a_offset = 1 + a_dim1;
19384
a -= a_offset;
19385
b_dim1 = *ldb;
19386
b_offset = 1 + b_dim1;
19387
b -= b_offset;
19388
19389
/* Function Body */
19390
lside = lsame_(side, "L");
19391
if (lside) {
19392
nrowa = *m;
19393
} else {
19394
nrowa = *n;
19395
}
19396
noconj = lsame_(transa, "T");
19397
nounit = lsame_(diag, "N");
19398
upper = lsame_(uplo, "U");
19399
19400
info = 0;
19401
if (! lside && ! lsame_(side, "R")) {
19402
info = 1;
19403
} else if (! upper && ! lsame_(uplo, "L")) {
19404
info = 2;
19405
} else if (! lsame_(transa, "N") && ! lsame_(transa,
19406
"T") && ! lsame_(transa, "C")) {
19407
info = 3;
19408
} else if (! lsame_(diag, "U") && ! lsame_(diag,
19409
"N")) {
19410
info = 4;
19411
} else if (*m < 0) {
19412
info = 5;
19413
} else if (*n < 0) {
19414
info = 6;
19415
} else if (*lda < max(1,nrowa)) {
19416
info = 9;
19417
} else if (*ldb < max(1,*m)) {
19418
info = 11;
19419
}
19420
if (info != 0) {
19421
xerbla_("ZTRMM ", &info);
19422
return 0;
19423
}
19424
19425
/* Quick return if possible. */
19426
19427
if (*m == 0 || *n == 0) {
19428
return 0;
19429
}
19430
19431
/* And when alpha.eq.zero. */
19432
19433
if (alpha->r == 0. && alpha->i == 0.) {
19434
i__1 = *n;
19435
for (j = 1; j <= i__1; ++j) {
19436
i__2 = *m;
19437
for (i__ = 1; i__ <= i__2; ++i__) {
19438
i__3 = i__ + j * b_dim1;
19439
b[i__3].r = 0., b[i__3].i = 0.;
19440
/* L10: */
19441
}
19442
/* L20: */
19443
}
19444
return 0;
19445
}
19446
19447
/* Start the operations. */
19448
19449
if (lside) {
19450
if (lsame_(transa, "N")) {
19451
19452
/* Form B := alpha*A*B. */
19453
19454
if (upper) {
19455
i__1 = *n;
19456
for (j = 1; j <= i__1; ++j) {
19457
i__2 = *m;
19458
for (k = 1; k <= i__2; ++k) {
19459
i__3 = k + j * b_dim1;
19460
if (b[i__3].r != 0. || b[i__3].i != 0.) {
19461
i__3 = k + j * b_dim1;
19462
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
19463
.i, z__1.i = alpha->r * b[i__3].i +
19464
alpha->i * b[i__3].r;
19465
temp.r = z__1.r, temp.i = z__1.i;
19466
i__3 = k - 1;
19467
for (i__ = 1; i__ <= i__3; ++i__) {
19468
i__4 = i__ + j * b_dim1;
19469
i__5 = i__ + j * b_dim1;
19470
i__6 = i__ + k * a_dim1;
19471
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6]
19472
.i, z__2.i = temp.r * a[i__6].i +
19473
temp.i * a[i__6].r;
19474
z__1.r = b[i__5].r + z__2.r, z__1.i = b[i__5]
19475
.i + z__2.i;
19476
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
19477
/* L30: */
19478
}
19479
if (nounit) {
19480
i__3 = k + k * a_dim1;
19481
z__1.r = temp.r * a[i__3].r - temp.i * a[i__3]
19482
.i, z__1.i = temp.r * a[i__3].i +
19483
temp.i * a[i__3].r;
19484
temp.r = z__1.r, temp.i = z__1.i;
19485
}
19486
i__3 = k + j * b_dim1;
19487
b[i__3].r = temp.r, b[i__3].i = temp.i;
19488
}
19489
/* L40: */
19490
}
19491
/* L50: */
19492
}
19493
} else {
19494
i__1 = *n;
19495
for (j = 1; j <= i__1; ++j) {
19496
for (k = *m; k >= 1; --k) {
19497
i__2 = k + j * b_dim1;
19498
if (b[i__2].r != 0. || b[i__2].i != 0.) {
19499
i__2 = k + j * b_dim1;
19500
z__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2]
19501
.i, z__1.i = alpha->r * b[i__2].i +
19502
alpha->i * b[i__2].r;
19503
temp.r = z__1.r, temp.i = z__1.i;
19504
i__2 = k + j * b_dim1;
19505
b[i__2].r = temp.r, b[i__2].i = temp.i;
19506
if (nounit) {
19507
i__2 = k + j * b_dim1;
19508
i__3 = k + j * b_dim1;
19509
i__4 = k + k * a_dim1;
19510
z__1.r = b[i__3].r * a[i__4].r - b[i__3].i *
19511
a[i__4].i, z__1.i = b[i__3].r * a[
19512
i__4].i + b[i__3].i * a[i__4].r;
19513
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
19514
}
19515
i__2 = *m;
19516
for (i__ = k + 1; i__ <= i__2; ++i__) {
19517
i__3 = i__ + j * b_dim1;
19518
i__4 = i__ + j * b_dim1;
19519
i__5 = i__ + k * a_dim1;
19520
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5]
19521
.i, z__2.i = temp.r * a[i__5].i +
19522
temp.i * a[i__5].r;
19523
z__1.r = b[i__4].r + z__2.r, z__1.i = b[i__4]
19524
.i + z__2.i;
19525
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19526
/* L60: */
19527
}
19528
}
19529
/* L70: */
19530
}
19531
/* L80: */
19532
}
19533
}
19534
} else {
19535
19536
/* Form B := alpha*A'*B or B := alpha*conjg( A' )*B. */
19537
19538
if (upper) {
19539
i__1 = *n;
19540
for (j = 1; j <= i__1; ++j) {
19541
for (i__ = *m; i__ >= 1; --i__) {
19542
i__2 = i__ + j * b_dim1;
19543
temp.r = b[i__2].r, temp.i = b[i__2].i;
19544
if (noconj) {
19545
if (nounit) {
19546
i__2 = i__ + i__ * a_dim1;
19547
z__1.r = temp.r * a[i__2].r - temp.i * a[i__2]
19548
.i, z__1.i = temp.r * a[i__2].i +
19549
temp.i * a[i__2].r;
19550
temp.r = z__1.r, temp.i = z__1.i;
19551
}
19552
i__2 = i__ - 1;
19553
for (k = 1; k <= i__2; ++k) {
19554
i__3 = k + i__ * a_dim1;
19555
i__4 = k + j * b_dim1;
19556
z__2.r = a[i__3].r * b[i__4].r - a[i__3].i *
19557
b[i__4].i, z__2.i = a[i__3].r * b[
19558
i__4].i + a[i__3].i * b[i__4].r;
19559
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
19560
z__2.i;
19561
temp.r = z__1.r, temp.i = z__1.i;
19562
/* L90: */
19563
}
19564
} else {
19565
if (nounit) {
19566
d_cnjg(&z__2, &a[i__ + i__ * a_dim1]);
19567
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
19568
z__1.i = temp.r * z__2.i + temp.i *
19569
z__2.r;
19570
temp.r = z__1.r, temp.i = z__1.i;
19571
}
19572
i__2 = i__ - 1;
19573
for (k = 1; k <= i__2; ++k) {
19574
d_cnjg(&z__3, &a[k + i__ * a_dim1]);
19575
i__3 = k + j * b_dim1;
19576
z__2.r = z__3.r * b[i__3].r - z__3.i * b[i__3]
19577
.i, z__2.i = z__3.r * b[i__3].i +
19578
z__3.i * b[i__3].r;
19579
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
19580
z__2.i;
19581
temp.r = z__1.r, temp.i = z__1.i;
19582
/* L100: */
19583
}
19584
}
19585
i__2 = i__ + j * b_dim1;
19586
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
19587
z__1.i = alpha->r * temp.i + alpha->i *
19588
temp.r;
19589
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
19590
/* L110: */
19591
}
19592
/* L120: */
19593
}
19594
} else {
19595
i__1 = *n;
19596
for (j = 1; j <= i__1; ++j) {
19597
i__2 = *m;
19598
for (i__ = 1; i__ <= i__2; ++i__) {
19599
i__3 = i__ + j * b_dim1;
19600
temp.r = b[i__3].r, temp.i = b[i__3].i;
19601
if (noconj) {
19602
if (nounit) {
19603
i__3 = i__ + i__ * a_dim1;
19604
z__1.r = temp.r * a[i__3].r - temp.i * a[i__3]
19605
.i, z__1.i = temp.r * a[i__3].i +
19606
temp.i * a[i__3].r;
19607
temp.r = z__1.r, temp.i = z__1.i;
19608
}
19609
i__3 = *m;
19610
for (k = i__ + 1; k <= i__3; ++k) {
19611
i__4 = k + i__ * a_dim1;
19612
i__5 = k + j * b_dim1;
19613
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i *
19614
b[i__5].i, z__2.i = a[i__4].r * b[
19615
i__5].i + a[i__4].i * b[i__5].r;
19616
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
19617
z__2.i;
19618
temp.r = z__1.r, temp.i = z__1.i;
19619
/* L130: */
19620
}
19621
} else {
19622
if (nounit) {
19623
d_cnjg(&z__2, &a[i__ + i__ * a_dim1]);
19624
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
19625
z__1.i = temp.r * z__2.i + temp.i *
19626
z__2.r;
19627
temp.r = z__1.r, temp.i = z__1.i;
19628
}
19629
i__3 = *m;
19630
for (k = i__ + 1; k <= i__3; ++k) {
19631
d_cnjg(&z__3, &a[k + i__ * a_dim1]);
19632
i__4 = k + j * b_dim1;
19633
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4]
19634
.i, z__2.i = z__3.r * b[i__4].i +
19635
z__3.i * b[i__4].r;
19636
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
19637
z__2.i;
19638
temp.r = z__1.r, temp.i = z__1.i;
19639
/* L140: */
19640
}
19641
}
19642
i__3 = i__ + j * b_dim1;
19643
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
19644
z__1.i = alpha->r * temp.i + alpha->i *
19645
temp.r;
19646
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19647
/* L150: */
19648
}
19649
/* L160: */
19650
}
19651
}
19652
}
19653
} else {
19654
if (lsame_(transa, "N")) {
19655
19656
/* Form B := alpha*B*A. */
19657
19658
if (upper) {
19659
for (j = *n; j >= 1; --j) {
19660
temp.r = alpha->r, temp.i = alpha->i;
19661
if (nounit) {
19662
i__1 = j + j * a_dim1;
19663
z__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
19664
z__1.i = temp.r * a[i__1].i + temp.i * a[i__1]
19665
.r;
19666
temp.r = z__1.r, temp.i = z__1.i;
19667
}
19668
i__1 = *m;
19669
for (i__ = 1; i__ <= i__1; ++i__) {
19670
i__2 = i__ + j * b_dim1;
19671
i__3 = i__ + j * b_dim1;
19672
z__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
19673
z__1.i = temp.r * b[i__3].i + temp.i * b[i__3]
19674
.r;
19675
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
19676
/* L170: */
19677
}
19678
i__1 = j - 1;
19679
for (k = 1; k <= i__1; ++k) {
19680
i__2 = k + j * a_dim1;
19681
if (a[i__2].r != 0. || a[i__2].i != 0.) {
19682
i__2 = k + j * a_dim1;
19683
z__1.r = alpha->r * a[i__2].r - alpha->i * a[i__2]
19684
.i, z__1.i = alpha->r * a[i__2].i +
19685
alpha->i * a[i__2].r;
19686
temp.r = z__1.r, temp.i = z__1.i;
19687
i__2 = *m;
19688
for (i__ = 1; i__ <= i__2; ++i__) {
19689
i__3 = i__ + j * b_dim1;
19690
i__4 = i__ + j * b_dim1;
19691
i__5 = i__ + k * b_dim1;
19692
z__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
19693
.i, z__2.i = temp.r * b[i__5].i +
19694
temp.i * b[i__5].r;
19695
z__1.r = b[i__4].r + z__2.r, z__1.i = b[i__4]
19696
.i + z__2.i;
19697
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19698
/* L180: */
19699
}
19700
}
19701
/* L190: */
19702
}
19703
/* L200: */
19704
}
19705
} else {
19706
i__1 = *n;
19707
for (j = 1; j <= i__1; ++j) {
19708
temp.r = alpha->r, temp.i = alpha->i;
19709
if (nounit) {
19710
i__2 = j + j * a_dim1;
19711
z__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
19712
z__1.i = temp.r * a[i__2].i + temp.i * a[i__2]
19713
.r;
19714
temp.r = z__1.r, temp.i = z__1.i;
19715
}
19716
i__2 = *m;
19717
for (i__ = 1; i__ <= i__2; ++i__) {
19718
i__3 = i__ + j * b_dim1;
19719
i__4 = i__ + j * b_dim1;
19720
z__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
19721
z__1.i = temp.r * b[i__4].i + temp.i * b[i__4]
19722
.r;
19723
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19724
/* L210: */
19725
}
19726
i__2 = *n;
19727
for (k = j + 1; k <= i__2; ++k) {
19728
i__3 = k + j * a_dim1;
19729
if (a[i__3].r != 0. || a[i__3].i != 0.) {
19730
i__3 = k + j * a_dim1;
19731
z__1.r = alpha->r * a[i__3].r - alpha->i * a[i__3]
19732
.i, z__1.i = alpha->r * a[i__3].i +
19733
alpha->i * a[i__3].r;
19734
temp.r = z__1.r, temp.i = z__1.i;
19735
i__3 = *m;
19736
for (i__ = 1; i__ <= i__3; ++i__) {
19737
i__4 = i__ + j * b_dim1;
19738
i__5 = i__ + j * b_dim1;
19739
i__6 = i__ + k * b_dim1;
19740
z__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
19741
.i, z__2.i = temp.r * b[i__6].i +
19742
temp.i * b[i__6].r;
19743
z__1.r = b[i__5].r + z__2.r, z__1.i = b[i__5]
19744
.i + z__2.i;
19745
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
19746
/* L220: */
19747
}
19748
}
19749
/* L230: */
19750
}
19751
/* L240: */
19752
}
19753
}
19754
} else {
19755
19756
/* Form B := alpha*B*A' or B := alpha*B*conjg( A' ). */
19757
19758
if (upper) {
19759
i__1 = *n;
19760
for (k = 1; k <= i__1; ++k) {
19761
i__2 = k - 1;
19762
for (j = 1; j <= i__2; ++j) {
19763
i__3 = j + k * a_dim1;
19764
if (a[i__3].r != 0. || a[i__3].i != 0.) {
19765
if (noconj) {
19766
i__3 = j + k * a_dim1;
19767
z__1.r = alpha->r * a[i__3].r - alpha->i * a[
19768
i__3].i, z__1.i = alpha->r * a[i__3]
19769
.i + alpha->i * a[i__3].r;
19770
temp.r = z__1.r, temp.i = z__1.i;
19771
} else {
19772
d_cnjg(&z__2, &a[j + k * a_dim1]);
19773
z__1.r = alpha->r * z__2.r - alpha->i *
19774
z__2.i, z__1.i = alpha->r * z__2.i +
19775
alpha->i * z__2.r;
19776
temp.r = z__1.r, temp.i = z__1.i;
19777
}
19778
i__3 = *m;
19779
for (i__ = 1; i__ <= i__3; ++i__) {
19780
i__4 = i__ + j * b_dim1;
19781
i__5 = i__ + j * b_dim1;
19782
i__6 = i__ + k * b_dim1;
19783
z__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
19784
.i, z__2.i = temp.r * b[i__6].i +
19785
temp.i * b[i__6].r;
19786
z__1.r = b[i__5].r + z__2.r, z__1.i = b[i__5]
19787
.i + z__2.i;
19788
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
19789
/* L250: */
19790
}
19791
}
19792
/* L260: */
19793
}
19794
temp.r = alpha->r, temp.i = alpha->i;
19795
if (nounit) {
19796
if (noconj) {
19797
i__2 = k + k * a_dim1;
19798
z__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
19799
z__1.i = temp.r * a[i__2].i + temp.i * a[
19800
i__2].r;
19801
temp.r = z__1.r, temp.i = z__1.i;
19802
} else {
19803
d_cnjg(&z__2, &a[k + k * a_dim1]);
19804
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
19805
z__1.i = temp.r * z__2.i + temp.i *
19806
z__2.r;
19807
temp.r = z__1.r, temp.i = z__1.i;
19808
}
19809
}
19810
if (temp.r != 1. || temp.i != 0.) {
19811
i__2 = *m;
19812
for (i__ = 1; i__ <= i__2; ++i__) {
19813
i__3 = i__ + k * b_dim1;
19814
i__4 = i__ + k * b_dim1;
19815
z__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
19816
z__1.i = temp.r * b[i__4].i + temp.i * b[
19817
i__4].r;
19818
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19819
/* L270: */
19820
}
19821
}
19822
/* L280: */
19823
}
19824
} else {
19825
for (k = *n; k >= 1; --k) {
19826
i__1 = *n;
19827
for (j = k + 1; j <= i__1; ++j) {
19828
i__2 = j + k * a_dim1;
19829
if (a[i__2].r != 0. || a[i__2].i != 0.) {
19830
if (noconj) {
19831
i__2 = j + k * a_dim1;
19832
z__1.r = alpha->r * a[i__2].r - alpha->i * a[
19833
i__2].i, z__1.i = alpha->r * a[i__2]
19834
.i + alpha->i * a[i__2].r;
19835
temp.r = z__1.r, temp.i = z__1.i;
19836
} else {
19837
d_cnjg(&z__2, &a[j + k * a_dim1]);
19838
z__1.r = alpha->r * z__2.r - alpha->i *
19839
z__2.i, z__1.i = alpha->r * z__2.i +
19840
alpha->i * z__2.r;
19841
temp.r = z__1.r, temp.i = z__1.i;
19842
}
19843
i__2 = *m;
19844
for (i__ = 1; i__ <= i__2; ++i__) {
19845
i__3 = i__ + j * b_dim1;
19846
i__4 = i__ + j * b_dim1;
19847
i__5 = i__ + k * b_dim1;
19848
z__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
19849
.i, z__2.i = temp.r * b[i__5].i +
19850
temp.i * b[i__5].r;
19851
z__1.r = b[i__4].r + z__2.r, z__1.i = b[i__4]
19852
.i + z__2.i;
19853
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
19854
/* L290: */
19855
}
19856
}
19857
/* L300: */
19858
}
19859
temp.r = alpha->r, temp.i = alpha->i;
19860
if (nounit) {
19861
if (noconj) {
19862
i__1 = k + k * a_dim1;
19863
z__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
19864
z__1.i = temp.r * a[i__1].i + temp.i * a[
19865
i__1].r;
19866
temp.r = z__1.r, temp.i = z__1.i;
19867
} else {
19868
d_cnjg(&z__2, &a[k + k * a_dim1]);
19869
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
19870
z__1.i = temp.r * z__2.i + temp.i *
19871
z__2.r;
19872
temp.r = z__1.r, temp.i = z__1.i;
19873
}
19874
}
19875
if (temp.r != 1. || temp.i != 0.) {
19876
i__1 = *m;
19877
for (i__ = 1; i__ <= i__1; ++i__) {
19878
i__2 = i__ + k * b_dim1;
19879
i__3 = i__ + k * b_dim1;
19880
z__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
19881
z__1.i = temp.r * b[i__3].i + temp.i * b[
19882
i__3].r;
19883
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
19884
/* L310: */
19885
}
19886
}
19887
/* L320: */
19888
}
19889
}
19890
}
19891
}
19892
19893
return 0;
19894
19895
/* End of ZTRMM . */
19896
19897
} /* ztrmm_ */
19898
19899
/* Subroutine */ int ztrmv_(char *uplo, char *trans, char *diag, integer *n,
19900
doublecomplex *a, integer *lda, doublecomplex *x, integer *incx)
19901
{
19902
/* System generated locals */
19903
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
19904
doublecomplex z__1, z__2, z__3;
19905
19906
/* Local variables */
19907
static integer i__, j, ix, jx, kx, info;
19908
static doublecomplex temp;
19909
extern logical lsame_(char *, char *);
19910
extern /* Subroutine */ int xerbla_(char *, integer *);
19911
static logical noconj, nounit;
19912
19913
19914
/*
19915
Purpose
19916
=======
19917
19918
ZTRMV performs one of the matrix-vector operations
19919
19920
x := A*x, or x := A'*x, or x := conjg( A' )*x,
19921
19922
where x is an n element vector and A is an n by n unit, or non-unit,
19923
upper or lower triangular matrix.
19924
19925
Arguments
19926
==========
19927
19928
UPLO - CHARACTER*1.
19929
On entry, UPLO specifies whether the matrix is an upper or
19930
lower triangular matrix as follows:
19931
19932
UPLO = 'U' or 'u' A is an upper triangular matrix.
19933
19934
UPLO = 'L' or 'l' A is a lower triangular matrix.
19935
19936
Unchanged on exit.
19937
19938
TRANS - CHARACTER*1.
19939
On entry, TRANS specifies the operation to be performed as
19940
follows:
19941
19942
TRANS = 'N' or 'n' x := A*x.
19943
19944
TRANS = 'T' or 't' x := A'*x.
19945
19946
TRANS = 'C' or 'c' x := conjg( A' )*x.
19947
19948
Unchanged on exit.
19949
19950
DIAG - CHARACTER*1.
19951
On entry, DIAG specifies whether or not A is unit
19952
triangular as follows:
19953
19954
DIAG = 'U' or 'u' A is assumed to be unit triangular.
19955
19956
DIAG = 'N' or 'n' A is not assumed to be unit
19957
triangular.
19958
19959
Unchanged on exit.
19960
19961
N - INTEGER.
19962
On entry, N specifies the order of the matrix A.
19963
N must be at least zero.
19964
Unchanged on exit.
19965
19966
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
19967
Before entry with UPLO = 'U' or 'u', the leading n by n
19968
upper triangular part of the array A must contain the upper
19969
triangular matrix and the strictly lower triangular part of
19970
A is not referenced.
19971
Before entry with UPLO = 'L' or 'l', the leading n by n
19972
lower triangular part of the array A must contain the lower
19973
triangular matrix and the strictly upper triangular part of
19974
A is not referenced.
19975
Note that when DIAG = 'U' or 'u', the diagonal elements of
19976
A are not referenced either, but are assumed to be unity.
19977
Unchanged on exit.
19978
19979
LDA - INTEGER.
19980
On entry, LDA specifies the first dimension of A as declared
19981
in the calling (sub) program. LDA must be at least
19982
max( 1, n ).
19983
Unchanged on exit.
19984
19985
X - COMPLEX*16 array of dimension at least
19986
( 1 + ( n - 1 )*abs( INCX ) ).
19987
Before entry, the incremented array X must contain the n
19988
element vector x. On exit, X is overwritten with the
19989
tranformed vector x.
19990
19991
INCX - INTEGER.
19992
On entry, INCX specifies the increment for the elements of
19993
X. INCX must not be zero.
19994
Unchanged on exit.
19995
19996
Further Details
19997
===============
19998
19999
Level 2 Blas routine.
20000
20001
-- Written on 22-October-1986.
20002
Jack Dongarra, Argonne National Lab.
20003
Jeremy Du Croz, Nag Central Office.
20004
Sven Hammarling, Nag Central Office.
20005
Richard Hanson, Sandia National Labs.
20006
20007
=====================================================================
20008
20009
20010
Test the input parameters.
20011
*/
20012
20013
/* Parameter adjustments */
20014
a_dim1 = *lda;
20015
a_offset = 1 + a_dim1;
20016
a -= a_offset;
20017
--x;
20018
20019
/* Function Body */
20020
info = 0;
20021
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
20022
info = 1;
20023
} else if (! lsame_(trans, "N") && ! lsame_(trans,
20024
"T") && ! lsame_(trans, "C")) {
20025
info = 2;
20026
} else if (! lsame_(diag, "U") && ! lsame_(diag,
20027
"N")) {
20028
info = 3;
20029
} else if (*n < 0) {
20030
info = 4;
20031
} else if (*lda < max(1,*n)) {
20032
info = 6;
20033
} else if (*incx == 0) {
20034
info = 8;
20035
}
20036
if (info != 0) {
20037
xerbla_("ZTRMV ", &info);
20038
return 0;
20039
}
20040
20041
/* Quick return if possible. */
20042
20043
if (*n == 0) {
20044
return 0;
20045
}
20046
20047
noconj = lsame_(trans, "T");
20048
nounit = lsame_(diag, "N");
20049
20050
/*
20051
Set up the start point in X if the increment is not unity. This
20052
will be ( N - 1 )*INCX too small for descending loops.
20053
*/
20054
20055
if (*incx <= 0) {
20056
kx = 1 - (*n - 1) * *incx;
20057
} else if (*incx != 1) {
20058
kx = 1;
20059
}
20060
20061
/*
20062
Start the operations. In this version the elements of A are
20063
accessed sequentially with one pass through A.
20064
*/
20065
20066
if (lsame_(trans, "N")) {
20067
20068
/* Form x := A*x. */
20069
20070
if (lsame_(uplo, "U")) {
20071
if (*incx == 1) {
20072
i__1 = *n;
20073
for (j = 1; j <= i__1; ++j) {
20074
i__2 = j;
20075
if (x[i__2].r != 0. || x[i__2].i != 0.) {
20076
i__2 = j;
20077
temp.r = x[i__2].r, temp.i = x[i__2].i;
20078
i__2 = j - 1;
20079
for (i__ = 1; i__ <= i__2; ++i__) {
20080
i__3 = i__;
20081
i__4 = i__;
20082
i__5 = i__ + j * a_dim1;
20083
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
20084
z__2.i = temp.r * a[i__5].i + temp.i * a[
20085
i__5].r;
20086
z__1.r = x[i__4].r + z__2.r, z__1.i = x[i__4].i +
20087
z__2.i;
20088
x[i__3].r = z__1.r, x[i__3].i = z__1.i;
20089
/* L10: */
20090
}
20091
if (nounit) {
20092
i__2 = j;
20093
i__3 = j;
20094
i__4 = j + j * a_dim1;
20095
z__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
20096
i__4].i, z__1.i = x[i__3].r * a[i__4].i +
20097
x[i__3].i * a[i__4].r;
20098
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
20099
}
20100
}
20101
/* L20: */
20102
}
20103
} else {
20104
jx = kx;
20105
i__1 = *n;
20106
for (j = 1; j <= i__1; ++j) {
20107
i__2 = jx;
20108
if (x[i__2].r != 0. || x[i__2].i != 0.) {
20109
i__2 = jx;
20110
temp.r = x[i__2].r, temp.i = x[i__2].i;
20111
ix = kx;
20112
i__2 = j - 1;
20113
for (i__ = 1; i__ <= i__2; ++i__) {
20114
i__3 = ix;
20115
i__4 = ix;
20116
i__5 = i__ + j * a_dim1;
20117
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
20118
z__2.i = temp.r * a[i__5].i + temp.i * a[
20119
i__5].r;
20120
z__1.r = x[i__4].r + z__2.r, z__1.i = x[i__4].i +
20121
z__2.i;
20122
x[i__3].r = z__1.r, x[i__3].i = z__1.i;
20123
ix += *incx;
20124
/* L30: */
20125
}
20126
if (nounit) {
20127
i__2 = jx;
20128
i__3 = jx;
20129
i__4 = j + j * a_dim1;
20130
z__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
20131
i__4].i, z__1.i = x[i__3].r * a[i__4].i +
20132
x[i__3].i * a[i__4].r;
20133
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
20134
}
20135
}
20136
jx += *incx;
20137
/* L40: */
20138
}
20139
}
20140
} else {
20141
if (*incx == 1) {
20142
for (j = *n; j >= 1; --j) {
20143
i__1 = j;
20144
if (x[i__1].r != 0. || x[i__1].i != 0.) {
20145
i__1 = j;
20146
temp.r = x[i__1].r, temp.i = x[i__1].i;
20147
i__1 = j + 1;
20148
for (i__ = *n; i__ >= i__1; --i__) {
20149
i__2 = i__;
20150
i__3 = i__;
20151
i__4 = i__ + j * a_dim1;
20152
z__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
20153
z__2.i = temp.r * a[i__4].i + temp.i * a[
20154
i__4].r;
20155
z__1.r = x[i__3].r + z__2.r, z__1.i = x[i__3].i +
20156
z__2.i;
20157
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
20158
/* L50: */
20159
}
20160
if (nounit) {
20161
i__1 = j;
20162
i__2 = j;
20163
i__3 = j + j * a_dim1;
20164
z__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
20165
i__3].i, z__1.i = x[i__2].r * a[i__3].i +
20166
x[i__2].i * a[i__3].r;
20167
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
20168
}
20169
}
20170
/* L60: */
20171
}
20172
} else {
20173
kx += (*n - 1) * *incx;
20174
jx = kx;
20175
for (j = *n; j >= 1; --j) {
20176
i__1 = jx;
20177
if (x[i__1].r != 0. || x[i__1].i != 0.) {
20178
i__1 = jx;
20179
temp.r = x[i__1].r, temp.i = x[i__1].i;
20180
ix = kx;
20181
i__1 = j + 1;
20182
for (i__ = *n; i__ >= i__1; --i__) {
20183
i__2 = ix;
20184
i__3 = ix;
20185
i__4 = i__ + j * a_dim1;
20186
z__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
20187
z__2.i = temp.r * a[i__4].i + temp.i * a[
20188
i__4].r;
20189
z__1.r = x[i__3].r + z__2.r, z__1.i = x[i__3].i +
20190
z__2.i;
20191
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
20192
ix -= *incx;
20193
/* L70: */
20194
}
20195
if (nounit) {
20196
i__1 = jx;
20197
i__2 = jx;
20198
i__3 = j + j * a_dim1;
20199
z__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
20200
i__3].i, z__1.i = x[i__2].r * a[i__3].i +
20201
x[i__2].i * a[i__3].r;
20202
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
20203
}
20204
}
20205
jx -= *incx;
20206
/* L80: */
20207
}
20208
}
20209
}
20210
} else {
20211
20212
/* Form x := A'*x or x := conjg( A' )*x. */
20213
20214
if (lsame_(uplo, "U")) {
20215
if (*incx == 1) {
20216
for (j = *n; j >= 1; --j) {
20217
i__1 = j;
20218
temp.r = x[i__1].r, temp.i = x[i__1].i;
20219
if (noconj) {
20220
if (nounit) {
20221
i__1 = j + j * a_dim1;
20222
z__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
20223
z__1.i = temp.r * a[i__1].i + temp.i * a[
20224
i__1].r;
20225
temp.r = z__1.r, temp.i = z__1.i;
20226
}
20227
for (i__ = j - 1; i__ >= 1; --i__) {
20228
i__1 = i__ + j * a_dim1;
20229
i__2 = i__;
20230
z__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
20231
i__2].i, z__2.i = a[i__1].r * x[i__2].i +
20232
a[i__1].i * x[i__2].r;
20233
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20234
z__2.i;
20235
temp.r = z__1.r, temp.i = z__1.i;
20236
/* L90: */
20237
}
20238
} else {
20239
if (nounit) {
20240
d_cnjg(&z__2, &a[j + j * a_dim1]);
20241
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
20242
z__1.i = temp.r * z__2.i + temp.i *
20243
z__2.r;
20244
temp.r = z__1.r, temp.i = z__1.i;
20245
}
20246
for (i__ = j - 1; i__ >= 1; --i__) {
20247
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
20248
i__1 = i__;
20249
z__2.r = z__3.r * x[i__1].r - z__3.i * x[i__1].i,
20250
z__2.i = z__3.r * x[i__1].i + z__3.i * x[
20251
i__1].r;
20252
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20253
z__2.i;
20254
temp.r = z__1.r, temp.i = z__1.i;
20255
/* L100: */
20256
}
20257
}
20258
i__1 = j;
20259
x[i__1].r = temp.r, x[i__1].i = temp.i;
20260
/* L110: */
20261
}
20262
} else {
20263
jx = kx + (*n - 1) * *incx;
20264
for (j = *n; j >= 1; --j) {
20265
i__1 = jx;
20266
temp.r = x[i__1].r, temp.i = x[i__1].i;
20267
ix = jx;
20268
if (noconj) {
20269
if (nounit) {
20270
i__1 = j + j * a_dim1;
20271
z__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i,
20272
z__1.i = temp.r * a[i__1].i + temp.i * a[
20273
i__1].r;
20274
temp.r = z__1.r, temp.i = z__1.i;
20275
}
20276
for (i__ = j - 1; i__ >= 1; --i__) {
20277
ix -= *incx;
20278
i__1 = i__ + j * a_dim1;
20279
i__2 = ix;
20280
z__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
20281
i__2].i, z__2.i = a[i__1].r * x[i__2].i +
20282
a[i__1].i * x[i__2].r;
20283
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20284
z__2.i;
20285
temp.r = z__1.r, temp.i = z__1.i;
20286
/* L120: */
20287
}
20288
} else {
20289
if (nounit) {
20290
d_cnjg(&z__2, &a[j + j * a_dim1]);
20291
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
20292
z__1.i = temp.r * z__2.i + temp.i *
20293
z__2.r;
20294
temp.r = z__1.r, temp.i = z__1.i;
20295
}
20296
for (i__ = j - 1; i__ >= 1; --i__) {
20297
ix -= *incx;
20298
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
20299
i__1 = ix;
20300
z__2.r = z__3.r * x[i__1].r - z__3.i * x[i__1].i,
20301
z__2.i = z__3.r * x[i__1].i + z__3.i * x[
20302
i__1].r;
20303
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20304
z__2.i;
20305
temp.r = z__1.r, temp.i = z__1.i;
20306
/* L130: */
20307
}
20308
}
20309
i__1 = jx;
20310
x[i__1].r = temp.r, x[i__1].i = temp.i;
20311
jx -= *incx;
20312
/* L140: */
20313
}
20314
}
20315
} else {
20316
if (*incx == 1) {
20317
i__1 = *n;
20318
for (j = 1; j <= i__1; ++j) {
20319
i__2 = j;
20320
temp.r = x[i__2].r, temp.i = x[i__2].i;
20321
if (noconj) {
20322
if (nounit) {
20323
i__2 = j + j * a_dim1;
20324
z__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
20325
z__1.i = temp.r * a[i__2].i + temp.i * a[
20326
i__2].r;
20327
temp.r = z__1.r, temp.i = z__1.i;
20328
}
20329
i__2 = *n;
20330
for (i__ = j + 1; i__ <= i__2; ++i__) {
20331
i__3 = i__ + j * a_dim1;
20332
i__4 = i__;
20333
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
20334
i__4].i, z__2.i = a[i__3].r * x[i__4].i +
20335
a[i__3].i * x[i__4].r;
20336
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20337
z__2.i;
20338
temp.r = z__1.r, temp.i = z__1.i;
20339
/* L150: */
20340
}
20341
} else {
20342
if (nounit) {
20343
d_cnjg(&z__2, &a[j + j * a_dim1]);
20344
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
20345
z__1.i = temp.r * z__2.i + temp.i *
20346
z__2.r;
20347
temp.r = z__1.r, temp.i = z__1.i;
20348
}
20349
i__2 = *n;
20350
for (i__ = j + 1; i__ <= i__2; ++i__) {
20351
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
20352
i__3 = i__;
20353
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
20354
z__2.i = z__3.r * x[i__3].i + z__3.i * x[
20355
i__3].r;
20356
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20357
z__2.i;
20358
temp.r = z__1.r, temp.i = z__1.i;
20359
/* L160: */
20360
}
20361
}
20362
i__2 = j;
20363
x[i__2].r = temp.r, x[i__2].i = temp.i;
20364
/* L170: */
20365
}
20366
} else {
20367
jx = kx;
20368
i__1 = *n;
20369
for (j = 1; j <= i__1; ++j) {
20370
i__2 = jx;
20371
temp.r = x[i__2].r, temp.i = x[i__2].i;
20372
ix = jx;
20373
if (noconj) {
20374
if (nounit) {
20375
i__2 = j + j * a_dim1;
20376
z__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i,
20377
z__1.i = temp.r * a[i__2].i + temp.i * a[
20378
i__2].r;
20379
temp.r = z__1.r, temp.i = z__1.i;
20380
}
20381
i__2 = *n;
20382
for (i__ = j + 1; i__ <= i__2; ++i__) {
20383
ix += *incx;
20384
i__3 = i__ + j * a_dim1;
20385
i__4 = ix;
20386
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
20387
i__4].i, z__2.i = a[i__3].r * x[i__4].i +
20388
a[i__3].i * x[i__4].r;
20389
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20390
z__2.i;
20391
temp.r = z__1.r, temp.i = z__1.i;
20392
/* L180: */
20393
}
20394
} else {
20395
if (nounit) {
20396
d_cnjg(&z__2, &a[j + j * a_dim1]);
20397
z__1.r = temp.r * z__2.r - temp.i * z__2.i,
20398
z__1.i = temp.r * z__2.i + temp.i *
20399
z__2.r;
20400
temp.r = z__1.r, temp.i = z__1.i;
20401
}
20402
i__2 = *n;
20403
for (i__ = j + 1; i__ <= i__2; ++i__) {
20404
ix += *incx;
20405
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
20406
i__3 = ix;
20407
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
20408
z__2.i = z__3.r * x[i__3].i + z__3.i * x[
20409
i__3].r;
20410
z__1.r = temp.r + z__2.r, z__1.i = temp.i +
20411
z__2.i;
20412
temp.r = z__1.r, temp.i = z__1.i;
20413
/* L190: */
20414
}
20415
}
20416
i__2 = jx;
20417
x[i__2].r = temp.r, x[i__2].i = temp.i;
20418
jx += *incx;
20419
/* L200: */
20420
}
20421
}
20422
}
20423
}
20424
20425
return 0;
20426
20427
/* End of ZTRMV . */
20428
20429
} /* ztrmv_ */
20430
20431
/* Subroutine */ int ztrsm_(char *side, char *uplo, char *transa, char *diag,
20432
integer *m, integer *n, doublecomplex *alpha, doublecomplex *a,
20433
integer *lda, doublecomplex *b, integer *ldb)
20434
{
20435
/* System generated locals */
20436
integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4, i__5,
20437
i__6, i__7;
20438
doublecomplex z__1, z__2, z__3;
20439
20440
/* Local variables */
20441
static integer i__, j, k, info;
20442
static doublecomplex temp;
20443
static logical lside;
20444
extern logical lsame_(char *, char *);
20445
static integer nrowa;
20446
static logical upper;
20447
extern /* Subroutine */ int xerbla_(char *, integer *);
20448
static logical noconj, nounit;
20449
20450
20451
/*
20452
Purpose
20453
=======
20454
20455
ZTRSM solves one of the matrix equations
20456
20457
op( A )*X = alpha*B, or X*op( A ) = alpha*B,
20458
20459
where alpha is a scalar, X and B are m by n matrices, A is a unit, or
20460
non-unit, upper or lower triangular matrix and op( A ) is one of
20461
20462
op( A ) = A or op( A ) = A' or op( A ) = conjg( A' ).
20463
20464
The matrix X is overwritten on B.
20465
20466
Arguments
20467
==========
20468
20469
SIDE - CHARACTER*1.
20470
On entry, SIDE specifies whether op( A ) appears on the left
20471
or right of X as follows:
20472
20473
SIDE = 'L' or 'l' op( A )*X = alpha*B.
20474
20475
SIDE = 'R' or 'r' X*op( A ) = alpha*B.
20476
20477
Unchanged on exit.
20478
20479
UPLO - CHARACTER*1.
20480
On entry, UPLO specifies whether the matrix A is an upper or
20481
lower triangular matrix as follows:
20482
20483
UPLO = 'U' or 'u' A is an upper triangular matrix.
20484
20485
UPLO = 'L' or 'l' A is a lower triangular matrix.
20486
20487
Unchanged on exit.
20488
20489
TRANSA - CHARACTER*1.
20490
On entry, TRANSA specifies the form of op( A ) to be used in
20491
the matrix multiplication as follows:
20492
20493
TRANSA = 'N' or 'n' op( A ) = A.
20494
20495
TRANSA = 'T' or 't' op( A ) = A'.
20496
20497
TRANSA = 'C' or 'c' op( A ) = conjg( A' ).
20498
20499
Unchanged on exit.
20500
20501
DIAG - CHARACTER*1.
20502
On entry, DIAG specifies whether or not A is unit triangular
20503
as follows:
20504
20505
DIAG = 'U' or 'u' A is assumed to be unit triangular.
20506
20507
DIAG = 'N' or 'n' A is not assumed to be unit
20508
triangular.
20509
20510
Unchanged on exit.
20511
20512
M - INTEGER.
20513
On entry, M specifies the number of rows of B. M must be at
20514
least zero.
20515
Unchanged on exit.
20516
20517
N - INTEGER.
20518
On entry, N specifies the number of columns of B. N must be
20519
at least zero.
20520
Unchanged on exit.
20521
20522
ALPHA - COMPLEX*16 .
20523
On entry, ALPHA specifies the scalar alpha. When alpha is
20524
zero then A is not referenced and B need not be set before
20525
entry.
20526
Unchanged on exit.
20527
20528
A - COMPLEX*16 array of DIMENSION ( LDA, k ), where k is m
20529
when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
20530
Before entry with UPLO = 'U' or 'u', the leading k by k
20531
upper triangular part of the array A must contain the upper
20532
triangular matrix and the strictly lower triangular part of
20533
A is not referenced.
20534
Before entry with UPLO = 'L' or 'l', the leading k by k
20535
lower triangular part of the array A must contain the lower
20536
triangular matrix and the strictly upper triangular part of
20537
A is not referenced.
20538
Note that when DIAG = 'U' or 'u', the diagonal elements of
20539
A are not referenced either, but are assumed to be unity.
20540
Unchanged on exit.
20541
20542
LDA - INTEGER.
20543
On entry, LDA specifies the first dimension of A as declared
20544
in the calling (sub) program. When SIDE = 'L' or 'l' then
20545
LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
20546
then LDA must be at least max( 1, n ).
20547
Unchanged on exit.
20548
20549
B - COMPLEX*16 array of DIMENSION ( LDB, n ).
20550
Before entry, the leading m by n part of the array B must
20551
contain the right-hand side matrix B, and on exit is
20552
overwritten by the solution matrix X.
20553
20554
LDB - INTEGER.
20555
On entry, LDB specifies the first dimension of B as declared
20556
in the calling (sub) program. LDB must be at least
20557
max( 1, m ).
20558
Unchanged on exit.
20559
20560
Further Details
20561
===============
20562
20563
Level 3 Blas routine.
20564
20565
-- Written on 8-February-1989.
20566
Jack Dongarra, Argonne National Laboratory.
20567
Iain Duff, AERE Harwell.
20568
Jeremy Du Croz, Numerical Algorithms Group Ltd.
20569
Sven Hammarling, Numerical Algorithms Group Ltd.
20570
20571
=====================================================================
20572
20573
20574
Test the input parameters.
20575
*/
20576
20577
/* Parameter adjustments */
20578
a_dim1 = *lda;
20579
a_offset = 1 + a_dim1;
20580
a -= a_offset;
20581
b_dim1 = *ldb;
20582
b_offset = 1 + b_dim1;
20583
b -= b_offset;
20584
20585
/* Function Body */
20586
lside = lsame_(side, "L");
20587
if (lside) {
20588
nrowa = *m;
20589
} else {
20590
nrowa = *n;
20591
}
20592
noconj = lsame_(transa, "T");
20593
nounit = lsame_(diag, "N");
20594
upper = lsame_(uplo, "U");
20595
20596
info = 0;
20597
if (! lside && ! lsame_(side, "R")) {
20598
info = 1;
20599
} else if (! upper && ! lsame_(uplo, "L")) {
20600
info = 2;
20601
} else if (! lsame_(transa, "N") && ! lsame_(transa,
20602
"T") && ! lsame_(transa, "C")) {
20603
info = 3;
20604
} else if (! lsame_(diag, "U") && ! lsame_(diag,
20605
"N")) {
20606
info = 4;
20607
} else if (*m < 0) {
20608
info = 5;
20609
} else if (*n < 0) {
20610
info = 6;
20611
} else if (*lda < max(1,nrowa)) {
20612
info = 9;
20613
} else if (*ldb < max(1,*m)) {
20614
info = 11;
20615
}
20616
if (info != 0) {
20617
xerbla_("ZTRSM ", &info);
20618
return 0;
20619
}
20620
20621
/* Quick return if possible. */
20622
20623
if (*m == 0 || *n == 0) {
20624
return 0;
20625
}
20626
20627
/* And when alpha.eq.zero. */
20628
20629
if (alpha->r == 0. && alpha->i == 0.) {
20630
i__1 = *n;
20631
for (j = 1; j <= i__1; ++j) {
20632
i__2 = *m;
20633
for (i__ = 1; i__ <= i__2; ++i__) {
20634
i__3 = i__ + j * b_dim1;
20635
b[i__3].r = 0., b[i__3].i = 0.;
20636
/* L10: */
20637
}
20638
/* L20: */
20639
}
20640
return 0;
20641
}
20642
20643
/* Start the operations. */
20644
20645
if (lside) {
20646
if (lsame_(transa, "N")) {
20647
20648
/* Form B := alpha*inv( A )*B. */
20649
20650
if (upper) {
20651
i__1 = *n;
20652
for (j = 1; j <= i__1; ++j) {
20653
if (alpha->r != 1. || alpha->i != 0.) {
20654
i__2 = *m;
20655
for (i__ = 1; i__ <= i__2; ++i__) {
20656
i__3 = i__ + j * b_dim1;
20657
i__4 = i__ + j * b_dim1;
20658
z__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
20659
.i, z__1.i = alpha->r * b[i__4].i +
20660
alpha->i * b[i__4].r;
20661
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20662
/* L30: */
20663
}
20664
}
20665
for (k = *m; k >= 1; --k) {
20666
i__2 = k + j * b_dim1;
20667
if (b[i__2].r != 0. || b[i__2].i != 0.) {
20668
if (nounit) {
20669
i__2 = k + j * b_dim1;
20670
z_div(&z__1, &b[k + j * b_dim1], &a[k + k *
20671
a_dim1]);
20672
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
20673
}
20674
i__2 = k - 1;
20675
for (i__ = 1; i__ <= i__2; ++i__) {
20676
i__3 = i__ + j * b_dim1;
20677
i__4 = i__ + j * b_dim1;
20678
i__5 = k + j * b_dim1;
20679
i__6 = i__ + k * a_dim1;
20680
z__2.r = b[i__5].r * a[i__6].r - b[i__5].i *
20681
a[i__6].i, z__2.i = b[i__5].r * a[
20682
i__6].i + b[i__5].i * a[i__6].r;
20683
z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4]
20684
.i - z__2.i;
20685
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20686
/* L40: */
20687
}
20688
}
20689
/* L50: */
20690
}
20691
/* L60: */
20692
}
20693
} else {
20694
i__1 = *n;
20695
for (j = 1; j <= i__1; ++j) {
20696
if (alpha->r != 1. || alpha->i != 0.) {
20697
i__2 = *m;
20698
for (i__ = 1; i__ <= i__2; ++i__) {
20699
i__3 = i__ + j * b_dim1;
20700
i__4 = i__ + j * b_dim1;
20701
z__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
20702
.i, z__1.i = alpha->r * b[i__4].i +
20703
alpha->i * b[i__4].r;
20704
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20705
/* L70: */
20706
}
20707
}
20708
i__2 = *m;
20709
for (k = 1; k <= i__2; ++k) {
20710
i__3 = k + j * b_dim1;
20711
if (b[i__3].r != 0. || b[i__3].i != 0.) {
20712
if (nounit) {
20713
i__3 = k + j * b_dim1;
20714
z_div(&z__1, &b[k + j * b_dim1], &a[k + k *
20715
a_dim1]);
20716
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20717
}
20718
i__3 = *m;
20719
for (i__ = k + 1; i__ <= i__3; ++i__) {
20720
i__4 = i__ + j * b_dim1;
20721
i__5 = i__ + j * b_dim1;
20722
i__6 = k + j * b_dim1;
20723
i__7 = i__ + k * a_dim1;
20724
z__2.r = b[i__6].r * a[i__7].r - b[i__6].i *
20725
a[i__7].i, z__2.i = b[i__6].r * a[
20726
i__7].i + b[i__6].i * a[i__7].r;
20727
z__1.r = b[i__5].r - z__2.r, z__1.i = b[i__5]
20728
.i - z__2.i;
20729
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
20730
/* L80: */
20731
}
20732
}
20733
/* L90: */
20734
}
20735
/* L100: */
20736
}
20737
}
20738
} else {
20739
20740
/*
20741
Form B := alpha*inv( A' )*B
20742
or B := alpha*inv( conjg( A' ) )*B.
20743
*/
20744
20745
if (upper) {
20746
i__1 = *n;
20747
for (j = 1; j <= i__1; ++j) {
20748
i__2 = *m;
20749
for (i__ = 1; i__ <= i__2; ++i__) {
20750
i__3 = i__ + j * b_dim1;
20751
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
20752
z__1.i = alpha->r * b[i__3].i + alpha->i * b[
20753
i__3].r;
20754
temp.r = z__1.r, temp.i = z__1.i;
20755
if (noconj) {
20756
i__3 = i__ - 1;
20757
for (k = 1; k <= i__3; ++k) {
20758
i__4 = k + i__ * a_dim1;
20759
i__5 = k + j * b_dim1;
20760
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i *
20761
b[i__5].i, z__2.i = a[i__4].r * b[
20762
i__5].i + a[i__4].i * b[i__5].r;
20763
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
20764
z__2.i;
20765
temp.r = z__1.r, temp.i = z__1.i;
20766
/* L110: */
20767
}
20768
if (nounit) {
20769
z_div(&z__1, &temp, &a[i__ + i__ * a_dim1]);
20770
temp.r = z__1.r, temp.i = z__1.i;
20771
}
20772
} else {
20773
i__3 = i__ - 1;
20774
for (k = 1; k <= i__3; ++k) {
20775
d_cnjg(&z__3, &a[k + i__ * a_dim1]);
20776
i__4 = k + j * b_dim1;
20777
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4]
20778
.i, z__2.i = z__3.r * b[i__4].i +
20779
z__3.i * b[i__4].r;
20780
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
20781
z__2.i;
20782
temp.r = z__1.r, temp.i = z__1.i;
20783
/* L120: */
20784
}
20785
if (nounit) {
20786
d_cnjg(&z__2, &a[i__ + i__ * a_dim1]);
20787
z_div(&z__1, &temp, &z__2);
20788
temp.r = z__1.r, temp.i = z__1.i;
20789
}
20790
}
20791
i__3 = i__ + j * b_dim1;
20792
b[i__3].r = temp.r, b[i__3].i = temp.i;
20793
/* L130: */
20794
}
20795
/* L140: */
20796
}
20797
} else {
20798
i__1 = *n;
20799
for (j = 1; j <= i__1; ++j) {
20800
for (i__ = *m; i__ >= 1; --i__) {
20801
i__2 = i__ + j * b_dim1;
20802
z__1.r = alpha->r * b[i__2].r - alpha->i * b[i__2].i,
20803
z__1.i = alpha->r * b[i__2].i + alpha->i * b[
20804
i__2].r;
20805
temp.r = z__1.r, temp.i = z__1.i;
20806
if (noconj) {
20807
i__2 = *m;
20808
for (k = i__ + 1; k <= i__2; ++k) {
20809
i__3 = k + i__ * a_dim1;
20810
i__4 = k + j * b_dim1;
20811
z__2.r = a[i__3].r * b[i__4].r - a[i__3].i *
20812
b[i__4].i, z__2.i = a[i__3].r * b[
20813
i__4].i + a[i__3].i * b[i__4].r;
20814
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
20815
z__2.i;
20816
temp.r = z__1.r, temp.i = z__1.i;
20817
/* L150: */
20818
}
20819
if (nounit) {
20820
z_div(&z__1, &temp, &a[i__ + i__ * a_dim1]);
20821
temp.r = z__1.r, temp.i = z__1.i;
20822
}
20823
} else {
20824
i__2 = *m;
20825
for (k = i__ + 1; k <= i__2; ++k) {
20826
d_cnjg(&z__3, &a[k + i__ * a_dim1]);
20827
i__3 = k + j * b_dim1;
20828
z__2.r = z__3.r * b[i__3].r - z__3.i * b[i__3]
20829
.i, z__2.i = z__3.r * b[i__3].i +
20830
z__3.i * b[i__3].r;
20831
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
20832
z__2.i;
20833
temp.r = z__1.r, temp.i = z__1.i;
20834
/* L160: */
20835
}
20836
if (nounit) {
20837
d_cnjg(&z__2, &a[i__ + i__ * a_dim1]);
20838
z_div(&z__1, &temp, &z__2);
20839
temp.r = z__1.r, temp.i = z__1.i;
20840
}
20841
}
20842
i__2 = i__ + j * b_dim1;
20843
b[i__2].r = temp.r, b[i__2].i = temp.i;
20844
/* L170: */
20845
}
20846
/* L180: */
20847
}
20848
}
20849
}
20850
} else {
20851
if (lsame_(transa, "N")) {
20852
20853
/* Form B := alpha*B*inv( A ). */
20854
20855
if (upper) {
20856
i__1 = *n;
20857
for (j = 1; j <= i__1; ++j) {
20858
if (alpha->r != 1. || alpha->i != 0.) {
20859
i__2 = *m;
20860
for (i__ = 1; i__ <= i__2; ++i__) {
20861
i__3 = i__ + j * b_dim1;
20862
i__4 = i__ + j * b_dim1;
20863
z__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
20864
.i, z__1.i = alpha->r * b[i__4].i +
20865
alpha->i * b[i__4].r;
20866
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20867
/* L190: */
20868
}
20869
}
20870
i__2 = j - 1;
20871
for (k = 1; k <= i__2; ++k) {
20872
i__3 = k + j * a_dim1;
20873
if (a[i__3].r != 0. || a[i__3].i != 0.) {
20874
i__3 = *m;
20875
for (i__ = 1; i__ <= i__3; ++i__) {
20876
i__4 = i__ + j * b_dim1;
20877
i__5 = i__ + j * b_dim1;
20878
i__6 = k + j * a_dim1;
20879
i__7 = i__ + k * b_dim1;
20880
z__2.r = a[i__6].r * b[i__7].r - a[i__6].i *
20881
b[i__7].i, z__2.i = a[i__6].r * b[
20882
i__7].i + a[i__6].i * b[i__7].r;
20883
z__1.r = b[i__5].r - z__2.r, z__1.i = b[i__5]
20884
.i - z__2.i;
20885
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
20886
/* L200: */
20887
}
20888
}
20889
/* L210: */
20890
}
20891
if (nounit) {
20892
z_div(&z__1, &c_b1078, &a[j + j * a_dim1]);
20893
temp.r = z__1.r, temp.i = z__1.i;
20894
i__2 = *m;
20895
for (i__ = 1; i__ <= i__2; ++i__) {
20896
i__3 = i__ + j * b_dim1;
20897
i__4 = i__ + j * b_dim1;
20898
z__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
20899
z__1.i = temp.r * b[i__4].i + temp.i * b[
20900
i__4].r;
20901
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20902
/* L220: */
20903
}
20904
}
20905
/* L230: */
20906
}
20907
} else {
20908
for (j = *n; j >= 1; --j) {
20909
if (alpha->r != 1. || alpha->i != 0.) {
20910
i__1 = *m;
20911
for (i__ = 1; i__ <= i__1; ++i__) {
20912
i__2 = i__ + j * b_dim1;
20913
i__3 = i__ + j * b_dim1;
20914
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
20915
.i, z__1.i = alpha->r * b[i__3].i +
20916
alpha->i * b[i__3].r;
20917
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
20918
/* L240: */
20919
}
20920
}
20921
i__1 = *n;
20922
for (k = j + 1; k <= i__1; ++k) {
20923
i__2 = k + j * a_dim1;
20924
if (a[i__2].r != 0. || a[i__2].i != 0.) {
20925
i__2 = *m;
20926
for (i__ = 1; i__ <= i__2; ++i__) {
20927
i__3 = i__ + j * b_dim1;
20928
i__4 = i__ + j * b_dim1;
20929
i__5 = k + j * a_dim1;
20930
i__6 = i__ + k * b_dim1;
20931
z__2.r = a[i__5].r * b[i__6].r - a[i__5].i *
20932
b[i__6].i, z__2.i = a[i__5].r * b[
20933
i__6].i + a[i__5].i * b[i__6].r;
20934
z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4]
20935
.i - z__2.i;
20936
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
20937
/* L250: */
20938
}
20939
}
20940
/* L260: */
20941
}
20942
if (nounit) {
20943
z_div(&z__1, &c_b1078, &a[j + j * a_dim1]);
20944
temp.r = z__1.r, temp.i = z__1.i;
20945
i__1 = *m;
20946
for (i__ = 1; i__ <= i__1; ++i__) {
20947
i__2 = i__ + j * b_dim1;
20948
i__3 = i__ + j * b_dim1;
20949
z__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
20950
z__1.i = temp.r * b[i__3].i + temp.i * b[
20951
i__3].r;
20952
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
20953
/* L270: */
20954
}
20955
}
20956
/* L280: */
20957
}
20958
}
20959
} else {
20960
20961
/*
20962
Form B := alpha*B*inv( A' )
20963
or B := alpha*B*inv( conjg( A' ) ).
20964
*/
20965
20966
if (upper) {
20967
for (k = *n; k >= 1; --k) {
20968
if (nounit) {
20969
if (noconj) {
20970
z_div(&z__1, &c_b1078, &a[k + k * a_dim1]);
20971
temp.r = z__1.r, temp.i = z__1.i;
20972
} else {
20973
d_cnjg(&z__2, &a[k + k * a_dim1]);
20974
z_div(&z__1, &c_b1078, &z__2);
20975
temp.r = z__1.r, temp.i = z__1.i;
20976
}
20977
i__1 = *m;
20978
for (i__ = 1; i__ <= i__1; ++i__) {
20979
i__2 = i__ + k * b_dim1;
20980
i__3 = i__ + k * b_dim1;
20981
z__1.r = temp.r * b[i__3].r - temp.i * b[i__3].i,
20982
z__1.i = temp.r * b[i__3].i + temp.i * b[
20983
i__3].r;
20984
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
20985
/* L290: */
20986
}
20987
}
20988
i__1 = k - 1;
20989
for (j = 1; j <= i__1; ++j) {
20990
i__2 = j + k * a_dim1;
20991
if (a[i__2].r != 0. || a[i__2].i != 0.) {
20992
if (noconj) {
20993
i__2 = j + k * a_dim1;
20994
temp.r = a[i__2].r, temp.i = a[i__2].i;
20995
} else {
20996
d_cnjg(&z__1, &a[j + k * a_dim1]);
20997
temp.r = z__1.r, temp.i = z__1.i;
20998
}
20999
i__2 = *m;
21000
for (i__ = 1; i__ <= i__2; ++i__) {
21001
i__3 = i__ + j * b_dim1;
21002
i__4 = i__ + j * b_dim1;
21003
i__5 = i__ + k * b_dim1;
21004
z__2.r = temp.r * b[i__5].r - temp.i * b[i__5]
21005
.i, z__2.i = temp.r * b[i__5].i +
21006
temp.i * b[i__5].r;
21007
z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4]
21008
.i - z__2.i;
21009
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
21010
/* L300: */
21011
}
21012
}
21013
/* L310: */
21014
}
21015
if (alpha->r != 1. || alpha->i != 0.) {
21016
i__1 = *m;
21017
for (i__ = 1; i__ <= i__1; ++i__) {
21018
i__2 = i__ + k * b_dim1;
21019
i__3 = i__ + k * b_dim1;
21020
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3]
21021
.i, z__1.i = alpha->r * b[i__3].i +
21022
alpha->i * b[i__3].r;
21023
b[i__2].r = z__1.r, b[i__2].i = z__1.i;
21024
/* L320: */
21025
}
21026
}
21027
/* L330: */
21028
}
21029
} else {
21030
i__1 = *n;
21031
for (k = 1; k <= i__1; ++k) {
21032
if (nounit) {
21033
if (noconj) {
21034
z_div(&z__1, &c_b1078, &a[k + k * a_dim1]);
21035
temp.r = z__1.r, temp.i = z__1.i;
21036
} else {
21037
d_cnjg(&z__2, &a[k + k * a_dim1]);
21038
z_div(&z__1, &c_b1078, &z__2);
21039
temp.r = z__1.r, temp.i = z__1.i;
21040
}
21041
i__2 = *m;
21042
for (i__ = 1; i__ <= i__2; ++i__) {
21043
i__3 = i__ + k * b_dim1;
21044
i__4 = i__ + k * b_dim1;
21045
z__1.r = temp.r * b[i__4].r - temp.i * b[i__4].i,
21046
z__1.i = temp.r * b[i__4].i + temp.i * b[
21047
i__4].r;
21048
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
21049
/* L340: */
21050
}
21051
}
21052
i__2 = *n;
21053
for (j = k + 1; j <= i__2; ++j) {
21054
i__3 = j + k * a_dim1;
21055
if (a[i__3].r != 0. || a[i__3].i != 0.) {
21056
if (noconj) {
21057
i__3 = j + k * a_dim1;
21058
temp.r = a[i__3].r, temp.i = a[i__3].i;
21059
} else {
21060
d_cnjg(&z__1, &a[j + k * a_dim1]);
21061
temp.r = z__1.r, temp.i = z__1.i;
21062
}
21063
i__3 = *m;
21064
for (i__ = 1; i__ <= i__3; ++i__) {
21065
i__4 = i__ + j * b_dim1;
21066
i__5 = i__ + j * b_dim1;
21067
i__6 = i__ + k * b_dim1;
21068
z__2.r = temp.r * b[i__6].r - temp.i * b[i__6]
21069
.i, z__2.i = temp.r * b[i__6].i +
21070
temp.i * b[i__6].r;
21071
z__1.r = b[i__5].r - z__2.r, z__1.i = b[i__5]
21072
.i - z__2.i;
21073
b[i__4].r = z__1.r, b[i__4].i = z__1.i;
21074
/* L350: */
21075
}
21076
}
21077
/* L360: */
21078
}
21079
if (alpha->r != 1. || alpha->i != 0.) {
21080
i__2 = *m;
21081
for (i__ = 1; i__ <= i__2; ++i__) {
21082
i__3 = i__ + k * b_dim1;
21083
i__4 = i__ + k * b_dim1;
21084
z__1.r = alpha->r * b[i__4].r - alpha->i * b[i__4]
21085
.i, z__1.i = alpha->r * b[i__4].i +
21086
alpha->i * b[i__4].r;
21087
b[i__3].r = z__1.r, b[i__3].i = z__1.i;
21088
/* L370: */
21089
}
21090
}
21091
/* L380: */
21092
}
21093
}
21094
}
21095
}
21096
21097
return 0;
21098
21099
/* End of ZTRSM . */
21100
21101
} /* ztrsm_ */
21102
21103
/* Subroutine */ int ztrsv_(char *uplo, char *trans, char *diag, integer *n,
21104
doublecomplex *a, integer *lda, doublecomplex *x, integer *incx)
21105
{
21106
/* System generated locals */
21107
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
21108
doublecomplex z__1, z__2, z__3;
21109
21110
/* Local variables */
21111
static integer i__, j, ix, jx, kx, info;
21112
static doublecomplex temp;
21113
extern logical lsame_(char *, char *);
21114
extern /* Subroutine */ int xerbla_(char *, integer *);
21115
static logical noconj, nounit;
21116
21117
21118
/*
21119
Purpose
21120
=======
21121
21122
ZTRSV solves one of the systems of equations
21123
21124
A*x = b, or A'*x = b, or conjg( A' )*x = b,
21125
21126
where b and x are n element vectors and A is an n by n unit, or
21127
non-unit, upper or lower triangular matrix.
21128
21129
No test for singularity or near-singularity is included in this
21130
routine. Such tests must be performed before calling this routine.
21131
21132
Arguments
21133
==========
21134
21135
UPLO - CHARACTER*1.
21136
On entry, UPLO specifies whether the matrix is an upper or
21137
lower triangular matrix as follows:
21138
21139
UPLO = 'U' or 'u' A is an upper triangular matrix.
21140
21141
UPLO = 'L' or 'l' A is a lower triangular matrix.
21142
21143
Unchanged on exit.
21144
21145
TRANS - CHARACTER*1.
21146
On entry, TRANS specifies the equations to be solved as
21147
follows:
21148
21149
TRANS = 'N' or 'n' A*x = b.
21150
21151
TRANS = 'T' or 't' A'*x = b.
21152
21153
TRANS = 'C' or 'c' conjg( A' )*x = b.
21154
21155
Unchanged on exit.
21156
21157
DIAG - CHARACTER*1.
21158
On entry, DIAG specifies whether or not A is unit
21159
triangular as follows:
21160
21161
DIAG = 'U' or 'u' A is assumed to be unit triangular.
21162
21163
DIAG = 'N' or 'n' A is not assumed to be unit
21164
triangular.
21165
21166
Unchanged on exit.
21167
21168
N - INTEGER.
21169
On entry, N specifies the order of the matrix A.
21170
N must be at least zero.
21171
Unchanged on exit.
21172
21173
A - COMPLEX*16 array of DIMENSION ( LDA, n ).
21174
Before entry with UPLO = 'U' or 'u', the leading n by n
21175
upper triangular part of the array A must contain the upper
21176
triangular matrix and the strictly lower triangular part of
21177
A is not referenced.
21178
Before entry with UPLO = 'L' or 'l', the leading n by n
21179
lower triangular part of the array A must contain the lower
21180
triangular matrix and the strictly upper triangular part of
21181
A is not referenced.
21182
Note that when DIAG = 'U' or 'u', the diagonal elements of
21183
A are not referenced either, but are assumed to be unity.
21184
Unchanged on exit.
21185
21186
LDA - INTEGER.
21187
On entry, LDA specifies the first dimension of A as declared
21188
in the calling (sub) program. LDA must be at least
21189
max( 1, n ).
21190
Unchanged on exit.
21191
21192
X - COMPLEX*16 array of dimension at least
21193
( 1 + ( n - 1 )*abs( INCX ) ).
21194
Before entry, the incremented array X must contain the n
21195
element right-hand side vector b. On exit, X is overwritten
21196
with the solution vector x.
21197
21198
INCX - INTEGER.
21199
On entry, INCX specifies the increment for the elements of
21200
X. INCX must not be zero.
21201
Unchanged on exit.
21202
21203
Further Details
21204
===============
21205
21206
Level 2 Blas routine.
21207
21208
-- Written on 22-October-1986.
21209
Jack Dongarra, Argonne National Lab.
21210
Jeremy Du Croz, Nag Central Office.
21211
Sven Hammarling, Nag Central Office.
21212
Richard Hanson, Sandia National Labs.
21213
21214
=====================================================================
21215
21216
21217
Test the input parameters.
21218
*/
21219
21220
/* Parameter adjustments */
21221
a_dim1 = *lda;
21222
a_offset = 1 + a_dim1;
21223
a -= a_offset;
21224
--x;
21225
21226
/* Function Body */
21227
info = 0;
21228
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
21229
info = 1;
21230
} else if (! lsame_(trans, "N") && ! lsame_(trans,
21231
"T") && ! lsame_(trans, "C")) {
21232
info = 2;
21233
} else if (! lsame_(diag, "U") && ! lsame_(diag,
21234
"N")) {
21235
info = 3;
21236
} else if (*n < 0) {
21237
info = 4;
21238
} else if (*lda < max(1,*n)) {
21239
info = 6;
21240
} else if (*incx == 0) {
21241
info = 8;
21242
}
21243
if (info != 0) {
21244
xerbla_("ZTRSV ", &info);
21245
return 0;
21246
}
21247
21248
/* Quick return if possible. */
21249
21250
if (*n == 0) {
21251
return 0;
21252
}
21253
21254
noconj = lsame_(trans, "T");
21255
nounit = lsame_(diag, "N");
21256
21257
/*
21258
Set up the start point in X if the increment is not unity. This
21259
will be ( N - 1 )*INCX too small for descending loops.
21260
*/
21261
21262
if (*incx <= 0) {
21263
kx = 1 - (*n - 1) * *incx;
21264
} else if (*incx != 1) {
21265
kx = 1;
21266
}
21267
21268
/*
21269
Start the operations. In this version the elements of A are
21270
accessed sequentially with one pass through A.
21271
*/
21272
21273
if (lsame_(trans, "N")) {
21274
21275
/* Form x := inv( A )*x. */
21276
21277
if (lsame_(uplo, "U")) {
21278
if (*incx == 1) {
21279
for (j = *n; j >= 1; --j) {
21280
i__1 = j;
21281
if (x[i__1].r != 0. || x[i__1].i != 0.) {
21282
if (nounit) {
21283
i__1 = j;
21284
z_div(&z__1, &x[j], &a[j + j * a_dim1]);
21285
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
21286
}
21287
i__1 = j;
21288
temp.r = x[i__1].r, temp.i = x[i__1].i;
21289
for (i__ = j - 1; i__ >= 1; --i__) {
21290
i__1 = i__;
21291
i__2 = i__;
21292
i__3 = i__ + j * a_dim1;
21293
z__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
21294
z__2.i = temp.r * a[i__3].i + temp.i * a[
21295
i__3].r;
21296
z__1.r = x[i__2].r - z__2.r, z__1.i = x[i__2].i -
21297
z__2.i;
21298
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
21299
/* L10: */
21300
}
21301
}
21302
/* L20: */
21303
}
21304
} else {
21305
jx = kx + (*n - 1) * *incx;
21306
for (j = *n; j >= 1; --j) {
21307
i__1 = jx;
21308
if (x[i__1].r != 0. || x[i__1].i != 0.) {
21309
if (nounit) {
21310
i__1 = jx;
21311
z_div(&z__1, &x[jx], &a[j + j * a_dim1]);
21312
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
21313
}
21314
i__1 = jx;
21315
temp.r = x[i__1].r, temp.i = x[i__1].i;
21316
ix = jx;
21317
for (i__ = j - 1; i__ >= 1; --i__) {
21318
ix -= *incx;
21319
i__1 = ix;
21320
i__2 = ix;
21321
i__3 = i__ + j * a_dim1;
21322
z__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
21323
z__2.i = temp.r * a[i__3].i + temp.i * a[
21324
i__3].r;
21325
z__1.r = x[i__2].r - z__2.r, z__1.i = x[i__2].i -
21326
z__2.i;
21327
x[i__1].r = z__1.r, x[i__1].i = z__1.i;
21328
/* L30: */
21329
}
21330
}
21331
jx -= *incx;
21332
/* L40: */
21333
}
21334
}
21335
} else {
21336
if (*incx == 1) {
21337
i__1 = *n;
21338
for (j = 1; j <= i__1; ++j) {
21339
i__2 = j;
21340
if (x[i__2].r != 0. || x[i__2].i != 0.) {
21341
if (nounit) {
21342
i__2 = j;
21343
z_div(&z__1, &x[j], &a[j + j * a_dim1]);
21344
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
21345
}
21346
i__2 = j;
21347
temp.r = x[i__2].r, temp.i = x[i__2].i;
21348
i__2 = *n;
21349
for (i__ = j + 1; i__ <= i__2; ++i__) {
21350
i__3 = i__;
21351
i__4 = i__;
21352
i__5 = i__ + j * a_dim1;
21353
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
21354
z__2.i = temp.r * a[i__5].i + temp.i * a[
21355
i__5].r;
21356
z__1.r = x[i__4].r - z__2.r, z__1.i = x[i__4].i -
21357
z__2.i;
21358
x[i__3].r = z__1.r, x[i__3].i = z__1.i;
21359
/* L50: */
21360
}
21361
}
21362
/* L60: */
21363
}
21364
} else {
21365
jx = kx;
21366
i__1 = *n;
21367
for (j = 1; j <= i__1; ++j) {
21368
i__2 = jx;
21369
if (x[i__2].r != 0. || x[i__2].i != 0.) {
21370
if (nounit) {
21371
i__2 = jx;
21372
z_div(&z__1, &x[jx], &a[j + j * a_dim1]);
21373
x[i__2].r = z__1.r, x[i__2].i = z__1.i;
21374
}
21375
i__2 = jx;
21376
temp.r = x[i__2].r, temp.i = x[i__2].i;
21377
ix = jx;
21378
i__2 = *n;
21379
for (i__ = j + 1; i__ <= i__2; ++i__) {
21380
ix += *incx;
21381
i__3 = ix;
21382
i__4 = ix;
21383
i__5 = i__ + j * a_dim1;
21384
z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
21385
z__2.i = temp.r * a[i__5].i + temp.i * a[
21386
i__5].r;
21387
z__1.r = x[i__4].r - z__2.r, z__1.i = x[i__4].i -
21388
z__2.i;
21389
x[i__3].r = z__1.r, x[i__3].i = z__1.i;
21390
/* L70: */
21391
}
21392
}
21393
jx += *incx;
21394
/* L80: */
21395
}
21396
}
21397
}
21398
} else {
21399
21400
/* Form x := inv( A' )*x or x := inv( conjg( A' ) )*x. */
21401
21402
if (lsame_(uplo, "U")) {
21403
if (*incx == 1) {
21404
i__1 = *n;
21405
for (j = 1; j <= i__1; ++j) {
21406
i__2 = j;
21407
temp.r = x[i__2].r, temp.i = x[i__2].i;
21408
if (noconj) {
21409
i__2 = j - 1;
21410
for (i__ = 1; i__ <= i__2; ++i__) {
21411
i__3 = i__ + j * a_dim1;
21412
i__4 = i__;
21413
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
21414
i__4].i, z__2.i = a[i__3].r * x[i__4].i +
21415
a[i__3].i * x[i__4].r;
21416
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21417
z__2.i;
21418
temp.r = z__1.r, temp.i = z__1.i;
21419
/* L90: */
21420
}
21421
if (nounit) {
21422
z_div(&z__1, &temp, &a[j + j * a_dim1]);
21423
temp.r = z__1.r, temp.i = z__1.i;
21424
}
21425
} else {
21426
i__2 = j - 1;
21427
for (i__ = 1; i__ <= i__2; ++i__) {
21428
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
21429
i__3 = i__;
21430
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
21431
z__2.i = z__3.r * x[i__3].i + z__3.i * x[
21432
i__3].r;
21433
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21434
z__2.i;
21435
temp.r = z__1.r, temp.i = z__1.i;
21436
/* L100: */
21437
}
21438
if (nounit) {
21439
d_cnjg(&z__2, &a[j + j * a_dim1]);
21440
z_div(&z__1, &temp, &z__2);
21441
temp.r = z__1.r, temp.i = z__1.i;
21442
}
21443
}
21444
i__2 = j;
21445
x[i__2].r = temp.r, x[i__2].i = temp.i;
21446
/* L110: */
21447
}
21448
} else {
21449
jx = kx;
21450
i__1 = *n;
21451
for (j = 1; j <= i__1; ++j) {
21452
ix = kx;
21453
i__2 = jx;
21454
temp.r = x[i__2].r, temp.i = x[i__2].i;
21455
if (noconj) {
21456
i__2 = j - 1;
21457
for (i__ = 1; i__ <= i__2; ++i__) {
21458
i__3 = i__ + j * a_dim1;
21459
i__4 = ix;
21460
z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
21461
i__4].i, z__2.i = a[i__3].r * x[i__4].i +
21462
a[i__3].i * x[i__4].r;
21463
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21464
z__2.i;
21465
temp.r = z__1.r, temp.i = z__1.i;
21466
ix += *incx;
21467
/* L120: */
21468
}
21469
if (nounit) {
21470
z_div(&z__1, &temp, &a[j + j * a_dim1]);
21471
temp.r = z__1.r, temp.i = z__1.i;
21472
}
21473
} else {
21474
i__2 = j - 1;
21475
for (i__ = 1; i__ <= i__2; ++i__) {
21476
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
21477
i__3 = ix;
21478
z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i,
21479
z__2.i = z__3.r * x[i__3].i + z__3.i * x[
21480
i__3].r;
21481
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21482
z__2.i;
21483
temp.r = z__1.r, temp.i = z__1.i;
21484
ix += *incx;
21485
/* L130: */
21486
}
21487
if (nounit) {
21488
d_cnjg(&z__2, &a[j + j * a_dim1]);
21489
z_div(&z__1, &temp, &z__2);
21490
temp.r = z__1.r, temp.i = z__1.i;
21491
}
21492
}
21493
i__2 = jx;
21494
x[i__2].r = temp.r, x[i__2].i = temp.i;
21495
jx += *incx;
21496
/* L140: */
21497
}
21498
}
21499
} else {
21500
if (*incx == 1) {
21501
for (j = *n; j >= 1; --j) {
21502
i__1 = j;
21503
temp.r = x[i__1].r, temp.i = x[i__1].i;
21504
if (noconj) {
21505
i__1 = j + 1;
21506
for (i__ = *n; i__ >= i__1; --i__) {
21507
i__2 = i__ + j * a_dim1;
21508
i__3 = i__;
21509
z__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
21510
i__3].i, z__2.i = a[i__2].r * x[i__3].i +
21511
a[i__2].i * x[i__3].r;
21512
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21513
z__2.i;
21514
temp.r = z__1.r, temp.i = z__1.i;
21515
/* L150: */
21516
}
21517
if (nounit) {
21518
z_div(&z__1, &temp, &a[j + j * a_dim1]);
21519
temp.r = z__1.r, temp.i = z__1.i;
21520
}
21521
} else {
21522
i__1 = j + 1;
21523
for (i__ = *n; i__ >= i__1; --i__) {
21524
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
21525
i__2 = i__;
21526
z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i,
21527
z__2.i = z__3.r * x[i__2].i + z__3.i * x[
21528
i__2].r;
21529
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21530
z__2.i;
21531
temp.r = z__1.r, temp.i = z__1.i;
21532
/* L160: */
21533
}
21534
if (nounit) {
21535
d_cnjg(&z__2, &a[j + j * a_dim1]);
21536
z_div(&z__1, &temp, &z__2);
21537
temp.r = z__1.r, temp.i = z__1.i;
21538
}
21539
}
21540
i__1 = j;
21541
x[i__1].r = temp.r, x[i__1].i = temp.i;
21542
/* L170: */
21543
}
21544
} else {
21545
kx += (*n - 1) * *incx;
21546
jx = kx;
21547
for (j = *n; j >= 1; --j) {
21548
ix = kx;
21549
i__1 = jx;
21550
temp.r = x[i__1].r, temp.i = x[i__1].i;
21551
if (noconj) {
21552
i__1 = j + 1;
21553
for (i__ = *n; i__ >= i__1; --i__) {
21554
i__2 = i__ + j * a_dim1;
21555
i__3 = ix;
21556
z__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
21557
i__3].i, z__2.i = a[i__2].r * x[i__3].i +
21558
a[i__2].i * x[i__3].r;
21559
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21560
z__2.i;
21561
temp.r = z__1.r, temp.i = z__1.i;
21562
ix -= *incx;
21563
/* L180: */
21564
}
21565
if (nounit) {
21566
z_div(&z__1, &temp, &a[j + j * a_dim1]);
21567
temp.r = z__1.r, temp.i = z__1.i;
21568
}
21569
} else {
21570
i__1 = j + 1;
21571
for (i__ = *n; i__ >= i__1; --i__) {
21572
d_cnjg(&z__3, &a[i__ + j * a_dim1]);
21573
i__2 = ix;
21574
z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i,
21575
z__2.i = z__3.r * x[i__2].i + z__3.i * x[
21576
i__2].r;
21577
z__1.r = temp.r - z__2.r, z__1.i = temp.i -
21578
z__2.i;
21579
temp.r = z__1.r, temp.i = z__1.i;
21580
ix -= *incx;
21581
/* L190: */
21582
}
21583
if (nounit) {
21584
d_cnjg(&z__2, &a[j + j * a_dim1]);
21585
z_div(&z__1, &temp, &z__2);
21586
temp.r = z__1.r, temp.i = z__1.i;
21587
}
21588
}
21589
i__1 = jx;
21590
x[i__1].r = temp.r, x[i__1].i = temp.i;
21591
jx -= *incx;
21592
/* L200: */
21593
}
21594
}
21595
}
21596
}
21597
21598
return 0;
21599
21600
/* End of ZTRSV . */
21601
21602
} /* ztrsv_ */
21603
21604
21605