```001:       SUBROUTINE ZLA_GBAMV( TRANS, M, N, KL, KU, ALPHA, AB, LDAB, X,
002:      \$                      INCX, BETA, Y, INCY )
003: *
004: *     -- LAPACK routine (version 3.2)                                 --
005: *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
006: *     -- Jason Riedy of Univ. of California Berkeley.                 --
007: *     -- April 2009                                                   --
008: *
009: *     -- LAPACK is a software package provided by Univ. of Tennessee, --
010: *     -- Univ. of California Berkeley and NAG Ltd.                    --
011: *
012:       IMPLICIT NONE
013: *     ..
014: *     .. Scalar Arguments ..
015:       DOUBLE PRECISION   ALPHA, BETA
016:       INTEGER            INCX, INCY, LDAB, M, N, KL, KU, TRANS
017: *     ..
018: *     .. Array Arguments ..
019:       COMPLEX*16         AB( LDAB, * ), X( * )
020:       DOUBLE PRECISION   Y( * )
021: *     ..
022: *
023: *  Purpose
024: *  =======
025: *
026: *  DLA_GBAMV  performs one of the matrix-vector operations
027: *
028: *          y := alpha*abs(A)*abs(x) + beta*abs(y),
029: *     or   y := alpha*abs(A)'*abs(x) + beta*abs(y),
030: *
031: *  where alpha and beta are scalars, x and y are vectors and A is an
032: *  m by n matrix.
033: *
034: *  This function is primarily used in calculating error bounds.
035: *  To protect against underflow during evaluation, components in
036: *  the resulting vector are perturbed away from zero by (N+1)
037: *  times the underflow threshold.  To prevent unnecessarily large
038: *  errors for block-structure embedded in general matrices,
039: *  "symbolically" zero components are not perturbed.  A zero
040: *  entry is considered "symbolic" if all multiplications involved
041: *  in computing that entry have at least one zero multiplicand.
042: *
043: *  Arguments
044: *  ==========
045: *
046: *  TRANS  - INTEGER
047: *           On entry, TRANS specifies the operation to be performed as
048: *           follows:
049: *
050: *             BLAS_NO_TRANS      y := alpha*abs(A)*abs(x) + beta*abs(y)
051: *             BLAS_TRANS         y := alpha*abs(A')*abs(x) + beta*abs(y)
052: *             BLAS_CONJ_TRANS    y := alpha*abs(A')*abs(x) + beta*abs(y)
053: *
054: *           Unchanged on exit.
055: *
056: *  M      - INTEGER
057: *           On entry, M specifies the number of rows of the matrix A.
058: *           M must be at least zero.
059: *           Unchanged on exit.
060: *
061: *  N      - INTEGER
062: *           On entry, N specifies the number of columns of the matrix A.
063: *           N must be at least zero.
064: *           Unchanged on exit.
065: *
066: *  KL     - INTEGER
067: *           The number of subdiagonals within the band of A.  KL >= 0.
068: *
069: *  KU     - INTEGER
070: *           The number of superdiagonals within the band of A.  KU >= 0.
071: *
072: *  ALPHA  - DOUBLE PRECISION
073: *           On entry, ALPHA specifies the scalar alpha.
074: *           Unchanged on exit.
075: *
076: *  A      - DOUBLE PRECISION   array of DIMENSION ( LDA, n )
077: *           Before entry, the leading m by n part of the array A must
078: *           contain the matrix of coefficients.
079: *           Unchanged on exit.
080: *
081: *  LDA    - INTEGER
082: *           On entry, LDA specifies the first dimension of A as declared
083: *           in the calling (sub) program. LDA must be at least
084: *           max( 1, m ).
085: *           Unchanged on exit.
086: *
087: *  X      - DOUBLE PRECISION   array of DIMENSION at least
088: *           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
089: *           and at least
090: *           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
091: *           Before entry, the incremented array X must contain the
092: *           vector x.
093: *           Unchanged on exit.
094: *
095: *  INCX   - INTEGER
096: *           On entry, INCX specifies the increment for the elements of
097: *           X. INCX must not be zero.
098: *           Unchanged on exit.
099: *
100: *  BETA   - DOUBLE PRECISION
101: *           On entry, BETA specifies the scalar beta. When BETA is
102: *           supplied as zero then Y need not be set on input.
103: *           Unchanged on exit.
104: *
105: *  Y      - DOUBLE PRECISION   array of DIMENSION at least
106: *           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
107: *           and at least
108: *           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
109: *           Before entry with BETA non-zero, the incremented array Y
110: *           must contain the vector y. On exit, Y is overwritten by the
111: *           updated vector y.
112: *
113: *  INCY   - INTEGER
114: *           On entry, INCY specifies the increment for the elements of
115: *           Y. INCY must not be zero.
116: *           Unchanged on exit.
117: *
118: *
119: *  Level 2 Blas routine.
120: *
121: *  =====================================================================
122: *
123: *     .. Parameters ..
124:       COMPLEX*16         ONE, ZERO
125:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
126: *     ..
127: *     .. Local Scalars ..
128:       LOGICAL            SYMB_ZERO
129:       DOUBLE PRECISION   TEMP, SAFE1
130:       INTEGER            I, INFO, IY, J, JX, KX, KY, LENX, LENY, KD, KE
131:       COMPLEX*16         CDUM
132: *     ..
133: *     .. External Subroutines ..
134:       EXTERNAL           XERBLA, DLAMCH
135:       DOUBLE PRECISION   DLAMCH
136: *     ..
137: *     .. External Functions ..
138:       EXTERNAL           ILATRANS
139:       INTEGER            ILATRANS
140: *     ..
141: *     .. Intrinsic Functions ..
142:       INTRINSIC          MAX, ABS, REAL, DIMAG, SIGN
143: *     ..
144: *     .. Statement Functions
145:       DOUBLE PRECISION   CABS1
146: *     ..
147: *     .. Statement Function Definitions ..
148:       CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
149: *     ..
150: *     .. Executable Statements ..
151: *
152: *     Test the input parameters.
153: *
154:       INFO = 0
155:       IF     ( .NOT.( ( TRANS.EQ.ILATRANS( 'N' ) )
156:      \$           .OR. ( TRANS.EQ.ILATRANS( 'T' ) )
157:      \$           .OR. ( TRANS.EQ.ILATRANS( 'C' ) ) ) ) THEN
158:          INFO = 1
159:       ELSE IF( M.LT.0 )THEN
160:          INFO = 2
161:       ELSE IF( N.LT.0 )THEN
162:          INFO = 3
163:       ELSE IF( KL.LT.0 .OR. KL.GT.M-1 ) THEN
164:          INFO = 4
165:       ELSE IF( KU.LT.0 .OR. KU.GT.N-1 ) THEN
166:          INFO = 5
167:       ELSE IF( LDAB.LT.KL+KU+1 )THEN
168:          INFO = 6
169:       ELSE IF( INCX.EQ.0 )THEN
170:          INFO = 8
171:       ELSE IF( INCY.EQ.0 )THEN
172:          INFO = 11
173:       END IF
174:       IF( INFO.NE.0 )THEN
175:          CALL XERBLA( 'ZLA_GBAMV ', INFO )
176:          RETURN
177:       END IF
178: *
179: *     Quick return if possible.
180: *
181:       IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
182:      \$    ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
183:      \$   RETURN
184: *
185: *     Set  LENX  and  LENY, the lengths of the vectors x and y, and set
186: *     up the start points in  X  and  Y.
187: *
188:       IF( TRANS.EQ.ILATRANS( 'N' ) )THEN
189:          LENX = N
190:          LENY = M
191:       ELSE
192:          LENX = M
193:          LENY = N
194:       END IF
195:       IF( INCX.GT.0 )THEN
196:          KX = 1
197:       ELSE
198:          KX = 1 - ( LENX - 1 )*INCX
199:       END IF
200:       IF( INCY.GT.0 )THEN
201:          KY = 1
202:       ELSE
203:          KY = 1 - ( LENY - 1 )*INCY
204:       END IF
205: *
206: *     Set SAFE1 essentially to be the underflow threshold times the
207: *     number of additions in each row.
208: *
209:       SAFE1 = DLAMCH( 'Safe minimum' )
210:       SAFE1 = (N+1)*SAFE1
211: *
212: *     Form  y := alpha*abs(A)*abs(x) + beta*abs(y).
213: *
214: *     The O(M*N) SYMB_ZERO tests could be replaced by O(N) queries to
215: *     the inexact flag.  Still doesn't help change the iteration order
216: *     to per-column.
217: *
218:       KD = KU + 1
219:       KE = KL + 1
220:       IY = KY
221:       IF ( INCX.EQ.1 ) THEN
222:          IF( TRANS.EQ.ILATRANS( 'N' ) )THEN
223:             DO I = 1, LENY
224:                IF ( BETA .EQ. 0.0D+0 ) THEN
225:                   SYMB_ZERO = .TRUE.
226:                   Y( IY ) = 0.0D+0
227:                ELSE IF ( Y( IY ) .EQ. 0.0D+0 ) THEN
228:                   SYMB_ZERO = .TRUE.
229:                ELSE
230:                   SYMB_ZERO = .FALSE.
231:                   Y( IY ) = BETA * ABS( Y( IY ) )
232:                END IF
233:                IF ( ALPHA .NE. 0.0D+0 ) THEN
234:                   DO J = MAX( I-KL, 1 ), MIN( I+KU, LENX )
235:                      TEMP = CABS1( AB( KD+I-J, J ) )
236:                      SYMB_ZERO = SYMB_ZERO .AND.
237:      \$                    ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
238:
239:                      Y( IY ) = Y( IY ) + ALPHA*CABS1( X( J ) )*TEMP
240:                   END DO
241:                END IF
242:
243:                IF ( .NOT.SYMB_ZERO)
244:      \$              Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
245:
246:                IY = IY + INCY
247:             END DO
248:          ELSE
249:             DO I = 1, LENY
250:                IF ( BETA .EQ. 0.0D+0 ) THEN
251:                   SYMB_ZERO = .TRUE.
252:                   Y( IY ) = 0.0D+0
253:                ELSE IF ( Y( IY ) .EQ. 0.0D+0 ) THEN
254:                   SYMB_ZERO = .TRUE.
255:                ELSE
256:                   SYMB_ZERO = .FALSE.
257:                   Y( IY ) = BETA * ABS( Y( IY ) )
258:                END IF
259:                IF ( ALPHA .NE. 0.0D+0 ) THEN
260:                   DO J = MAX( I-KL, 1 ), MIN( I+KU, LENX )
261:                      TEMP = CABS1( AB( KE-I+J, I ) )
262:                      SYMB_ZERO = SYMB_ZERO .AND.
263:      \$                    ( X( J ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
264:
265:                      Y( IY ) = Y( IY ) + ALPHA*CABS1( X( J ) )*TEMP
266:                   END DO
267:                END IF
268:
269:                IF ( .NOT.SYMB_ZERO)
270:      \$              Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
271:
272:                IY = IY + INCY
273:             END DO
274:          END IF
275:       ELSE
276:          IF( TRANS.EQ.ILATRANS( 'N' ) )THEN
277:             DO I = 1, LENY
278:                IF ( BETA .EQ. 0.0D+0 ) THEN
279:                   SYMB_ZERO = .TRUE.
280:                   Y( IY ) = 0.0D+0
281:                ELSE IF ( Y( IY ) .EQ. 0.0D+0 ) THEN
282:                   SYMB_ZERO = .TRUE.
283:                ELSE
284:                   SYMB_ZERO = .FALSE.
285:                   Y( IY ) = BETA * ABS( Y( IY ) )
286:                END IF
287:                IF ( ALPHA .NE. 0.0D+0 ) THEN
288:                   JX = KX
289:                   DO J = MAX( I-KL, 1 ), MIN( I+KU, LENX )
290:                      TEMP = CABS1( AB( KD+I-J, J ) )
291:                      SYMB_ZERO = SYMB_ZERO .AND.
292:      \$                    ( X( JX ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
293:
294:                      Y( IY ) = Y( IY ) + ALPHA*CABS1( X( JX ) )*TEMP
295:                      JX = JX + INCX
296:                   END DO
297:                END IF
298:
299:                IF ( .NOT.SYMB_ZERO )
300:      \$              Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
301:
302:                IY = IY + INCY
303:             END DO
304:          ELSE
305:             DO I = 1, LENY
306:                IF ( BETA .EQ. 0.0D+0 ) THEN
307:                   SYMB_ZERO = .TRUE.
308:                   Y( IY ) = 0.0D+0
309:                ELSE IF ( Y( IY ) .EQ. 0.0D+0 ) THEN
310:                   SYMB_ZERO = .TRUE.
311:                ELSE
312:                   SYMB_ZERO = .FALSE.
313:                   Y( IY ) = BETA * ABS( Y( IY ) )
314:                END IF
315:                IF ( ALPHA .NE. 0.0D+0 ) THEN
316:                   JX = KX
317:                   DO J = MAX( I-KL, 1 ), MIN( I+KU, LENX )
318:                      TEMP = CABS1( AB( KE-I+J, I ) )
319:                      SYMB_ZERO = SYMB_ZERO .AND.
320:      \$                    ( X( JX ) .EQ. ZERO .OR. TEMP .EQ. ZERO )
321:
322:                      Y( IY ) = Y( IY ) + ALPHA*CABS1( X( JX ) )*TEMP
323:                      JX = JX + INCX
324:                   END DO
325:                END IF
326:
327:                IF ( .NOT.SYMB_ZERO )
328:      \$              Y( IY ) = Y( IY ) + SIGN( SAFE1, Y( IY ) )
329:
330:                IY = IY + INCY
331:             END DO
332:          END IF
333:
334:       END IF
335: *
336:       RETURN
337: *
338: *     End of ZLA_GBAMV
339: *
340:       END
341: ```