LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
zlascl.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine zlascl (TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
 ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom. More...
 

Function/Subroutine Documentation

subroutine zlascl ( character  TYPE,
integer  KL,
integer  KU,
double precision  CFROM,
double precision  CTO,
integer  M,
integer  N,
complex*16, dimension( lda, * )  A,
integer  LDA,
integer  INFO 
)

ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.

Download ZLASCL + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 ZLASCL multiplies the M by N complex matrix A by the real scalar
 CTO/CFROM.  This is done without over/underflow as long as the final
 result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that
 A may be full, upper triangular, lower triangular, upper Hessenberg,
 or banded.
Parameters
[in]TYPE
          TYPE is CHARACTER*1
          TYPE indices the storage type of the input matrix.
          = 'G':  A is a full matrix.
          = 'L':  A is a lower triangular matrix.
          = 'U':  A is an upper triangular matrix.
          = 'H':  A is an upper Hessenberg matrix.
          = 'B':  A is a symmetric band matrix with lower bandwidth KL
                  and upper bandwidth KU and with the only the lower
                  half stored.
          = 'Q':  A is a symmetric band matrix with lower bandwidth KL
                  and upper bandwidth KU and with the only the upper
                  half stored.
          = 'Z':  A is a band matrix with lower bandwidth KL and upper
                  bandwidth KU. See ZGBTRF for storage details.
[in]KL
          KL is INTEGER
          The lower bandwidth of A.  Referenced only if TYPE = 'B',
          'Q' or 'Z'.
[in]KU
          KU is INTEGER
          The upper bandwidth of A.  Referenced only if TYPE = 'B',
          'Q' or 'Z'.
[in]CFROM
          CFROM is DOUBLE PRECISION
[in]CTO
          CTO is DOUBLE PRECISION

          The matrix A is multiplied by CTO/CFROM. A(I,J) is computed
          without over/underflow if the final result CTO*A(I,J)/CFROM
          can be represented without over/underflow.  CFROM must be
          nonzero.
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0.
[in,out]A
          A is COMPLEX*16 array, dimension (LDA,N)
          The matrix to be multiplied by CTO/CFROM.  See TYPE for the
          storage type.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,M).
[out]INFO
          INFO is INTEGER
          0  - successful exit
          <0 - if INFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012

Definition at line 141 of file zlascl.f.

