Debian Codegraph @

native/deprecated/expokit/blas.f

raw symbols SCIP
1 * Subset of BLAS routines used by EXPOKIT.
2 * This file is supplied in case BLAS is not installed in your
3 * environment.
4 *----------------------------------------------------------------------|
5 SUBROUTINE XERBLA ( SRNAME, INFO )
6 * .. Scalar Arguments ..
7 INTEGER INFO
8 CHARACTER*6 SRNAME
9 * ..
10 *
11 * Purpose
12 * =======
13 *
14 * XERBLA is an error handler for the Level 2 BLAS routines.
15 *
16 * It is called by the Level 2 BLAS routines if an input parameter is
17 * invalid.
18 *
19 * Installers should consider modifying the STOP statement in order to
20 * call system-specific exception-handling facilities.
21 *
22 * Parameters
23 * ==========
24 *
25 * SRNAME - CHARACTER*6.
26 * On entry, SRNAME specifies the name of the routine which
27 * called XERBLA.
28 *
29 * INFO - INTEGER.
30 * On entry, INFO specifies the position of the invalid
31 * parameter in the parameter-list of the calling routine.
32 *
33 *
34 * Auxiliary routine for Level 2 Blas.
35 *
36 * Written on 20-July-1986.
37 *
38 * .. Executable Statements ..
39 *
40 WRITE (*,99999) SRNAME, INFO
41 *
42 STOP
43 *
44 99999 FORMAT ( ' ** On entry to ', A6, ' parameter number ', I2,
45 $ ' had an illegal value' )
46 *
47 * End of XERBLA.
48 *
49 END
50 *----------------------------------------------------------------------|
51 LOGICAL FUNCTION LSAME( CA, CB )
52 *
53 * -- LAPACK auxiliary routine (version 1.1) --
54 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
55 * Courant Institute, Argonne National Lab, and Rice University
56 * February 29, 1992
57 *
58 * .. Scalar Arguments ..
59 CHARACTER CA, CB
60 * ..
61 *
62 * Purpose
63 * =======
64 *
65 * LSAME returns .TRUE. if CA is the same letter as CB regardless of
66 * case.
67 *
68 * Arguments
69 * =========
70 *
71 * CA (input) CHARACTER*1
72 * CB (input) CHARACTER*1
73 * CA and CB specify the single characters to be compared.
74 *
75 * .. Intrinsic Functions ..
76 INTRINSIC ICHAR
77 * ..
78 * .. Local Scalars ..
79 INTEGER INTA, INTB, ZCODE
80 * ..
81 * .. Executable Statements ..
82 *
83 * Test if the characters are equal
84 *
85 LSAME = CA.EQ.CB
86 IF( LSAME )
87 $ RETURN
88 *
89 * Now test for equivalence if both characters are alphabetic.
90 *
91 ZCODE = ICHAR( 'Z' )
92 *
93 * Use 'Z' rather than 'A' so that ASCII can be detected on Prime
94 * machines, on which ICHAR returns a value with bit 8 set.
95 * ICHAR('A') on Prime machines returns 193 which is the same as
96 * ICHAR('A') on an EBCDIC machine.
97 *
98 INTA = ICHAR( CA )
99 INTB = ICHAR( CB )
100 *
101 IF( ZCODE.EQ.90 .OR. ZCODE.EQ.122 ) THEN
102 *
103 * ASCII is assumed - ZCODE is the ASCII code of either lower or
104 * upper case 'Z'.
105 *
106 IF( INTA.GE.97 .AND. INTA.LE.122 ) INTA = INTA - 32
107 IF( INTB.GE.97 .AND. INTB.LE.122 ) INTB = INTB - 32
108 *
109 ELSE IF( ZCODE.EQ.233 .OR. ZCODE.EQ.169 ) THEN
110 *
111 * EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or
112 * upper case 'Z'.
113 *
114 IF( INTA.GE.129 .AND. INTA.LE.137 .OR.
115 $ INTA.GE.145 .AND. INTA.LE.153 .OR.
116 $ INTA.GE.162 .AND. INTA.LE.169 ) INTA = INTA + 64
117 IF( INTB.GE.129 .AND. INTB.LE.137 .OR.
118 $ INTB.GE.145 .AND. INTB.LE.153 .OR.
119 $ INTB.GE.162 .AND. INTB.LE.169 ) INTB = INTB + 64
120 *
121 ELSE IF( ZCODE.EQ.218 .OR. ZCODE.EQ.250 ) THEN
122 *
123 * ASCII is assumed, on Prime machines - ZCODE is the ASCII code
124 * plus 128 of either lower or upper case 'Z'.
125 *
126 IF( INTA.GE.225 .AND. INTA.LE.250 ) INTA = INTA - 32
127 IF( INTB.GE.225 .AND. INTB.LE.250 ) INTB = INTB - 32
128 END IF
129 LSAME = INTA.EQ.INTB
130 *
131 * RETURN
132 *
133 * End of LSAME
134 *
135 END
136 *----------------------------------------------------------------------|
137 double precision function dcabs1(z)
138 complex*16 z,zz
139 double precision t(2)
140 equivalence (zz,t(1))
141 zz = z
142 dcabs1 = dabs(t(1)) + dabs(t(2))
143 return
144 end
145 *----------------------------------------------------------------------|
146 subroutine zaxpy(n,za,zx,incx,zy,incy)
147 c
148 c constant times a vector plus a vector.
149 c jack dongarra, 3/11/78.
150 c
151 complex*16 zx(1),zy(1),za
152 double precision dcabs1
153 if(n.le.0)return
154 if (dcabs1(za) .eq. 0.0d0) return
155 if (incx.eq.1.and.incy.eq.1)go to 20
156 c
157 c code for unequal increments or equal increments
158 c not equal to 1
159 c
160 ix = 1
161 iy = 1
162 if(incx.lt.0)ix = (-n+1)*incx + 1
163 if(incy.lt.0)iy = (-n+1)*incy + 1
164 do 10 i = 1,n
165 zy(iy) = zy(iy) + za*zx(ix)
166 ix = ix + incx
167 iy = iy + incy
168 10 continue
169 return
170 c
171 c code for both increments equal to 1
172 c
173 20 do 30 i = 1,n
174 zy(i) = zy(i) + za*zx(i)
175 30 continue
176 return
177 end
178 *----------------------------------------------------------------------|
179 integer function idamax(n,dx,incx)
180 c
181 c finds the index of element having max. absolute value.
182 c jack dongarra, linpack, 3/11/78.
183 c modified 3/93 to return if incx .le. 0.
184 c
185 double precision dx(1),dmax
186 integer i,incx,ix,n
187 c
188 idamax = 0
189 if( n.lt.1 .or. incx.le.0 ) return
190 idamax = 1
191 if(n.eq.1)return
192 if(incx.eq.1)go to 20
193 c
194 c code for increment not equal to 1
195 c
196 ix = 1
197 dmax = dabs(dx(1))
198 ix = ix + incx
199 do 10 i = 2,n
200 if(dabs(dx(ix)).le.dmax) go to 5
201 idamax = i
202 dmax = dabs(dx(ix))
203 5 ix = ix + incx
204 10 continue
205 return
206 c
207 c code for increment equal to 1
208 c
209 20 dmax = dabs(dx(1))
210 do 30 i = 2,n
211 if(dabs(dx(i)).le.dmax) go to 30
212 idamax = i
213 dmax = dabs(dx(i))
214 30 continue
215 return
216 end
217 *----------------------------------------------------------------------|
218 double precision function dasum(n,dx,incx)
219 c
220 c takes the sum of the absolute values.
221 c jack dongarra, linpack, 3/11/78.
222 c modified 3/93 to return if incx .le. 0.
223 c
224 double precision dx(1),dtemp
225 integer i,incx,m,mp1,n,nincx
226 c
227 dasum = 0.0d0
228 dtemp = 0.0d0
229 if( n.le.0 .or. incx.le.0 )return
230 if(incx.eq.1)go to 20
231 c
232 c code for increment not equal to 1
233 c
234 nincx = n*incx
235 do 10 i = 1,nincx,incx
236 dtemp = dtemp + dabs(dx(i))
237 10 continue
238 dasum = dtemp
239 return
240 c
241 c code for increment equal to 1
242 c
243 c
244 c clean-up loop
245 c
246 20 m = mod(n,6)
247 if( m .eq. 0 ) go to 40
248 do 30 i = 1,m
249 dtemp = dtemp + dabs(dx(i))
250 30 continue
251 if( n .lt. 6 ) go to 60
252 40 mp1 = m + 1
253 do 50 i = mp1,n,6
254 dtemp = dtemp + dabs(dx(i)) + dabs(dx(i + 1)) + dabs(dx(i + 2))
255 * + dabs(dx(i + 3)) + dabs(dx(i + 4)) + dabs(dx(i + 5))
256 50 continue
257 60 dasum = dtemp
258 return
259 end
260 *----------------------------------------------------------------------|
261 subroutine dscal(n,da,dx,incx)
262 c
263 c scales a vector by a constant.
264 c uses unrolled loops for increment equal to one.
265 c jack dongarra, linpack, 3/11/78.
266 c modified 3/93 to return if incx .le. 0.
267 c
268 double precision da,dx(1)
269 integer i,incx,m,mp1,n,nincx
270 c
271 if( n.le.0 .or. incx.le.0 )return
272 if(incx.eq.1)go to 20
273 c
274 c code for increment not equal to 1
275 c
276 nincx = n*incx
277 do 10 i = 1,nincx,incx
278 dx(i) = da*dx(i)
279 10 continue
280 return
281 c
282 c code for increment equal to 1
283 c
284 c
285 c clean-up loop
286 c
287 20 m = mod(n,5)
288 if( m .eq. 0 ) go to 40
289 do 30 i = 1,m
290 dx(i) = da*dx(i)
291 30 continue
292 if( n .lt. 5 ) return
293 40 mp1 = m + 1
294 do 50 i = mp1,n,5
295 dx(i) = da*dx(i)
296 dx(i + 1) = da*dx(i + 1)
297 dx(i + 2) = da*dx(i + 2)
298 dx(i + 3) = da*dx(i + 3)
299 dx(i + 4) = da*dx(i + 4)
300 50 continue
301 return
302 end
303 *----------------------------------------------------------------------|
304 subroutine dcopy(n,dx,incx,dy,incy)
305 c
306 c copies a vector, x, to a vector, y.
307 c uses unrolled loops for increments equal to one.
308 c jack dongarra, linpack, 3/11/78.
309 c
310 double precision dx(1),dy(1)
311 integer i,incx,incy,ix,iy,m,mp1,n
312 c
313 if(n.le.0)return
314 if(incx.eq.1.and.incy.eq.1)go to 20
315 c
316 c code for unequal increments or equal increments
317 c not equal to 1
318 c
319 ix = 1
320 iy = 1
321 if(incx.lt.0)ix = (-n+1)*incx + 1
322 if(incy.lt.0)iy = (-n+1)*incy + 1
323 do 10 i = 1,n
324 dy(iy) = dx(ix)
325 ix = ix + incx
326 iy = iy + incy
327 10 continue
328 return
329 c
330 c code for both increments equal to 1
331 c
332 c
333 c clean-up loop
334 c
335 20 m = mod(n,7)
336 if( m .eq. 0 ) go to 40
337 do 30 i = 1,m
338 dy(i) = dx(i)
339 30 continue
340 if( n .lt. 7 ) return
341 40 mp1 = m + 1
342 do 50 i = mp1,n,7
343 dy(i) = dx(i)
344 dy(i + 1) = dx(i + 1)
345 dy(i + 2) = dx(i + 2)
346 dy(i + 3) = dx(i + 3)
347 dy(i + 4) = dx(i + 4)
348 dy(i + 5) = dx(i + 5)
349 dy(i + 6) = dx(i + 6)
350 50 continue
351 return
352 end
353 *----------------------------------------------------------------------|
354 double precision function dnrm2 ( n, dx, incx)
355 integer i, incx, ix, j, n, next
356 double precision dx(1), cutlo, cuthi, hitest, sum, xmax,zero,one
357 data zero, one /0.0d0, 1.0d0/
358 c
359 c euclidean norm of the n-vector stored in dx() with storage
360 c increment incx .
361 c if n .le. 0 return with result = 0.
362 c if n .ge. 1 then incx must be .ge. 1
363 c
364 c c.l.lawson, 1978 jan 08
365 c modified to correct failure to update ix, 1/25/92.
366 c modified 3/93 to return if incx .le. 0.
367 c
368 c four phase method using two built-in constants that are
369 c hopefully applicable to all machines.
370 c cutlo = maximum of dsqrt(u/eps) over all known machines.
371 c cuthi = minimum of dsqrt(v) over all known machines.
372 c where
373 c eps = smallest no. such that eps + 1. .gt. 1.
374 c u = smallest positive no. (underflow limit)
375 c v = largest no. (overflow limit)
376 c
377 c brief outline of algorithm..
378 c
379 c phase 1 scans zero components.
380 c move to phase 2 when a component is nonzero and .le. cutlo
381 c move to phase 3 when a component is .gt. cutlo
382 c move to phase 4 when a component is .ge. cuthi/m
383 c where m = n for x() real and m = 2*n for complex.
384 c
385 c values for cutlo and cuthi..
386 c from the environmental parameters listed in the imsl converter
387 c document the limiting values are as follows..
388 c cutlo, s.p. u/eps = 2**(-102) for honeywell. close seconds are
389 c univac and dec at 2**(-103)
390 c thus cutlo = 2**(-51) = 4.44089e-16
391 c cuthi, s.p. v = 2**127 for univac, honeywell, and dec.
392 c thus cuthi = 2**(63.5) = 1.30438e19
393 c cutlo, d.p. u/eps = 2**(-67) for honeywell and dec.
394 c thus cutlo = 2**(-33.5) = 8.23181d-11
395 c cuthi, d.p. same as s.p. cuthi = 1.30438d19
396 c data cutlo, cuthi / 8.232d-11, 1.304d19 /
397 c data cutlo, cuthi / 4.441e-16, 1.304e19 /
398 data cutlo, cuthi / 8.232d-11, 1.304d19 /
399 c
400 if(n .gt. 0 .and. incx.gt.0) go to 10
401 dnrm2 = zero
402 go to 300
403 c
404 10 assign 30 to next
405 sum = zero
406 i = 1
407 ix = 1
408 c begin main loop
409 20 go to next,(30, 50, 70, 110)
410 30 if( dabs(dx(i)) .gt. cutlo) go to 85
411 assign 50 to next
412 xmax = zero
413 c
414 c phase 1. sum is zero
415 c
416 50 if( dx(i) .eq. zero) go to 200
417 if( dabs(dx(i)) .gt. cutlo) go to 85
418 c
419 c prepare for phase 2.
420 assign 70 to next
421 go to 105
422 c
423 c prepare for phase 4.
424 c
425 100 continue
426 ix = j
427 assign 110 to next
428 sum = (sum / dx(i)) / dx(i)
429 105 xmax = dabs(dx(i))
430 go to 115
431 c
432 c phase 2. sum is small.
433 c scale to avoid destructive underflow.
434 c
435 70 if( dabs(dx(i)) .gt. cutlo ) go to 75
436 c
437 c common code for phases 2 and 4.
438 c in phase 4 sum is large. scale to avoid overflow.
439 c
440 110 if( dabs(dx(i)) .le. xmax ) go to 115
441 sum = one + sum * (xmax / dx(i))**2
442 xmax = dabs(dx(i))
443 go to 200
444 c
445 115 sum = sum + (dx(i)/xmax)**2
446 go to 200
447 c
448 c
449 c prepare for phase 3.
450 c
451 75 sum = (sum * xmax) * xmax
452 c
453 c
454 c for real or d.p. set hitest = cuthi/n
455 c for complex set hitest = cuthi/(2*n)
456 c
457 85 hitest = cuthi/float( n )
458 c
459 c phase 3. sum is mid-range. no scaling.
460 c
461 do 95 j = ix,n
462 if(dabs(dx(i)) .ge. hitest) go to 100
463 sum = sum + dx(i)**2
464 i = i + incx
465 95 continue
466 dnrm2 = dsqrt( sum )
467 go to 300
468 c
469 200 continue
470 ix = ix + 1
471 i = i + incx
472 if( ix .le. n ) go to 20
473 c
474 c end of main loop.
475 c
476 c compute square root and adjust for scaling.
477 c
478 dnrm2 = xmax * dsqrt(sum)
479 300 continue
480 return
481 end
482 *----------------------------------------------------------------------|
483 double precision function ddot(n,dx,incx,dy,incy)
484 c
485 c forms the dot product of two vectors.
486 c uses unrolled loops for increments equal to one.
487 c jack dongarra, linpack, 3/11/78.
488 c
489 double precision dx(1),dy(1),dtemp
490 integer i,incx,incy,ix,iy,m,mp1,n
491 c
492 ddot = 0.0d0
493 dtemp = 0.0d0
494 if(n.le.0)return
495 if(incx.eq.1.and.incy.eq.1)go to 20
496 c
497 c code for unequal increments or equal increments
498 c not equal to 1
499 c
500 ix = 1
501 iy = 1
502 if(incx.lt.0)ix = (-n+1)*incx + 1
503 if(incy.lt.0)iy = (-n+1)*incy + 1
504 do 10 i = 1,n
505 dtemp = dtemp + dx(ix)*dy(iy)
506 ix = ix + incx
507 iy = iy + incy
508 10 continue
509 ddot = dtemp
510 return
511 c
512 c code for both increments equal to 1
513 c
514 c
515 c clean-up loop
516 c
517 20 m = mod(n,5)
518 if( m .eq. 0 ) go to 40
519 do 30 i = 1,m
520 dtemp = dtemp + dx(i)*dy(i)
521 30 continue
522 if( n .lt. 5 ) go to 60
523 40 mp1 = m + 1
524 do 50 i = mp1,n,5
525 dtemp = dtemp + dx(i)*dy(i) + dx(i + 1)*dy(i + 1) +
526 * dx(i + 2)*dy(i + 2) + dx(i + 3)*dy(i + 3) + dx(i + 4)*dy(i + 4)
527 50 continue
528 60 ddot = dtemp
529 return
530 end
531 *----------------------------------------------------------------------|
532 subroutine daxpy(n,da,dx,incx,dy,incy)
533 c
534 c constant times a vector plus a vector.
535 c uses unrolled loops for increments equal to one.
536 c jack dongarra, linpack, 3/11/78.
537 c
538 double precision dx(1),dy(1),da
539 integer i,incx,incy,ix,iy,m,mp1,n
540 c
541 if(n.le.0)return
542 if (da .eq. 0.0d0) return
543 if(incx.eq.1.and.incy.eq.1)go to 20
544 c
545 c code for unequal increments or equal increments
546 c not equal to 1
547 c
548 ix = 1
549 iy = 1
550 if(incx.lt.0)ix = (-n+1)*incx + 1
551 if(incy.lt.0)iy = (-n+1)*incy + 1
552 do 10 i = 1,n
553 dy(iy) = dy(iy) + da*dx(ix)
554 ix = ix + incx
555 iy = iy + incy
556 10 continue
557 return
558 c
559 c code for both increments equal to 1
560 c
561 c
562 c clean-up loop
563 c
564 20 m = mod(n,4)
565 if( m .eq. 0 ) go to 40
566 do 30 i = 1,m
567 dy(i) = dy(i) + da*dx(i)
568 30 continue
569 if( n .lt. 4 ) return
570 40 mp1 = m + 1
571 do 50 i = mp1,n,4
572 dy(i) = dy(i) + da*dx(i)
573 dy(i + 1) = dy(i + 1) + da*dx(i + 1)
574 dy(i + 2) = dy(i + 2) + da*dx(i + 2)
575 dy(i + 3) = dy(i + 3) + da*dx(i + 3)
576 50 continue
577 return
578 end
579 *----------------------------------------------------------------------|
580 subroutine zswap (n,zx,incx,zy,incy)
581 c
582 c interchanges two vectors.
583 c jack dongarra, 3/11/78.
584 c
585 complex*16 zx(1),zy(1),ztemp
586 c
587 if(n.le.0)return
588 if(incx.eq.1.and.incy.eq.1)go to 20
589 c
590 c code for unequal increments or equal increments not equal
591 c to 1
592 c
593 ix = 1
594 iy = 1
595 if(incx.lt.0)ix = (-n+1)*incx + 1
596 if(incy.lt.0)iy = (-n+1)*incy + 1
597 do 10 i = 1,n
598 ztemp = zx(ix)
599 zx(ix) = zy(iy)
600 zy(iy) = ztemp
601 ix = ix + incx
602 iy = iy + incy
603 10 continue
604 return
605 c
606 c code for both increments equal to 1
607 20 do 30 i = 1,n
608 ztemp = zx(i)
609 zx(i) = zy(i)
610 zy(i) = ztemp
611 30 continue
612 return
613 end
614 *----------------------------------------------------------------------|
615 SUBROUTINE DGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX,
616 $ BETA, Y, INCY )
617 * .. Scalar Arguments ..
618 DOUBLE PRECISION ALPHA, BETA
619 INTEGER INCX, INCY, LDA, M, N
620 CHARACTER*1 TRANS
621 * .. Array Arguments ..
622 DOUBLE PRECISION A( LDA, * ), X( * ), Y( * )
623 * ..
624 *
625 * Purpose
626 * =======
627 *
628 * DGEMV performs one of the matrix-vector operations
629 *
630 * y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
631 *
632 * where alpha and beta are scalars, x and y are vectors and A is an
633 * m by n matrix.
634 *
635 * Parameters
636 * ==========
637 *
638 * TRANS - CHARACTER*1.
639 * On entry, TRANS specifies the operation to be performed as
640 * follows:
641 *
642 * TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
643 *
644 * TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
645 *
646 * TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
647 *
648 * Unchanged on exit.
649 *
650 * M - INTEGER.
651 * On entry, M specifies the number of rows of the matrix A.
652 * M must be at least zero.
653 * Unchanged on exit.
654 *
655 * N - INTEGER.
656 * On entry, N specifies the number of columns of the matrix A.
657 * N must be at least zero.
658 * Unchanged on exit.
659 *
660 * ALPHA - DOUBLE PRECISION.
661 * On entry, ALPHA specifies the scalar alpha.
662 * Unchanged on exit.
663 *
664 * A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
665 * Before entry, the leading m by n part of the array A must
666 * contain the matrix of coefficients.
667 * Unchanged on exit.
668 *
669 * LDA - INTEGER.
670 * On entry, LDA specifies the first dimension of A as declared
671 * in the calling (sub) program. LDA must be at least
672 * max( 1, m ).
673 * Unchanged on exit.
674 *
675 * X - DOUBLE PRECISION array of DIMENSION at least
676 * ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
677 * and at least
678 * ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
679 * Before entry, the incremented array X must contain the
680 * vector x.
681 * Unchanged on exit.
682 *
683 * INCX - INTEGER.
684 * On entry, INCX specifies the increment for the elements of
685 * X. INCX must not be zero.
686 * Unchanged on exit.
687 *
688 * BETA - DOUBLE PRECISION.
689 * On entry, BETA specifies the scalar beta. When BETA is
690 * supplied as zero then Y need not be set on input.
691 * Unchanged on exit.
692 *
693 * Y - DOUBLE PRECISION array of DIMENSION at least
694 * ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
695 * and at least
696 * ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
697 * Before entry with BETA non-zero, the incremented array Y
698 * must contain the vector y. On exit, Y is overwritten by the
699 * updated vector y.
700 *
701 * INCY - INTEGER.
702 * On entry, INCY specifies the increment for the elements of
703 * Y. INCY must not be zero.
704 * Unchanged on exit.
705 *
706 *
707 * Level 2 Blas routine.
708 *
709 * -- Written on 22-October-1986.
710 * Jack Dongarra, Argonne National Lab.
711 * Jeremy Du Croz, Nag Central Office.
712 * Sven Hammarling, Nag Central Office.
713 * Richard Hanson, Sandia National Labs.
714 *
715 *
716 * .. Parameters ..
717 DOUBLE PRECISION ONE , ZERO
718 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
719 * .. Local Scalars ..
720 DOUBLE PRECISION TEMP
721 INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY, LENX, LENY
722 * .. External Functions ..
723 LOGICAL LSAME
724 EXTERNAL LSAME
725 * .. External Subroutines ..
726 EXTERNAL XERBLA
727 * .. Intrinsic Functions ..
728 INTRINSIC MAX
729 * ..
730 * .. Executable Statements ..
731 *
732 * Test the input parameters.
733 *
734 INFO = 0
735 IF ( .NOT.LSAME( TRANS, 'N' ).AND.
736 $ .NOT.LSAME( TRANS, 'T' ).AND.
737 $ .NOT.LSAME( TRANS, 'C' ) )THEN
738 INFO = 1
739 ELSE IF( M.LT.0 )THEN
740 INFO = 2
741 ELSE IF( N.LT.0 )THEN
742 INFO = 3
743 ELSE IF( LDA.LT.MAX( 1, M ) )THEN
744 INFO = 6
745 ELSE IF( INCX.EQ.0 )THEN
746 INFO = 8
747 ELSE IF( INCY.EQ.0 )THEN
748 INFO = 11
749 END IF
750 IF( INFO.NE.0 )THEN
751 CALL XERBLA( 'DGEMV ', INFO )
752 RETURN
753 END IF
754 *
755 * Quick return if possible.
756 *
757 IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
758 $ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
759 $ RETURN
760 *
761 * Set LENX and LENY, the lengths of the vectors x and y, and set
762 * up the start points in X and Y.
763 *
764 IF( LSAME( TRANS, 'N' ) )THEN
765 LENX = N
766 LENY = M
767 ELSE
768 LENX = M
769 LENY = N
770 END IF
771 IF( INCX.GT.0 )THEN
772 KX = 1
773 ELSE
774 KX = 1 - ( LENX - 1 )*INCX
775 END IF
776 IF( INCY.GT.0 )THEN
777 KY = 1
778 ELSE
779 KY = 1 - ( LENY - 1 )*INCY
780 END IF
781 *
782 * Start the operations. In this version the elements of A are
783 * accessed sequentially with one pass through A.
784 *
785 * First form y := beta*y.
786 *
787 IF( BETA.NE.ONE )THEN
788 IF( INCY.EQ.1 )THEN
789 IF( BETA.EQ.ZERO )THEN
790 DO 10, I = 1, LENY
791 Y( I ) = ZERO
792 10 CONTINUE
793 ELSE
794 DO 20, I = 1, LENY
795 Y( I ) = BETA*Y( I )
796 20 CONTINUE
797 END IF
798 ELSE
799 IY = KY
800 IF( BETA.EQ.ZERO )THEN
801 DO 30, I = 1, LENY
802 Y( IY ) = ZERO
803 IY = IY + INCY
804 30 CONTINUE
805 ELSE
806 DO 40, I = 1, LENY
807 Y( IY ) = BETA*Y( IY )
808 IY = IY + INCY
809 40 CONTINUE
810 END IF
811 END IF
812 END IF
813 IF( ALPHA.EQ.ZERO )
814 $ RETURN
815 IF( LSAME( TRANS, 'N' ) )THEN
816 *
817 * Form y := alpha*A*x + y.
818 *
819 JX = KX
820 IF( INCY.EQ.1 )THEN
821 DO 60, J = 1, N
822 IF( X( JX ).NE.ZERO )THEN
823 TEMP = ALPHA*X( JX )
824 DO 50, I = 1, M
825 Y( I ) = Y( I ) + TEMP*A( I, J )
826 50 CONTINUE
827 END IF
828 JX = JX + INCX
829 60 CONTINUE
830 ELSE
831 DO 80, J = 1, N
832 IF( X( JX ).NE.ZERO )THEN
833 TEMP = ALPHA*X( JX )
834 IY = KY
835 DO 70, I = 1, M
836 Y( IY ) = Y( IY ) + TEMP*A( I, J )
837 IY = IY + INCY
838 70 CONTINUE
839 END IF
840 JX = JX + INCX
841 80 CONTINUE
842 END IF
843 ELSE
844 *
845 * Form y := alpha*A'*x + y.
846 *
847 JY = KY
848 IF( INCX.EQ.1 )THEN
849 DO 100, J = 1, N
850 TEMP = ZERO
851 DO 90, I = 1, M
852 TEMP = TEMP + A( I, J )*X( I )
853 90 CONTINUE
854 Y( JY ) = Y( JY ) + ALPHA*TEMP
855 JY = JY + INCY
856 100 CONTINUE
857 ELSE
858 DO 120, J = 1, N
859 TEMP = ZERO
860 IX = KX
861 DO 110, I = 1, M
862 TEMP = TEMP + A( I, J )*X( IX )
863 IX = IX + INCX
864 110 CONTINUE
865 Y( JY ) = Y( JY ) + ALPHA*TEMP
866 JY = JY + INCY
867 120 CONTINUE
868 END IF
869 END IF
870 *
871 RETURN
872 *
873 * End of DGEMV .
874 *
875 END
876 *----------------------------------------------------------------------|
877 SUBROUTINE DGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB,
878 $ BETA, C, LDC )
879 * .. Scalar Arguments ..
880 CHARACTER*1 TRANSA, TRANSB
881 INTEGER M, N, K, LDA, LDB, LDC
882 DOUBLE PRECISION ALPHA, BETA
883 * .. Array Arguments ..
884 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * )
885 * ..
886 *
887 * Purpose
888 * =======
889 *
890 * DGEMM performs one of the matrix-matrix operations
891 *
892 * C := alpha*op( A )*op( B ) + beta*C,
893 *
894 * where op( X ) is one of
895 *
896 * op( X ) = X or op( X ) = X',
897 *
898 * alpha and beta are scalars, and A, B and C are matrices, with op( A )
899 * an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
900 *
901 * Parameters
902 * ==========
903 *
904 * TRANSA - CHARACTER*1.
905 * On entry, TRANSA specifies the form of op( A ) to be used in
906 * the matrix multiplication as follows:
907 *
908 * TRANSA = 'N' or 'n', op( A ) = A.
909 *
910 * TRANSA = 'T' or 't', op( A ) = A'.
911 *
912 * TRANSA = 'C' or 'c', op( A ) = A'.
913 *
914 * Unchanged on exit.
915 *
916 * TRANSB - CHARACTER*1.
917 * On entry, TRANSB specifies the form of op( B ) to be used in
918 * the matrix multiplication as follows:
919 *
920 * TRANSB = 'N' or 'n', op( B ) = B.
921 *
922 * TRANSB = 'T' or 't', op( B ) = B'.
923 *
924 * TRANSB = 'C' or 'c', op( B ) = B'.
925 *
926 * Unchanged on exit.
927 *
928 * M - INTEGER.
929 * On entry, M specifies the number of rows of the matrix
930 * op( A ) and of the matrix C. M must be at least zero.
931 * Unchanged on exit.
932 *
933 * N - INTEGER.
934 * On entry, N specifies the number of columns of the matrix
935 * op( B ) and the number of columns of the matrix C. N must be
936 * at least zero.
937 * Unchanged on exit.
938 *
939 * K - INTEGER.
940 * On entry, K specifies the number of columns of the matrix
941 * op( A ) and the number of rows of the matrix op( B ). K must
942 * be at least zero.
943 * Unchanged on exit.
944 *
945 * ALPHA - DOUBLE PRECISION.
946 * On entry, ALPHA specifies the scalar alpha.
947 * Unchanged on exit.
948 *
949 * A - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is
950 * k when TRANSA = 'N' or 'n', and is m otherwise.
951 * Before entry with TRANSA = 'N' or 'n', the leading m by k
952 * part of the array A must contain the matrix A, otherwise
953 * the leading k by m part of the array A must contain the
954 * matrix A.
955 * Unchanged on exit.
956 *
957 * LDA - INTEGER.
958 * On entry, LDA specifies the first dimension of A as declared
959 * in the calling (sub) program. When TRANSA = 'N' or 'n' then
960 * LDA must be at least max( 1, m ), otherwise LDA must be at
961 * least max( 1, k ).
962 * Unchanged on exit.
963 *
964 * B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is
965 * n when TRANSB = 'N' or 'n', and is k otherwise.
966 * Before entry with TRANSB = 'N' or 'n', the leading k by n
967 * part of the array B must contain the matrix B, otherwise
968 * the leading n by k part of the array B must contain the
969 * matrix B.
970 * Unchanged on exit.
971 *
972 * LDB - INTEGER.
973 * On entry, LDB specifies the first dimension of B as declared
974 * in the calling (sub) program. When TRANSB = 'N' or 'n' then
975 * LDB must be at least max( 1, k ), otherwise LDB must be at
976 * least max( 1, n ).
977 * Unchanged on exit.
978 *
979 * BETA - DOUBLE PRECISION.
980 * On entry, BETA specifies the scalar beta. When BETA is
981 * supplied as zero then C need not be set on input.
982 * Unchanged on exit.
983 *
984 * C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
985 * Before entry, the leading m by n part of the array C must
986 * contain the matrix C, except when beta is zero, in which
987 * case C need not be set on entry.
988 * On exit, the array C is overwritten by the m by n matrix
989 * ( alpha*op( A )*op( B ) + beta*C ).
990 *
991 * LDC - INTEGER.
992 * On entry, LDC specifies the first dimension of C as declared
993 * in the calling (sub) program. LDC must be at least
994 * max( 1, m ).
995 * Unchanged on exit.
996 *
997 *
998 * Level 3 Blas routine.
999 *
1000 * -- Written on 8-February-1989.
1001 * Jack Dongarra, Argonne National Laboratory.
1002 * Iain Duff, AERE Harwell.
1003 * Jeremy Du Croz, Numerical Algorithms Group Ltd.
1004 * Sven Hammarling, Numerical Algorithms Group Ltd.
1005 *
1006 *
1007 * .. External Functions ..
1008 LOGICAL LSAME
1009 EXTERNAL LSAME
1010 * .. External Subroutines ..
1011 EXTERNAL XERBLA
1012 * .. Intrinsic Functions ..
1013 INTRINSIC MAX
1014 * .. Local Scalars ..
1015 LOGICAL NOTA, NOTB
1016 INTEGER I, INFO, J, L, NCOLA, NROWA, NROWB
1017 DOUBLE PRECISION TEMP
1018 * .. Parameters ..
1019 DOUBLE PRECISION ONE , ZERO
1020 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
1021 * ..
1022 * .. Executable Statements ..
1023 *
1024 * Set NOTA and NOTB as true if A and B respectively are not
1025 * transposed and set NROWA, NCOLA and NROWB as the number of rows
1026 * and columns of A and the number of rows of B respectively.
1027 *
1028 NOTA = LSAME( TRANSA, 'N' )
1029 NOTB = LSAME( TRANSB, 'N' )
1030 IF( NOTA )THEN
1031 NROWA = M
1032 NCOLA = K
1033 ELSE
1034 NROWA = K
1035 NCOLA = M
1036 END IF
1037 IF( NOTB )THEN
1038 NROWB = K
1039 ELSE
1040 NROWB = N
1041 END IF
1042 *
1043 * Test the input parameters.
1044 *
1045 INFO = 0
1046 IF( ( .NOT.NOTA ).AND.
1047 $ ( .NOT.LSAME( TRANSA, 'C' ) ).AND.
1048 $ ( .NOT.LSAME( TRANSA, 'T' ) ) )THEN
1049 INFO = 1
1050 ELSE IF( ( .NOT.NOTB ).AND.
1051 $ ( .NOT.LSAME( TRANSB, 'C' ) ).AND.
1052 $ ( .NOT.LSAME( TRANSB, 'T' ) ) )THEN
1053 INFO = 2
1054 ELSE IF( M .LT.0 )THEN
1055 INFO = 3
1056 ELSE IF( N .LT.0 )THEN
1057 INFO = 4
1058 ELSE IF( K .LT.0 )THEN
1059 INFO = 5
1060 ELSE IF( LDA.LT.MAX( 1, NROWA ) )THEN
1061 INFO = 8
1062 ELSE IF( LDB.LT.MAX( 1, NROWB ) )THEN
1063 INFO = 10
1064 ELSE IF( LDC.LT.MAX( 1, M ) )THEN
1065 INFO = 13
1066 END IF
1067 IF( INFO.NE.0 )THEN
1068 CALL XERBLA( 'DGEMM ', INFO )
1069 RETURN
1070 END IF
1071 *
1072 * Quick return if possible.
1073 *
1074 IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
1075 $ ( ( ( ALPHA.EQ.ZERO ).OR.( K.EQ.0 ) ).AND.( BETA.EQ.ONE ) ) )
1076 $ RETURN
1077 *
1078 * And if alpha.eq.zero.
1079 *
1080 IF( ALPHA.EQ.ZERO )THEN
1081 IF( BETA.EQ.ZERO )THEN
1082 DO 20, J = 1, N
1083 DO 10, I = 1, M
1084 C( I, J ) = ZERO
1085 10 CONTINUE
1086 20 CONTINUE
1087 ELSE
1088 DO 40, J = 1, N
1089 DO 30, I = 1, M
1090 C( I, J ) = BETA*C( I, J )
1091 30 CONTINUE
1092 40 CONTINUE
1093 END IF
1094 RETURN
1095 END IF
1096 *
1097 * Start the operations.
1098 *
1099 IF( NOTB )THEN
1100 IF( NOTA )THEN
1101 *
1102 * Form C := alpha*A*B + beta*C.
1103 *
1104 DO 90, J = 1, N
1105 IF( BETA.EQ.ZERO )THEN
1106 DO 50, I = 1, M
1107 C( I, J ) = ZERO
1108 50 CONTINUE
1109 ELSE IF( BETA.NE.ONE )THEN
1110 DO 60, I = 1, M
1111 C( I, J ) = BETA*C( I, J )
1112 60 CONTINUE
1113 END IF
1114 DO 80, L = 1, K
1115 IF( B( L, J ).NE.ZERO )THEN
1116 TEMP = ALPHA*B( L, J )
1117 DO 70, I = 1, M
1118 C( I, J ) = C( I, J ) + TEMP*A( I, L )
1119 70 CONTINUE
1120 END IF
1121 80 CONTINUE
1122 90 CONTINUE
1123 ELSE
1124 *
1125 * Form C := alpha*A'*B + beta*C
1126 *
1127 DO 120, J = 1, N
1128 DO 110, I = 1, M
1129 TEMP = ZERO
1130 DO 100, L = 1, K
1131 TEMP = TEMP + A( L, I )*B( L, J )
1132 100 CONTINUE
1133 IF( BETA.EQ.ZERO )THEN
1134 C( I, J ) = ALPHA*TEMP
1135 ELSE
1136 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
1137 END IF
1138 110 CONTINUE
1139 120 CONTINUE
1140 END IF
1141 ELSE
1142 IF( NOTA )THEN
1143 *
1144 * Form C := alpha*A*B' + beta*C
1145 *
1146 DO 170, J = 1, N
1147 IF( BETA.EQ.ZERO )THEN
1148 DO 130, I = 1, M
1149 C( I, J ) = ZERO
1150 130 CONTINUE
1151 ELSE IF( BETA.NE.ONE )THEN
1152 DO 140, I = 1, M
1153 C( I, J ) = BETA*C( I, J )
1154 140 CONTINUE
1155 END IF
1156 DO 160, L = 1, K
1157 IF( B( J, L ).NE.ZERO )THEN
1158 TEMP = ALPHA*B( J, L )
1159 DO 150, I = 1, M
1160 C( I, J ) = C( I, J ) + TEMP*A( I, L )
1161 150 CONTINUE
1162 END IF
1163 160 CONTINUE
1164 170 CONTINUE
1165 ELSE
1166 *
1167 * Form C := alpha*A'*B' + beta*C
1168 *
1169 DO 200, J = 1, N
1170 DO 190, I = 1, M
1171 TEMP = ZERO
1172 DO 180, L = 1, K
1173 TEMP = TEMP + A( L, I )*B( J, L )
1174 180 CONTINUE
1175 IF( BETA.EQ.ZERO )THEN
1176 C( I, J ) = ALPHA*TEMP
1177 ELSE
1178 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
1179 END IF
1180 190 CONTINUE
1181 200 CONTINUE
1182 END IF
1183 END IF
1184 *
1185 RETURN
1186 *
1187 * End of DGEMM .
1188 *
1189 END
1190 *----------------------------------------------------------------------|
1191 *
1192 ************************************************************************
1193 *
1194 * File of the COMPLEX*16 Level-2 BLAS.
1195 * ==========================================
1196 *
1197 * SUBROUTINE ZGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX,
1198 * $ BETA, Y, INCY )
1199 *
1200 * SUBROUTINE ZGBMV ( TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX,
1201 * $ BETA, Y, INCY )
1202 *
1203 * SUBROUTINE ZHEMV ( UPLO, N, ALPHA, A, LDA, X, INCX,
1204 * $ BETA, Y, INCY )
1205 *
1206 * SUBROUTINE ZHBMV ( UPLO, N, K, ALPHA, A, LDA, X, INCX,
1207 * $ BETA, Y, INCY )
1208 *
1209 * SUBROUTINE ZHPMV ( UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY )
1210 *
1211 * SUBROUTINE ZTRMV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX )
1212 *
1213 * SUBROUTINE ZTBMV ( UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX )
1214 *
1215 * SUBROUTINE ZTPMV ( UPLO, TRANS, DIAG, N, AP, X, INCX )
1216 *
1217 * SUBROUTINE ZTRSV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX )
1218 *
1219 * SUBROUTINE ZTBSV ( UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX )
1220 *
1221 * SUBROUTINE ZTPSV ( UPLO, TRANS, DIAG, N, AP, X, INCX )
1222 *
1223 * SUBROUTINE ZGERU ( M, N, ALPHA, X, INCX, Y, INCY, A, LDA )
1224 *
1225 * SUBROUTINE ZGERC ( M, N, ALPHA, X, INCX, Y, INCY, A, LDA )
1226 *
1227 * SUBROUTINE ZHER ( UPLO, N, ALPHA, X, INCX, A, LDA )
1228 *
1229 * SUBROUTINE ZHPR ( UPLO, N, ALPHA, X, INCX, AP )
1230 *
1231 * SUBROUTINE ZHER2 ( UPLO, N, ALPHA, X, INCX, Y, INCY, A, LDA )
1232 *
1233 * SUBROUTINE ZHPR2 ( UPLO, N, ALPHA, X, INCX, Y, INCY, AP )
1234 *
1235 * See:
1236 *
1237 * Dongarra J. J., Du Croz J. J., Hammarling S. and Hanson R. J..
1238 * An extended set of Fortran Basic Linear Algebra Subprograms.
1239 *
1240 * Technical Memoranda Nos. 41 (revision 3) and 81, Mathematics
1241 * and Computer Science Division, Argonne National Laboratory,
1242 * 9700 South Cass Avenue, Argonne, Illinois 60439, US.
1243 *
1244 * Or
1245 *
1246 * NAG Technical Reports TR3/87 and TR4/87, Numerical Algorithms
1247 * Group Ltd., NAG Central Office, 256 Banbury Road, Oxford
1248 * OX2 7DE, UK, and Numerical Algorithms Group Inc., 1101 31st
1249 * Street, Suite 100, Downers Grove, Illinois 60515-1263, USA.
1250 *
1251 ************************************************************************
1252 *
1253 SUBROUTINE ZGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX,
1254 $ BETA, Y, INCY )
1255 * .. Scalar Arguments ..
1256 COMPLEX*16 ALPHA, BETA
1257 INTEGER INCX, INCY, LDA, M, N
1258 CHARACTER*1 TRANS
1259 * .. Array Arguments ..
1260 COMPLEX*16 A( LDA, * ), X( * ), Y( * )
1261 * ..
1262 *
1263 * Purpose
1264 * =======
1265 *
1266 * ZGEMV performs one of the matrix-vector operations
1267 *
1268 * y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or
1269 *
1270 * y := alpha*conjg( A' )*x + beta*y,
1271 *
1272 * where alpha and beta are scalars, x and y are vectors and A is an
1273 * m by n matrix.
1274 *
1275 * Parameters
1276 * ==========
1277 *
1278 * TRANS - CHARACTER*1.
1279 * On entry, TRANS specifies the operation to be performed as
1280 * follows:
1281 *
1282 * TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
1283 *
1284 * TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
1285 *
1286 * TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y.
1287 *
1288 * Unchanged on exit.
1289 *
1290 * M - INTEGER.
1291 * On entry, M specifies the number of rows of the matrix A.
1292 * M must be at least zero.
1293 * Unchanged on exit.
1294 *
1295 * N - INTEGER.
1296 * On entry, N specifies the number of columns of the matrix A.
1297 * N must be at least zero.
1298 * Unchanged on exit.
1299 *
1300 * ALPHA - COMPLEX*16 .
1301 * On entry, ALPHA specifies the scalar alpha.
1302 * Unchanged on exit.
1303 *
1304 * A - COMPLEX*16 array of DIMENSION ( LDA, n ).
1305 * Before entry, the leading m by n part of the array A must
1306 * contain the matrix of coefficients.
1307 * Unchanged on exit.
1308 *
1309 * LDA - INTEGER.
1310 * On entry, LDA specifies the first dimension of A as declared
1311 * in the calling (sub) program. LDA must be at least
1312 * max( 1, m ).
1313 * Unchanged on exit.
1314 *
1315 * X - COMPLEX*16 array of DIMENSION at least
1316 * ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
1317 * and at least
1318 * ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
1319 * Before entry, the incremented array X must contain the
1320 * vector x.
1321 * Unchanged on exit.
1322 *
1323 * INCX - INTEGER.
1324 * On entry, INCX specifies the increment for the elements of
1325 * X. INCX must not be zero.
1326 * Unchanged on exit.
1327 *
1328 * BETA - COMPLEX*16 .
1329 * On entry, BETA specifies the scalar beta. When BETA is
1330 * supplied as zero then Y need not be set on input.
1331 * Unchanged on exit.
1332 *
1333 * Y - COMPLEX*16 array of DIMENSION at least
1334 * ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
1335 * and at least
1336 * ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
1337 * Before entry with BETA non-zero, the incremented array Y
1338 * must contain the vector y. On exit, Y is overwritten by the
1339 * updated vector y.
1340 *
1341 * INCY - INTEGER.
1342 * On entry, INCY specifies the increment for the elements of
1343 * Y. INCY must not be zero.
1344 * Unchanged on exit.
1345 *
1346 *
1347 * Level 2 Blas routine.
1348 *
1349 * -- Written on 22-October-1986.
1350 * Jack Dongarra, Argonne National Lab.
1351 * Jeremy Du Croz, Nag Central Office.
1352 * Sven Hammarling, Nag Central Office.
1353 * Richard Hanson, Sandia National Labs.
1354 *
1355 *
1356 * .. Parameters ..
1357 COMPLEX*16 ONE
1358 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
1359 COMPLEX*16 ZERO
1360 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
1361 * .. Local Scalars ..
1362 COMPLEX*16 TEMP
1363 INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY, LENX, LENY
1364 LOGICAL NOCONJ
1365 * .. External Functions ..
1366 LOGICAL LSAME
1367 EXTERNAL LSAME
1368 * .. External Subroutines ..
1369 EXTERNAL XERBLA
1370 * .. Intrinsic Functions ..
1371 INTRINSIC DCONJG, MAX
1372 * ..
1373 * .. Executable Statements ..
1374 *
1375 * Test the input parameters.
1376 *
1377 INFO = 0
1378 IF ( .NOT.LSAME( TRANS, 'N' ).AND.
1379 $ .NOT.LSAME( TRANS, 'T' ).AND.
1380 $ .NOT.LSAME( TRANS, 'C' ) )THEN
1381 INFO = 1
1382 ELSE IF( M.LT.0 )THEN
1383 INFO = 2
1384 ELSE IF( N.LT.0 )THEN
1385 INFO = 3
1386 ELSE IF( LDA.LT.MAX( 1, M ) )THEN
1387 INFO = 6
1388 ELSE IF( INCX.EQ.0 )THEN
1389 INFO = 8
1390 ELSE IF( INCY.EQ.0 )THEN
1391 INFO = 11
1392 END IF
1393 IF( INFO.NE.0 )THEN
1394 CALL XERBLA( 'ZGEMV ', INFO )
1395 RETURN
1396 END IF
1397 *
1398 * Quick return if possible.
1399 *
1400 IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
1401 $ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
1402 $ RETURN
1403 *
1404 NOCONJ = LSAME( TRANS, 'T' )
1405 *
1406 * Set LENX and LENY, the lengths of the vectors x and y, and set
1407 * up the start points in X and Y.
1408 *
1409 IF( LSAME( TRANS, 'N' ) )THEN
1410 LENX = N
1411 LENY = M
1412 ELSE
1413 LENX = M
1414 LENY = N
1415 END IF
1416 IF( INCX.GT.0 )THEN
1417 KX = 1
1418 ELSE
1419 KX = 1 - ( LENX - 1 )*INCX
1420 END IF
1421 IF( INCY.GT.0 )THEN
1422 KY = 1
1423 ELSE
1424 KY = 1 - ( LENY - 1 )*INCY
1425 END IF
1426 *
1427 * Start the operations. In this version the elements of A are
1428 * accessed sequentially with one pass through A.
1429 *
1430 * First form y := beta*y.
1431 *
1432 IF( BETA.NE.ONE )THEN
1433 IF( INCY.EQ.1 )THEN
1434 IF( BETA.EQ.ZERO )THEN
1435 DO 10, I = 1, LENY
1436 Y( I ) = ZERO
1437 10 CONTINUE
1438 ELSE
1439 DO 20, I = 1, LENY
1440 Y( I ) = BETA*Y( I )
1441 20 CONTINUE
1442 END IF
1443 ELSE
1444 IY = KY
1445 IF( BETA.EQ.ZERO )THEN
1446 DO 30, I = 1, LENY
1447 Y( IY ) = ZERO
1448 IY = IY + INCY
1449 30 CONTINUE
1450 ELSE
1451 DO 40, I = 1, LENY
1452 Y( IY ) = BETA*Y( IY )
1453 IY = IY + INCY
1454 40 CONTINUE
1455 END IF
1456 END IF
1457 END IF
1458 IF( ALPHA.EQ.ZERO )
1459 $ RETURN
1460 IF( LSAME( TRANS, 'N' ) )THEN
1461 *
1462 * Form y := alpha*A*x + y.
1463 *
1464 JX = KX
1465 IF( INCY.EQ.1 )THEN
1466 DO 60, J = 1, N
1467 IF( X( JX ).NE.ZERO )THEN
1468 TEMP = ALPHA*X( JX )
1469 DO 50, I = 1, M
1470 Y( I ) = Y( I ) + TEMP*A( I, J )
1471 50 CONTINUE
1472 END IF
1473 JX = JX + INCX
1474 60 CONTINUE
1475 ELSE
1476 DO 80, J = 1, N
1477 IF( X( JX ).NE.ZERO )THEN
1478 TEMP = ALPHA*X( JX )
1479 IY = KY
1480 DO 70, I = 1, M
1481 Y( IY ) = Y( IY ) + TEMP*A( I, J )
1482 IY = IY + INCY
1483 70 CONTINUE
1484 END IF
1485 JX = JX + INCX
1486 80 CONTINUE
1487 END IF
1488 ELSE
1489 *
1490 * Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y.
1491 *
1492 JY = KY
1493 IF( INCX.EQ.1 )THEN
1494 DO 110, J = 1, N
1495 TEMP = ZERO
1496 IF( NOCONJ )THEN
1497 DO 90, I = 1, M
1498 TEMP = TEMP + A( I, J )*X( I )
1499 90 CONTINUE
1500 ELSE
1501 DO 100, I = 1, M
1502 TEMP = TEMP + DCONJG( A( I, J ) )*X( I )
1503 100 CONTINUE
1504 END IF
1505 Y( JY ) = Y( JY ) + ALPHA*TEMP
1506 JY = JY + INCY
1507 110 CONTINUE
1508 ELSE
1509 DO 140, J = 1, N
1510 TEMP = ZERO
1511 IX = KX
1512 IF( NOCONJ )THEN
1513 DO 120, I = 1, M
1514 TEMP = TEMP + A( I, J )*X( IX )
1515 IX = IX + INCX
1516 120 CONTINUE
1517 ELSE
1518 DO 130, I = 1, M
1519 TEMP = TEMP + DCONJG( A( I, J ) )*X( IX )
1520 IX = IX + INCX
1521 130 CONTINUE
1522 END IF
1523 Y( JY ) = Y( JY ) + ALPHA*TEMP
1524 JY = JY + INCY
1525 140 CONTINUE
1526 END IF
1527 END IF
1528 *
1529 RETURN
1530 *
1531 * End of ZGEMV .
1532 *
1533 END
1534 subroutine zcopy(n,zx,incx,zy,incy)
1535 c
1536 c copies a vector, x, to a vector, y.
1537 c jack dongarra, linpack, 4/11/78.
1538 c
1539 double complex zx(1),zy(1)
1540 integer i,incx,incy,ix,iy,n
1541 c
1542 if(n.le.0)return
1543 if(incx.eq.1.and.incy.eq.1)go to 20
1544 c
1545 c code for unequal increments or equal increments
1546 c not equal to 1
1547 c
1548 ix = 1
1549 iy = 1
1550 if(incx.lt.0)ix = (-n+1)*incx + 1
1551 if(incy.lt.0)iy = (-n+1)*incy + 1
1552 do 10 i = 1,n
1553 zy(iy) = zx(ix)
1554 ix = ix + incx
1555 iy = iy + incy
1556 10 continue
1557 return
1558 c
1559 c code for both increments equal to 1
1560 c
1561 20 do 30 i = 1,n
1562 zy(i) = zx(i)
1563 30 continue
1564 return
1565 end
1566 double precision function dznrm2( n, zx, incx)
1567 logical imag, scale
1568 integer i, incx, ix, n, next
1569 double precision cutlo, cuthi, hitest, sum, xmax, absx, zero, one
1570 double complex zx(1)
1571 double precision dreal,dimag
1572 double complex zdumr,zdumi
1573 dreal(zdumr) = zdumr
1574 dimag(zdumi) = (0.0d0,-1.0d0)*zdumi
1575 data zero, one /0.0d0, 1.0d0/
1576 c
1577 c unitary norm of the complex n-vector stored in zx() with storage
1578 c increment incx .
1579 c if n .le. 0 return with result = 0.
1580 c if n .ge. 1 then incx must be .ge. 1
1581 c
1582 c c.l.lawson , 1978 jan 08
1583 c modified 3/93 to return if incx .le. 0.
1584 c
1585 c four phase method using two built-in constants that are
1586 c hopefully applicable to all machines.
1587 c cutlo = maximum of sqrt(u/eps) over all known machines.
1588 c cuthi = minimum of sqrt(v) over all known machines.
1589 c where
1590 c eps = smallest no. such that eps + 1. .gt. 1.
1591 c u = smallest positive no. (underflow limit)
1592 c v = largest no. (overflow limit)
1593 c
1594 c brief outline of algorithm..
1595 c
1596 c phase 1 scans zero components.
1597 c move to phase 2 when a component is nonzero and .le. cutlo
1598 c move to phase 3 when a component is .gt. cutlo
1599 c move to phase 4 when a component is .ge. cuthi/m
1600 c where m = n for x() real and m = 2*n for complex.
1601 c
1602 c values for cutlo and cuthi..
1603 c from the environmental parameters listed in the imsl converter
1604 c document the limiting values are as follows..
1605 c cutlo, s.p. u/eps = 2**(-102) for honeywell. close seconds are
1606 c univac and dec at 2**(-103)
1607 c thus cutlo = 2**(-51) = 4.44089e-16
1608 c cuthi, s.p. v = 2**127 for univac, honeywell, and dec.
1609 c thus cuthi = 2**(63.5) = 1.30438e19
1610 c cutlo, d.p. u/eps = 2**(-67) for honeywell and dec.
1611 c thus cutlo = 2**(-33.5) = 8.23181d-11
1612 c cuthi, d.p. same as s.p. cuthi = 1.30438d19
1613 c data cutlo, cuthi / 8.232d-11, 1.304d19 /
1614 c data cutlo, cuthi / 4.441e-16, 1.304e19 /
1615 data cutlo, cuthi / 8.232d-11, 1.304d19 /
1616 c
1617 if(n .gt. 0 .and. incx.gt.0) go to 10
1618 dznrm2 = zero
1619 go to 300
1620 c
1621 10 assign 30 to next
1622 sum = zero
1623 i = 1
1624 c begin main loop
1625 do 220 ix = 1,n
1626 absx = dabs(dreal(zx(i)))
1627 imag = .false.
1628 go to next,(30, 50, 70, 90, 110)
1629 30 if( absx .gt. cutlo) go to 85
1630 assign 50 to next
1631 scale = .false.
1632 c
1633 c phase 1. sum is zero
1634 c
1635 50 if( absx .eq. zero) go to 200
1636 if( absx .gt. cutlo) go to 85
1637 c
1638 c prepare for phase 2.
1639 assign 70 to next
1640 go to 105
1641 c
1642 c prepare for phase 4.
1643 c
1644 100 assign 110 to next
1645 sum = (sum / absx) / absx
1646 105 scale = .true.
1647 xmax = absx
1648 go to 115
1649 c
1650 c phase 2. sum is small.
1651 c scale to avoid destructive underflow.
1652 c
1653 70 if( absx .gt. cutlo ) go to 75
1654 c
1655 c common code for phases 2 and 4.
1656 c in phase 4 sum is large. scale to avoid overflow.
1657 c
1658 110 if( absx .le. xmax ) go to 115
1659 sum = one + sum * (xmax / absx)**2
1660 xmax = absx
1661 go to 200
1662 c
1663 115 sum = sum + (absx/xmax)**2
1664 go to 200
1665 c
1666 c
1667 c prepare for phase 3.
1668 c
1669 75 sum = (sum * xmax) * xmax
1670 c
1671 85 assign 90 to next
1672 scale = .false.
1673 c
1674 c for real or d.p. set hitest = cuthi/n
1675 c for complex set hitest = cuthi/(2*n)
1676 c
1677 hitest = cuthi/dble( 2*n )
1678 c
1679 c phase 3. sum is mid-range. no scaling.
1680 c
1681 90 if(absx .ge. hitest) go to 100
1682 sum = sum + absx**2
1683 200 continue
1684 c control selection of real and imaginary parts.
1685 c
1686 if(imag) go to 210
1687 absx = dabs(dimag(zx(i)))
1688 imag = .true.
1689 go to next,( 50, 70, 90, 110 )
1690 c
1691 210 continue
1692 i = i + incx
1693 220 continue
1694 c
1695 c end of main loop.
1696 c compute square root and adjust for scaling.
1697 c
1698 dznrm2 = dsqrt(sum)
1699 if(scale) dznrm2 = dznrm2 * xmax
1700 300 continue
1701 return
1702 end
1703 *
1704 ************************************************************************
1705 *
1706 * File of the COMPLEX*16 Level-3 BLAS.
1707 * ==========================================
1708 *
1709 * SUBROUTINE ZGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB,
1710 * $ BETA, C, LDC )
1711 *
1712 * SUBROUTINE ZSYMM ( SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB,
1713 * $ BETA, C, LDC )
1714 *
1715 * SUBROUTINE ZHEMM ( SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB,
1716 * $ BETA, C, LDC )
1717 *
1718 * SUBROUTINE ZSYRK ( UPLO, TRANS, N, K, ALPHA, A, LDA,
1719 * $ BETA, C, LDC )
1720 *
1721 * SUBROUTINE ZHERK ( UPLO, TRANS, N, K, ALPHA, A, LDA,
1722 * $ BETA, C, LDC )
1723 *
1724 * SUBROUTINE ZSYR2K( UPLO, TRANS, N, K, ALPHA, A, LDA, B, LDB,
1725 * $ BETA, C, LDC )
1726 *
1727 * SUBROUTINE ZHER2K( UPLO, TRANS, N, K, ALPHA, A, LDA, B, LDB,
1728 * $ BETA, C, LDC )
1729 *
1730 * SUBROUTINE ZTRMM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA,
1731 * $ B, LDB )
1732 *
1733 * SUBROUTINE ZTRSM ( SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA,
1734 * $ B, LDB )
1735 *
1736 * See:
1737 *
1738 * Dongarra J. J., Du Croz J. J., Duff I. and Hammarling S.
1739 * A set of Level 3 Basic Linear Algebra Subprograms. Technical
1740 * Memorandum No.88 (Revision 1), Mathematics and Computer Science
1741 * Division, Argonne National Laboratory, 9700 South Cass Avenue,
1742 * Argonne, Illinois 60439.
1743 *
1744 *
1745 ************************************************************************
1746 *
1747 SUBROUTINE ZGEMM ( TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB,
1748 $ BETA, C, LDC )
1749 * .. Scalar Arguments ..
1750 CHARACTER*1 TRANSA, TRANSB
1751 INTEGER M, N, K, LDA, LDB, LDC
1752 COMPLEX*16 ALPHA, BETA
1753 * .. Array Arguments ..
1754 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )
1755 * ..
1756 *
1757 * Purpose
1758 * =======
1759 *
1760 * ZGEMM performs one of the matrix-matrix operations
1761 *
1762 * C := alpha*op( A )*op( B ) + beta*C,
1763 *
1764 * where op( X ) is one of
1765 *
1766 * op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ),
1767 *
1768 * alpha and beta are scalars, and A, B and C are matrices, with op( A )
1769 * an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1770 *
1771 * Parameters
1772 * ==========
1773 *
1774 * TRANSA - CHARACTER*1.
1775 * On entry, TRANSA specifies the form of op( A ) to be used in
1776 * the matrix multiplication as follows:
1777 *
1778 * TRANSA = 'N' or 'n', op( A ) = A.
1779 *
1780 * TRANSA = 'T' or 't', op( A ) = A'.
1781 *
1782 * TRANSA = 'C' or 'c', op( A ) = conjg( A' ).
1783 *
1784 * Unchanged on exit.
1785 *
1786 * TRANSB - CHARACTER*1.
1787 * On entry, TRANSB specifies the form of op( B ) to be used in
1788 * the matrix multiplication as follows:
1789 *
1790 * TRANSB = 'N' or 'n', op( B ) = B.
1791 *
1792 * TRANSB = 'T' or 't', op( B ) = B'.
1793 *
1794 * TRANSB = 'C' or 'c', op( B ) = conjg( B' ).
1795 *
1796 * Unchanged on exit.
1797 *
1798 * M - INTEGER.
1799 * On entry, M specifies the number of rows of the matrix
1800 * op( A ) and of the matrix C. M must be at least zero.
1801 * Unchanged on exit.
1802 *
1803 * N - INTEGER.
1804 * On entry, N specifies the number of columns of the matrix
1805 * op( B ) and the number of columns of the matrix C. N must be
1806 * at least zero.
1807 * Unchanged on exit.
1808 *
1809 * K - INTEGER.
1810 * On entry, K specifies the number of columns of the matrix
1811 * op( A ) and the number of rows of the matrix op( B ). K must
1812 * be at least zero.
1813 * Unchanged on exit.
1814 *
1815 * ALPHA - COMPLEX*16 .
1816 * On entry, ALPHA specifies the scalar alpha.
1817 * Unchanged on exit.
1818 *
1819 * A - COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is
1820 * k when TRANSA = 'N' or 'n', and is m otherwise.
1821 * Before entry with TRANSA = 'N' or 'n', the leading m by k
1822 * part of the array A must contain the matrix A, otherwise
1823 * the leading k by m part of the array A must contain the
1824 * matrix A.
1825 * Unchanged on exit.
1826 *
1827 * LDA - INTEGER.
1828 * On entry, LDA specifies the first dimension of A as declared
1829 * in the calling (sub) program. When TRANSA = 'N' or 'n' then
1830 * LDA must be at least max( 1, m ), otherwise LDA must be at
1831 * least max( 1, k ).
1832 * Unchanged on exit.
1833 *
1834 * B - COMPLEX*16 array of DIMENSION ( LDB, kb ), where kb is
1835 * n when TRANSB = 'N' or 'n', and is k otherwise.
1836 * Before entry with TRANSB = 'N' or 'n', the leading k by n
1837 * part of the array B must contain the matrix B, otherwise
1838 * the leading n by k part of the array B must contain the
1839 * matrix B.
1840 * Unchanged on exit.
1841 *
1842 * LDB - INTEGER.
1843 * On entry, LDB specifies the first dimension of B as declared
1844 * in the calling (sub) program. When TRANSB = 'N' or 'n' then
1845 * LDB must be at least max( 1, k ), otherwise LDB must be at
1846 * least max( 1, n ).
1847 * Unchanged on exit.
1848 *
1849 * BETA - COMPLEX*16 .
1850 * On entry, BETA specifies the scalar beta. When BETA is
1851 * supplied as zero then C need not be set on input.
1852 * Unchanged on exit.
1853 *
1854 * C - COMPLEX*16 array of DIMENSION ( LDC, n ).
1855 * Before entry, the leading m by n part of the array C must
1856 * contain the matrix C, except when beta is zero, in which
1857 * case C need not be set on entry.
1858 * On exit, the array C is overwritten by the m by n matrix
1859 * ( alpha*op( A )*op( B ) + beta*C ).
1860 *
1861 * LDC - INTEGER.
1862 * On entry, LDC specifies the first dimension of C as declared
1863 * in the calling (sub) program. LDC must be at least
1864 * max( 1, m ).
1865 * Unchanged on exit.
1866 *
1867 *
1868 * Level 3 Blas routine.
1869 *
1870 * -- Written on 8-February-1989.
1871 * Jack Dongarra, Argonne National Laboratory.
1872 * Iain Duff, AERE Harwell.
1873 * Jeremy Du Croz, Numerical Algorithms Group Ltd.
1874 * Sven Hammarling, Numerical Algorithms Group Ltd.
1875 *
1876 *
1877 * .. External Functions ..
1878 LOGICAL LSAME
1879 EXTERNAL LSAME
1880 * .. External Subroutines ..
1881 EXTERNAL XERBLA
1882 * .. Intrinsic Functions ..
1883 INTRINSIC DCONJG, MAX
1884 * .. Local Scalars ..
1885 LOGICAL CONJA, CONJB, NOTA, NOTB
1886 INTEGER I, INFO, J, L, NCOLA, NROWA, NROWB
1887 COMPLEX*16 TEMP
1888 * .. Parameters ..
1889 COMPLEX*16 ONE
1890 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
1891 COMPLEX*16 ZERO
1892 PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
1893 * ..
1894 * .. Executable Statements ..
1895 *
1896 * Set NOTA and NOTB as true if A and B respectively are not
1897 * conjugated or transposed, set CONJA and CONJB as true if A and
1898 * B respectively are to be transposed but not conjugated and set
1899 * NROWA, NCOLA and NROWB as the number of rows and columns of A
1900 * and the number of rows of B respectively.
1901 *
1902 NOTA = LSAME( TRANSA, 'N' )
1903 NOTB = LSAME( TRANSB, 'N' )
1904 CONJA = LSAME( TRANSA, 'C' )
1905 CONJB = LSAME( TRANSB, 'C' )
1906 IF( NOTA )THEN
1907 NROWA = M
1908 NCOLA = K
1909 ELSE
1910 NROWA = K
1911 NCOLA = M
1912 END IF
1913 IF( NOTB )THEN
1914 NROWB = K
1915 ELSE
1916 NROWB = N
1917 END IF
1918 *
1919 * Test the input parameters.
1920 *
1921 INFO = 0
1922 IF( ( .NOT.NOTA ).AND.
1923 $ ( .NOT.CONJA ).AND.
1924 $ ( .NOT.LSAME( TRANSA, 'T' ) ) )THEN
1925 INFO = 1
1926 ELSE IF( ( .NOT.NOTB ).AND.
1927 $ ( .NOT.CONJB ).AND.
1928 $ ( .NOT.LSAME( TRANSB, 'T' ) ) )THEN
1929 INFO = 2
1930 ELSE IF( M .LT.0 )THEN
1931 INFO = 3
1932 ELSE IF( N .LT.0 )THEN
1933 INFO = 4
1934 ELSE IF( K .LT.0 )THEN
1935 INFO = 5
1936 ELSE IF( LDA.LT.MAX( 1, NROWA ) )THEN
1937 INFO = 8
1938 ELSE IF( LDB.LT.MAX( 1, NROWB ) )THEN
1939 INFO = 10
1940 ELSE IF( LDC.LT.MAX( 1, M ) )THEN
1941 INFO = 13
1942 END IF
1943 IF( INFO.NE.0 )THEN
1944 CALL XERBLA( 'ZGEMM ', INFO )
1945 RETURN
1946 END IF
1947 *
1948 * Quick return if possible.
1949 *
1950 IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
1951 $ ( ( ( ALPHA.EQ.ZERO ).OR.( K.EQ.0 ) ).AND.( BETA.EQ.ONE ) ) )
1952 $ RETURN
1953 *
1954 * And when alpha.eq.zero.
1955 *
1956 IF( ALPHA.EQ.ZERO )THEN
1957 IF( BETA.EQ.ZERO )THEN
1958 DO 20, J = 1, N
1959 DO 10, I = 1, M
1960 C( I, J ) = ZERO
1961 10 CONTINUE
1962 20 CONTINUE
1963 ELSE
1964 DO 40, J = 1, N
1965 DO 30, I = 1, M
1966 C( I, J ) = BETA*C( I, J )
1967 30 CONTINUE
1968 40 CONTINUE
1969 END IF
1970 RETURN
1971 END IF
1972 *
1973 * Start the operations.
1974 *
1975 IF( NOTB )THEN
1976 IF( NOTA )THEN
1977 *
1978 * Form C := alpha*A*B + beta*C.
1979 *
1980 DO 90, J = 1, N
1981 IF( BETA.EQ.ZERO )THEN
1982 DO 50, I = 1, M
1983 C( I, J ) = ZERO
1984 50 CONTINUE
1985 ELSE IF( BETA.NE.ONE )THEN
1986 DO 60, I = 1, M
1987 C( I, J ) = BETA*C( I, J )
1988 60 CONTINUE
1989 END IF
1990 DO 80, L = 1, K
1991 IF( B( L, J ).NE.ZERO )THEN
1992 TEMP = ALPHA*B( L, J )
1993 DO 70, I = 1, M
1994 C( I, J ) = C( I, J ) + TEMP*A( I, L )
1995 70 CONTINUE
1996 END IF
1997 80 CONTINUE
1998 90 CONTINUE
1999 ELSE IF( CONJA )THEN
2000 *
2001 * Form C := alpha*conjg( A' )*B + beta*C.
2002 *
2003 DO 120, J = 1, N
2004 DO 110, I = 1, M
2005 TEMP = ZERO
2006 DO 100, L = 1, K
2007 TEMP = TEMP + DCONJG( A( L, I ) )*B( L, J )
2008 100 CONTINUE
2009 IF( BETA.EQ.ZERO )THEN
2010 C( I, J ) = ALPHA*TEMP
2011 ELSE
2012 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2013 END IF
2014 110 CONTINUE
2015 120 CONTINUE
2016 ELSE
2017 *
2018 * Form C := alpha*A'*B + beta*C
2019 *
2020 DO 150, J = 1, N
2021 DO 140, I = 1, M
2022 TEMP = ZERO
2023 DO 130, L = 1, K
2024 TEMP = TEMP + A( L, I )*B( L, J )
2025 130 CONTINUE
2026 IF( BETA.EQ.ZERO )THEN
2027 C( I, J ) = ALPHA*TEMP
2028 ELSE
2029 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2030 END IF
2031 140 CONTINUE
2032 150 CONTINUE
2033 END IF
2034 ELSE IF( NOTA )THEN
2035 IF( CONJB )THEN
2036 *
2037 * Form C := alpha*A*conjg( B' ) + beta*C.
2038 *
2039 DO 200, J = 1, N
2040 IF( BETA.EQ.ZERO )THEN
2041 DO 160, I = 1, M
2042 C( I, J ) = ZERO
2043 160 CONTINUE
2044 ELSE IF( BETA.NE.ONE )THEN
2045 DO 170, I = 1, M
2046 C( I, J ) = BETA*C( I, J )
2047 170 CONTINUE
2048 END IF
2049 DO 190, L = 1, K
2050 IF( B( J, L ).NE.ZERO )THEN
2051 TEMP = ALPHA*DCONJG( B( J, L ) )
2052 DO 180, I = 1, M
2053 C( I, J ) = C( I, J ) + TEMP*A( I, L )
2054 180 CONTINUE
2055 END IF
2056 190 CONTINUE
2057 200 CONTINUE
2058 ELSE
2059 *
2060 * Form C := alpha*A*B' + beta*C
2061 *
2062 DO 250, J = 1, N
2063 IF( BETA.EQ.ZERO )THEN
2064 DO 210, I = 1, M
2065 C( I, J ) = ZERO
2066 210 CONTINUE
2067 ELSE IF( BETA.NE.ONE )THEN
2068 DO 220, I = 1, M
2069 C( I, J ) = BETA*C( I, J )
2070 220 CONTINUE
2071 END IF
2072 DO 240, L = 1, K
2073 IF( B( J, L ).NE.ZERO )THEN
2074 TEMP = ALPHA*B( J, L )
2075 DO 230, I = 1, M
2076 C( I, J ) = C( I, J ) + TEMP*A( I, L )
2077 230 CONTINUE
2078 END IF
2079 240 CONTINUE
2080 250 CONTINUE
2081 END IF
2082 ELSE IF( CONJA )THEN
2083 IF( CONJB )THEN
2084 *
2085 * Form C := alpha*conjg( A' )*conjg( B' ) + beta*C.
2086 *
2087 DO 280, J = 1, N
2088 DO 270, I = 1, M
2089 TEMP = ZERO
2090 DO 260, L = 1, K
2091 TEMP = TEMP +
2092 $ DCONJG( A( L, I ) )*DCONJG( B( J, L ) )
2093 260 CONTINUE
2094 IF( BETA.EQ.ZERO )THEN
2095 C( I, J ) = ALPHA*TEMP
2096 ELSE
2097 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2098 END IF
2099 270 CONTINUE
2100 280 CONTINUE
2101 ELSE
2102 *
2103 * Form C := alpha*conjg( A' )*B' + beta*C
2104 *
2105 DO 310, J = 1, N
2106 DO 300, I = 1, M
2107 TEMP = ZERO
2108 DO 290, L = 1, K
2109 TEMP = TEMP + DCONJG( A( L, I ) )*B( J, L )
2110 290 CONTINUE
2111 IF( BETA.EQ.ZERO )THEN
2112 C( I, J ) = ALPHA*TEMP
2113 ELSE
2114 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2115 END IF
2116 300 CONTINUE
2117 310 CONTINUE
2118 END IF
2119 ELSE
2120 IF( CONJB )THEN
2121 *
2122 * Form C := alpha*A'*conjg( B' ) + beta*C
2123 *
2124 DO 340, J = 1, N
2125 DO 330, I = 1, M
2126 TEMP = ZERO
2127 DO 320, L = 1, K
2128 TEMP = TEMP + A( L, I )*DCONJG( B( J, L ) )
2129 320 CONTINUE
2130 IF( BETA.EQ.ZERO )THEN
2131 C( I, J ) = ALPHA*TEMP
2132 ELSE
2133 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2134 END IF
2135 330 CONTINUE
2136 340 CONTINUE
2137 ELSE
2138 *
2139 * Form C := alpha*A'*B' + beta*C
2140 *
2141 DO 370, J = 1, N
2142 DO 360, I = 1, M
2143 TEMP = ZERO
2144 DO 350, L = 1, K
2145 TEMP = TEMP + A( L, I )*B( J, L )
2146 350 CONTINUE
2147 IF( BETA.EQ.ZERO )THEN
2148 C( I, J ) = ALPHA*TEMP
2149 ELSE
2150 C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
2151 END IF
2152 360 CONTINUE
2153 370 CONTINUE
2154 END IF
2155 END IF
2156 *
2157 RETURN
2158 *
2159 * End of ZGEMM .
2160 *
2161 END
2162 double complex function zdotc(n,zx,incx,zy,incy)
2163 c
2164 c forms the dot product of a vector.
2165 c jack dongarra, 3/11/78.
2166 c
2167 double complex zx(1),zy(1),ztemp
2168 ztemp = (0.0d0,0.0d0)
2169 zdotc = (0.0d0,0.0d0)
2170 if(n.le.0)return
2171 if(incx.eq.1.and.incy.eq.1)go to 20
2172 c
2173 c code for unequal increments or equal increments
2174 c not equal to 1
2175 c
2176 ix = 1
2177 iy = 1
2178 if(incx.lt.0)ix = (-n+1)*incx + 1
2179 if(incy.lt.0)iy = (-n+1)*incy + 1
2180 do 10 i = 1,n
2181 ztemp = ztemp + dconjg(zx(ix))*zy(iy)
2182 ix = ix + incx
2183 iy = iy + incy
2184 10 continue
2185 zdotc = ztemp
2186 return
2187 c
2188 c code for both increments equal to 1
2189 c
2190 20 do 30 i = 1,n
2191 ztemp = ztemp + dconjg(zx(i))*zy(i)
2192 30 continue
2193 zdotc = ztemp
2194 return
2195 end
2196 subroutine zdscal(n,da,zx,incx)
2197 c
2198 c scales a vector by a constant.
2199 c jack dongarra, 3/11/78.
2200 c modified 3/93 to return if incx .le. 0.
2201 c
2202 double complex zx(1)
2203 double precision da
2204 integer i,incx,ix,n
2205 c
2206 if( n.le.0 .or. incx.le.0 )return
2207 if(incx.eq.1)go to 20
2208 c
2209 c code for increment not equal to 1
2210 c
2211 ix = 1
2212 do 10 i = 1,n
2213 zx(ix) = dcmplx(da,0.0d0)*zx(ix)
2214 ix = ix + incx
2215 10 continue
2216 return
2217 c
2218 c code for increment equal to 1
2219 c
2220 20 do 30 i = 1,n
2221 zx(i) = dcmplx(da,0.0d0)*zx(i)
2222 30 continue
2223 return
2224 end
2225 subroutine dswap (n,dx,incx,dy,incy)
2226 c
2227 c interchanges two vectors.
2228 c uses unrolled loops for increments equal one.
2229 c jack dongarra, linpack, 3/11/78.
2230 c
2231 double precision dx(1),dy(1),dtemp
2232 integer i,incx,incy,ix,iy,m,mp1,n
2233 c
2234 if(n.le.0)return
2235 if(incx.eq.1.and.incy.eq.1)go to 20
2236 c
2237 c code for unequal increments or equal increments not equal
2238 c to 1
2239 c
2240 ix = 1
2241 iy = 1
2242 if(incx.lt.0)ix = (-n+1)*incx + 1
2243 if(incy.lt.0)iy = (-n+1)*incy + 1
2244 do 10 i = 1,n
2245 dtemp = dx(ix)
2246 dx(ix) = dy(iy)
2247 dy(iy) = dtemp
2248 ix = ix + incx
2249 iy = iy + incy
2250 10 continue
2251 return
2252 c
2253 c code for both increments equal to 1
2254 c
2255 c
2256 c clean-up loop
2257 c
2258 20 m = mod(n,3)
2259 if( m .eq. 0 ) go to 40
2260 do 30 i = 1,m
2261 dtemp = dx(i)
2262 dx(i) = dy(i)
2263 dy(i) = dtemp
2264 30 continue
2265 if( n .lt. 3 ) return
2266 40 mp1 = m + 1
2267 do 50 i = mp1,n,3
2268 dtemp = dx(i)
2269 dx(i) = dy(i)
2270 dy(i) = dtemp
2271 dtemp = dx(i + 1)
2272 dx(i + 1) = dy(i + 1)
2273 dy(i + 1) = dtemp
2274 dtemp = dx(i + 2)
2275 dx(i + 2) = dy(i + 2)
2276 dy(i + 2) = dtemp
2277 50 continue
2278 return
2279 end
2280 integer function izamax(n,zx,incx)
2281 c
2282 c finds the index of element having max. absolute value.
2283 c jack dongarra, 1/15/85.
2284 c modified 3/93 to return if incx .le. 0.
2285 c
2286 double complex zx(1)
2287 double precision smax
2288 integer i,incx,ix,n
2289 double precision dcabs1
2290 c
2291 izamax = 0
2292 if( n.lt.1 .or. incx.le.0 )return
2293 izamax = 1
2294 if(n.eq.1)return
2295 if(incx.eq.1)go to 20
2296 c
2297 c code for increment not equal to 1
2298 c
2299 ix = 1
2300 smax = dcabs1(zx(1))
2301 ix = ix + incx
2302 do 10 i = 2,n
2303 if(dcabs1(zx(ix)).le.smax) go to 5
2304 izamax = i
2305 smax = dcabs1(zx(ix))
2306 5 ix = ix + incx
2307 10 continue
2308 return
2309 c
2310 c code for increment equal to 1
2311 c
2312 20 smax = dcabs1(zx(1))
2313 do 30 i = 2,n
2314 if(dcabs1(zx(i)).le.smax) go to 30
2315 izamax = i
2316 smax = dcabs1(zx(i))
2317 30 continue
2318 return
2319 end
2320 subroutine zscal(n,za,zx,incx)
2321 c
2322 c scales a vector by a constant.
2323 c jack dongarra, 3/11/78.
2324 c modified 3/93 to return if incx .le. 0.
2325 c
2326 double complex za,zx(1)
2327 integer i,incx,ix,n
2328 c
2329 if( n.le.0 .or. incx.le.0 )return
2330 if(incx.eq.1)go to 20
2331 c
2332 c code for increment not equal to 1
2333 c
2334 ix = 1
2335 do 10 i = 1,n
2336 zx(ix) = za*zx(ix)
2337 ix = ix + incx
2338 10 continue
2339 return
2340 c
2341 c code for increment equal to 1
2342 c
2343 20 do 30 i = 1,n
2344 zx(i) = za*zx(i)
2345 30 continue
2346 return
2347 end
2348 double complex function zdotu(n,zx,incx,zy,incy)
2349 c
2350 c forms the dot product of a vector.
2351 c jack dongarra, 3/11/78.
2352 c
2353 double complex zx(1),zy(1),ztemp
2354 ztemp = (0.0d0,0.0d0)
2355 zdotu = (0.0d0,0.0d0)
2356 if(n.le.0)return
2357 if(incx.eq.1.and.incy.eq.1)go to 20
2358 c
2359 c code for unequal increments or equal increments
2360 c not equal to 1
2361 c
2362 ix = 1
2363 iy = 1
2364 if(incx.lt.0)ix = (-n+1)*incx + 1
2365 if(incy.lt.0)iy = (-n+1)*incy + 1
2366 do 10 i = 1,n
2367 ztemp = ztemp + zx(ix)*zy(iy)
2368 ix = ix + incx
2369 iy = iy + incy
2370 10 continue
2371 zdotu = ztemp
2372 return
2373 c
2374 c code for both increments equal to 1
2375 c
2376 20 do 30 i = 1,n
2377 ztemp = ztemp + zx(i)*zy(i)
2378 30 continue
2379 zdotu = ztemp
2380 return
2381 end