LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
 All Classes Files Functions Variables Typedefs Macros
zgbmv.f
Go to the documentation of this file.
1 *> \brief \b ZGBMV
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE ZGBMV(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
12 *
13 * .. Scalar Arguments ..
14 * COMPLEX*16 ALPHA,BETA
15 * INTEGER INCX,INCY,KL,KU,LDA,M,N
16 * CHARACTER TRANS
17 * ..
18 * .. Array Arguments ..
19 * COMPLEX*16 A(LDA,*),X(*),Y(*)
20 * ..
21 *
22 *
23 *> \par Purpose:
24 * =============
25 *>
26 *> \verbatim
27 *>
28 *> ZGBMV performs one of the matrix-vector operations
29 *>
30 *> y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y, or
31 *>
32 *> y := alpha*A**H*x + beta*y,
33 *>
34 *> where alpha and beta are scalars, x and y are vectors and A is an
35 *> m by n band matrix, with kl sub-diagonals and ku super-diagonals.
36 *> \endverbatim
37 *
38 * Arguments:
39 * ==========
40 *
41 *> \param[in] TRANS
42 *> \verbatim
43 *> TRANS is CHARACTER*1
44 *> On entry, TRANS specifies the operation to be performed as
45 *> follows:
46 *>
47 *> TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
48 *>
49 *> TRANS = 'T' or 't' y := alpha*A**T*x + beta*y.
50 *>
51 *> TRANS = 'C' or 'c' y := alpha*A**H*x + beta*y.
52 *> \endverbatim
53 *>
54 *> \param[in] M
55 *> \verbatim
56 *> M is INTEGER
57 *> On entry, M specifies the number of rows of the matrix A.
58 *> M must be at least zero.
59 *> \endverbatim
60 *>
61 *> \param[in] N
62 *> \verbatim
63 *> N is INTEGER
64 *> On entry, N specifies the number of columns of the matrix A.
65 *> N must be at least zero.
66 *> \endverbatim
67 *>
68 *> \param[in] KL
69 *> \verbatim
70 *> KL is INTEGER
71 *> On entry, KL specifies the number of sub-diagonals of the
72 *> matrix A. KL must satisfy 0 .le. KL.
73 *> \endverbatim
74 *>
75 *> \param[in] KU
76 *> \verbatim
77 *> KU is INTEGER
78 *> On entry, KU specifies the number of super-diagonals of the
79 *> matrix A. KU must satisfy 0 .le. KU.
80 *> \endverbatim
81 *>
82 *> \param[in] ALPHA
83 *> \verbatim
84 *> ALPHA is COMPLEX*16
85 *> On entry, ALPHA specifies the scalar alpha.
86 *> \endverbatim
87 *>
88 *> \param[in] A
89 *> \verbatim
90 *> A is COMPLEX*16 array of DIMENSION ( LDA, n ).
91 *> Before entry, the leading ( kl + ku + 1 ) by n part of the
92 *> array A must contain the matrix of coefficients, supplied
93 *> column by column, with the leading diagonal of the matrix in
94 *> row ( ku + 1 ) of the array, the first super-diagonal
95 *> starting at position 2 in row ku, the first sub-diagonal
96 *> starting at position 1 in row ( ku + 2 ), and so on.
97 *> Elements in the array A that do not correspond to elements
98 *> in the band matrix (such as the top left ku by ku triangle)
99 *> are not referenced.
100 *> The following program segment will transfer a band matrix
101 *> from conventional full matrix storage to band storage:
102 *>
103 *> DO 20, J = 1, N
104 *> K = KU + 1 - J
105 *> DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL )
106 *> A( K + I, J ) = matrix( I, J )
107 *> 10 CONTINUE
108 *> 20 CONTINUE
109 *> \endverbatim
110 *>
111 *> \param[in] LDA
112 *> \verbatim
113 *> LDA is INTEGER
114 *> On entry, LDA specifies the first dimension of A as declared
115 *> in the calling (sub) program. LDA must be at least
116 *> ( kl + ku + 1 ).
117 *> \endverbatim
118 *>
119 *> \param[in] X
120 *> \verbatim
121 *> X is COMPLEX*16 array of DIMENSION at least
122 *> ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
123 *> and at least
124 *> ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
125 *> Before entry, the incremented array X must contain the
126 *> vector x.
127 *> \endverbatim
128 *>
129 *> \param[in] INCX
130 *> \verbatim
131 *> INCX is INTEGER
132 *> On entry, INCX specifies the increment for the elements of
133 *> X. INCX must not be zero.
134 *> \endverbatim
135 *>
136 *> \param[in] BETA
137 *> \verbatim
138 *> BETA is COMPLEX*16
139 *> On entry, BETA specifies the scalar beta. When BETA is
140 *> supplied as zero then Y need not be set on input.
141 *> \endverbatim
142 *>
143 *> \param[in,out] Y
144 *> \verbatim
145 *> Y is COMPLEX*16 array of DIMENSION at least
146 *> ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
147 *> and at least
148 *> ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
149 *> Before entry, the incremented array Y must contain the
150 *> vector y. On exit, Y is overwritten by the updated vector y.
151 *> \endverbatim
152 *>
153 *> \param[in] INCY
154 *> \verbatim
155 *> INCY is INTEGER
156 *> On entry, INCY specifies the increment for the elements of
157 *> Y. INCY must not be zero.
158 *> \endverbatim
159 *
160 * Authors:
161 * ========
162 *
163 *> \author Univ. of Tennessee
164 *> \author Univ. of California Berkeley
165 *> \author Univ. of Colorado Denver
166 *> \author NAG Ltd.
167 *
168 *> \date November 2011
169 *
170 *> \ingroup complex16_blas_level2
171 *
172 *> \par Further Details:
173 * =====================
174 *>
175 *> \verbatim
176 *>
177 *> Level 2 Blas routine.
178 *> The vector and matrix arguments are not referenced when N = 0, or M = 0
179 *>
180 *> -- Written on 22-October-1986.
181 *> Jack Dongarra, Argonne National Lab.
182 *> Jeremy Du Croz, Nag Central Office.
183 *> Sven Hammarling, Nag Central Office.
184 *> Richard Hanson, Sandia National Labs.
185 *> \endverbatim
186 *>
187 * =====================================================================
188  SUBROUTINE zgbmv(TRANS,M,N,KL,KU,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
189 *
190 * -- Reference BLAS level2 routine (version 3.4.0) --
191 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
192 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
193 * November 2011
194 *
195 * .. Scalar Arguments ..
196  COMPLEX*16 alpha,beta
197  INTEGER incx,incy,kl,ku,lda,m,n
198  CHARACTER trans
199 * ..
200 * .. Array Arguments ..
201  COMPLEX*16 a(lda,*),x(*),y(*)
202 * ..
203 *
204 * =====================================================================
205 *
206 * .. Parameters ..
207  COMPLEX*16 one
208  parameter(one= (1.0d+0,0.0d+0))
209  COMPLEX*16 zero
210  parameter(zero= (0.0d+0,0.0d+0))
211 * ..
212 * .. Local Scalars ..
213  COMPLEX*16 temp
214  INTEGER i,info,ix,iy,j,jx,jy,k,kup1,kx,ky,lenx,leny
215  LOGICAL noconj
216 * ..
217 * .. External Functions ..
218  LOGICAL lsame
219  EXTERNAL lsame
220 * ..
221 * .. External Subroutines ..
222  EXTERNAL xerbla
223 * ..
224 * .. Intrinsic Functions ..
225  INTRINSIC dconjg,max,min
226 * ..
227 *
228 * Test the input parameters.
229 *
230  info = 0
231  IF (.NOT.lsame(trans,'N') .AND. .NOT.lsame(trans,'T') .AND.
232  + .NOT.lsame(trans,'C')) THEN
233  info = 1
234  ELSE IF (m.LT.0) THEN
235  info = 2
236  ELSE IF (n.LT.0) THEN
237  info = 3
238  ELSE IF (kl.LT.0) THEN
239  info = 4
240  ELSE IF (ku.LT.0) THEN
241  info = 5
242  ELSE IF (lda.LT. (kl+ku+1)) THEN
243  info = 8
244  ELSE IF (incx.EQ.0) THEN
245  info = 10
246  ELSE IF (incy.EQ.0) THEN
247  info = 13
248  END IF
249  IF (info.NE.0) THEN
250  CALL xerbla('ZGBMV ',info)
251  RETURN
252  END IF
253 *
254 * Quick return if possible.
255 *
256  IF ((m.EQ.0) .OR. (n.EQ.0) .OR.
257  + ((alpha.EQ.zero).AND. (beta.EQ.one))) RETURN
258 *
259  noconj = lsame(trans,'T')
260 *
261 * Set LENX and LENY, the lengths of the vectors x and y, and set
262 * up the start points in X and Y.
263 *
264  IF (lsame(trans,'N')) THEN
265  lenx = n
266  leny = m
267  ELSE
268  lenx = m
269  leny = n
270  END IF
271  IF (incx.GT.0) THEN
272  kx = 1
273  ELSE
274  kx = 1 - (lenx-1)*incx
275  END IF
276  IF (incy.GT.0) THEN
277  ky = 1
278  ELSE
279  ky = 1 - (leny-1)*incy
280  END IF
281 *
282 * Start the operations. In this version the elements of A are
283 * accessed sequentially with one pass through the band part of A.
284 *
285 * First form y := beta*y.
286 *
287  IF (beta.NE.one) THEN
288  IF (incy.EQ.1) THEN
289  IF (beta.EQ.zero) THEN
290  DO 10 i = 1,leny
291  y(i) = zero
292  10 CONTINUE
293  ELSE
294  DO 20 i = 1,leny
295  y(i) = beta*y(i)
296  20 CONTINUE
297  END IF
298  ELSE
299  iy = ky
300  IF (beta.EQ.zero) THEN
301  DO 30 i = 1,leny
302  y(iy) = zero
303  iy = iy + incy
304  30 CONTINUE
305  ELSE
306  DO 40 i = 1,leny
307  y(iy) = beta*y(iy)
308  iy = iy + incy
309  40 CONTINUE
310  END IF
311  END IF
312  END IF
313  IF (alpha.EQ.zero) RETURN
314  kup1 = ku + 1
315  IF (lsame(trans,'N')) THEN
316 *
317 * Form y := alpha*A*x + y.
318 *
319  jx = kx
320  IF (incy.EQ.1) THEN
321  DO 60 j = 1,n
322  IF (x(jx).NE.zero) THEN
323  temp = alpha*x(jx)
324  k = kup1 - j
325  DO 50 i = max(1,j-ku),min(m,j+kl)
326  y(i) = y(i) + temp*a(k+i,j)
327  50 CONTINUE
328  END IF
329  jx = jx + incx
330  60 CONTINUE
331  ELSE
332  DO 80 j = 1,n
333  IF (x(jx).NE.zero) THEN
334  temp = alpha*x(jx)
335  iy = ky
336  k = kup1 - j
337  DO 70 i = max(1,j-ku),min(m,j+kl)
338  y(iy) = y(iy) + temp*a(k+i,j)
339  iy = iy + incy
340  70 CONTINUE
341  END IF
342  jx = jx + incx
343  IF (j.GT.ku) ky = ky + incy
344  80 CONTINUE
345  END IF
346  ELSE
347 *
348 * Form y := alpha*A**T*x + y or y := alpha*A**H*x + y.
349 *
350  jy = ky
351  IF (incx.EQ.1) THEN
352  DO 110 j = 1,n
353  temp = zero
354  k = kup1 - j
355  IF (noconj) THEN
356  DO 90 i = max(1,j-ku),min(m,j+kl)
357  temp = temp + a(k+i,j)*x(i)
358  90 CONTINUE
359  ELSE
360  DO 100 i = max(1,j-ku),min(m,j+kl)
361  temp = temp + dconjg(a(k+i,j))*x(i)
362  100 CONTINUE
363  END IF
364  y(jy) = y(jy) + alpha*temp
365  jy = jy + incy
366  110 CONTINUE
367  ELSE
368  DO 140 j = 1,n
369  temp = zero
370  ix = kx
371  k = kup1 - j
372  IF (noconj) THEN
373  DO 120 i = max(1,j-ku),min(m,j+kl)
374  temp = temp + a(k+i,j)*x(ix)
375  ix = ix + incx
376  120 CONTINUE
377  ELSE
378  DO 130 i = max(1,j-ku),min(m,j+kl)
379  temp = temp + dconjg(a(k+i,j))*x(ix)
380  ix = ix + incx
381  130 CONTINUE
382  END IF
383  y(jy) = y(jy) + alpha*temp
384  jy = jy + incy
385  IF (j.GT.ku) kx = kx + incx
386  140 CONTINUE
387  END IF
388  END IF
389 *
390  RETURN
391 *
392 * End of ZGBMV .
393 *
394  END