141 *
142 * -- LAPACK auxiliary routine (version 3.4.2) --
143 * -- LAPACK is a software package provided by Univ. of Tennessee, --
144 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
145 * September 2012
146 *
147 * .. Scalar Arguments ..
148  CHARACTER type
149  INTEGER info, kl, ku, lda, m, n
150  DOUBLE PRECISION cfrom, cto
151 * ..
152 * .. Array Arguments ..
153  COMPLEX*16 a( lda, * )
154 * ..
155 *
156 * =====================================================================
157 *
158 * .. Parameters ..
159  DOUBLE PRECISION zero, one
160  parameter( zero = 0.0d0, one = 1.0d0 )
161 * ..
162 * .. Local Scalars ..
163  LOGICAL done
164  INTEGER i, itype, j, k1, k2, k3, k4
165  DOUBLE PRECISION bignum, cfrom1, cfromc, cto1, ctoc, mul, smlnum
166 * ..
167 * .. External Functions ..
168  LOGICAL lsame, disnan
169  DOUBLE PRECISION dlamch
170  EXTERNAL lsame, dlamch, disnan
171 * ..
172 * .. Intrinsic Functions ..
173  INTRINSIC abs, max, min
174 * ..
175 * .. External Subroutines ..
176  EXTERNAL xerbla
177 * ..
178 * .. Executable Statements ..
179 *
180 * Test the input arguments
181 *
182  info = 0
183 *
184  IF( lsame( TYPE, 'G' ) ) then
185  itype = 0
186  ELSE IF( lsame( TYPE, 'L' ) ) then
187  itype = 1
188  ELSE IF( lsame( TYPE, 'U' ) ) then
189  itype = 2
190  ELSE IF( lsame( TYPE, 'H' ) ) then
191  itype = 3
192  ELSE IF( lsame( TYPE, 'B' ) ) then
193  itype = 4
194  ELSE IF( lsame( TYPE, 'Q' ) ) then
195  itype = 5
196  ELSE IF( lsame( TYPE, 'Z' ) ) then
197  itype = 6
198  ELSE
199  itype = -1
200  END IF
201 *
202  IF( itype.EQ.-1 ) THEN
203  info = -1
204  ELSE IF( cfrom.EQ.zero .OR. disnan(cfrom) ) THEN
205  info = -4
206  ELSE IF( disnan(cto) ) THEN
207  info = -5
208  ELSE IF( m.LT.0 ) THEN
209  info = -6
210  ELSE IF( n.LT.0 .OR. ( itype.EQ.4 .AND. n.NE.m ) .OR.
211  $ ( itype.EQ.5 .AND. n.NE.m ) ) THEN
212  info = -7
213  ELSE IF( itype.LE.3 .AND. lda.LT.max( 1, m ) ) THEN
214  info = -9
215  ELSE IF( itype.GE.4 ) THEN
216  IF( kl.LT.0 .OR. kl.GT.max( m-1, 0 ) ) THEN
217  info = -2
218  ELSE IF( ku.LT.0 .OR. ku.GT.max( n-1, 0 ) .OR.
219  $ ( ( itype.EQ.4 .OR. itype.EQ.5 ) .AND. kl.NE.ku ) )
220  $ THEN
221  info = -3
222  ELSE IF( ( itype.EQ.4 .AND. lda.LT.kl+1 ) .OR.
223  $ ( itype.EQ.5 .AND. lda.LT.ku+1 ) .OR.
224  $ ( itype.EQ.6 .AND. lda.LT.2*kl+ku+1 ) ) THEN
225  info = -9
226  END IF
227  END IF
228 *
229  IF( info.NE.0 ) THEN
230  CALL xerbla( 'ZLASCL', -info )
231  RETURN
232  END IF
233 *
234 * Quick return if possible
235 *
236  IF( n.EQ.0 .OR. m.EQ.0 )
237  $ RETURN
238 *
239 * Get machine parameters
240 *
241  smlnum = dlamch( 'S' )
242  bignum = one / smlnum
243 *
244  cfromc = cfrom
245  ctoc = cto
246 *
247  10 CONTINUE
248  cfrom1 = cfromc*smlnum
249  IF( cfrom1.EQ.cfromc ) THEN
250 ! CFROMC is an inf. Multiply by a correctly signed zero for
251 ! finite CTOC, or a NaN if CTOC is infinite.
252  mul = ctoc / cfromc
253  done = .true.
254  cto1 = ctoc
255  ELSE
256  cto1 = ctoc / bignum
257  IF( cto1.EQ.ctoc ) THEN
258 ! CTOC is either 0 or an inf. In both cases, CTOC itself
259 ! serves as the correct multiplication factor.
260  mul = ctoc
261  done = .true.
262  cfromc = one
263  ELSE IF( abs( cfrom1 ).GT.abs( ctoc ) .AND. ctoc.NE.zero ) THEN
264  mul = smlnum
265  done = .false.
266  cfromc = cfrom1
267  ELSE IF( abs( cto1 ).GT.abs( cfromc ) ) THEN
268  mul = bignum
269  done = .false.
270  ctoc = cto1
271  ELSE
272  mul = ctoc / cfromc
273  done = .true.
274  END IF
275  END IF
276 *
277  IF( itype.EQ.0 ) THEN
278 *
279 * Full matrix
280 *
281  DO 30 j = 1, n
282  DO 20 i = 1, m
283  a( i, j ) = a( i, j )*mul
284  20 CONTINUE
285  30 CONTINUE
286 *
287  ELSE IF( itype.EQ.1 ) THEN
288 *
289 * Lower triangular matrix
290 *
291  DO 50 j = 1, n
292  DO 40 i = j, m
293  a( i, j ) = a( i, j )*mul
294  40 CONTINUE
295  50 CONTINUE
296 *
297  ELSE IF( itype.EQ.2 ) THEN
298 *
299 * Upper triangular matrix
300 *
301  DO 70 j = 1, n
302  DO 60 i = 1, min( j, m )
303  a( i, j ) = a( i, j )*mul
304  60 CONTINUE
305  70 CONTINUE
306 *
307  ELSE IF( itype.EQ.3 ) THEN
308 *
309 * Upper Hessenberg matrix
310 *
311  DO 90 j = 1, n
312  DO 80 i = 1, min( j+1, m )
313  a( i, j ) = a( i, j )*mul
314  80 CONTINUE
315  90 CONTINUE
316 *
317  ELSE IF( itype.EQ.4 ) THEN
318 *
319 * Lower half of a symmetric band matrix
320 *
321  k3 = kl + 1
322  k4 = n + 1
323  DO 110 j = 1, n
324  DO 100 i = 1, min( k3, k4-j )
325  a( i, j ) = a( i, j )*mul
326  100 CONTINUE
327  110 CONTINUE
328 *
329  ELSE IF( itype.EQ.5 ) THEN
330 *
331 * Upper half of a symmetric band matrix
332 *
333  k1 = ku + 2
334  k3 = ku + 1
335  DO 130 j = 1, n
336  DO 120 i = max( k1-j, 1 ), k3
337  a( i, j ) = a( i, j )*mul
338  120 CONTINUE
339  130 CONTINUE
340 *
341  ELSE IF( itype.EQ.6 ) THEN
342 *
343 * Band matrix
344 *
345  k1 = kl + ku + 2
346  k2 = kl + 1
347  k3 = 2*kl + ku + 1
348  k4 = kl + ku + 1 + m
349  DO 150 j = 1, n
350  DO 140 i = max( k1-j, k2 ), min( k3, k4-j )
351  a( i, j ) = a( i, j )*mul
352  140 CONTINUE
353  150 CONTINUE
354 *
355  END IF
356 *
357  IF( .NOT.done )
358  $ GO TO 10
359 *
360  RETURN
361 *
362 * End of ZLASCL
363 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
logical function disnan(DIN)
DISNAN tests input for NaN.
Definition: disnan.f:61

Here is the call graph for this function:

Here is the caller graph for this function: