PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zlascl.f
Go to the documentation of this file.
1  SUBROUTINE zlascl( TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO )
2 *
3 * -- LAPACK auxiliary routine (version 3.2) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  CHARACTER type
9  INTEGER info, kl, ku, lda, m, n
10  DOUBLE PRECISION cfrom, cto
11 * ..
12 * .. Array Arguments ..
13  COMPLEX*16 a( lda, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZLASCL multiplies the M by N complex matrix A by the real scalar
20 * CTO/CFROM. This is done without over/underflow as long as the final
21 * result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that
22 * A may be full, upper triangular, lower triangular, upper Hessenberg,
23 * or banded.
24 *
25 * Arguments
26 * =========
27 *
28 * TYPE (input) CHARACTER*1
29 * TYPE indices the storage type of the input matrix.
30 * = 'G': A is a full matrix.
31 * = 'L': A is a lower triangular matrix.
32 * = 'U': A is an upper triangular matrix.
33 * = 'H': A is an upper Hessenberg matrix.
34 * = 'B': A is a symmetric band matrix with lower bandwidth KL
35 * and upper bandwidth KU and with the only the lower
36 * half stored.
37 * = 'Q': A is a symmetric band matrix with lower bandwidth KL
38 * and upper bandwidth KU and with the only the upper
39 * half stored.
40 * = 'Z': A is a band matrix with lower bandwidth KL and upper
41 * bandwidth KU.
42 *
43 * KL (input) INTEGER
44 * The lower bandwidth of A. Referenced only if TYPE = 'B',
45 * 'Q' or 'Z'.
46 *
47 * KU (input) INTEGER
48 * The upper bandwidth of A. Referenced only if TYPE = 'B',
49 * 'Q' or 'Z'.
50 *
51 * CFROM (input) DOUBLE PRECISION
52 * CTO (input) DOUBLE PRECISION
53 * The matrix A is multiplied by CTO/CFROM. A(I,J) is computed
54 * without over/underflow if the final result CTO*A(I,J)/CFROM
55 * can be represented without over/underflow. CFROM must be
56 * nonzero.
57 *
58 * M (input) INTEGER
59 * The number of rows of the matrix A. M >= 0.
60 *
61 * N (input) INTEGER
62 * The number of columns of the matrix A. N >= 0.
63 *
64 * A (input/output) COMPLEX*16 array, dimension (LDA,N)
65 * The matrix to be multiplied by CTO/CFROM. See TYPE for the
66 * storage type.
67 *
68 * LDA (input) INTEGER
69 * The leading dimension of the array A. LDA >= max(1,M).
70 *
71 * INFO (output) INTEGER
72 * 0 - successful exit
73 * <0 - if INFO = -i, the i-th argument had an illegal value.
74 *
75 * =====================================================================
76 *
77 * .. Parameters ..
78  DOUBLE PRECISION zero, one
79  parameter( zero = 0.0d0, one = 1.0d0 )
80 * ..
81 * .. Local Scalars ..
82  LOGICAL done
83  INTEGER i, itype, j, k1, k2, k3, k4
84  DOUBLE PRECISION bignum, cfrom1, cfromc, cto1, ctoc, mul, smlnum
85 * ..
86 * .. External Functions ..
87  LOGICAL lsame, disnan
88  DOUBLE PRECISION dlamch
89  EXTERNAL lsame, dlamch, disnan
90 * ..
91 * .. Intrinsic Functions ..
92  INTRINSIC abs, max, min
93 * ..
94 * .. External Subroutines ..
95  EXTERNAL xerbla
96 * ..
97 * .. Executable Statements ..
98 *
99 * Test the input arguments
100 *
101  info = 0
102 *
103  IF( lsame( type, 'G' ) ) THEN
104  itype = 0
105  ELSE IF( lsame( type, 'L' ) ) THEN
106  itype = 1
107  ELSE IF( lsame( type, 'U' ) ) THEN
108  itype = 2
109  ELSE IF( lsame( type, 'H' ) ) THEN
110  itype = 3
111  ELSE IF( lsame( type, 'B' ) ) THEN
112  itype = 4
113  ELSE IF( lsame( type, 'Q' ) ) THEN
114  itype = 5
115  ELSE IF( lsame( type, 'Z' ) ) THEN
116  itype = 6
117  ELSE
118  itype = -1
119  END IF
120 *
121  IF( itype.EQ.-1 ) THEN
122  info = -1
123  ELSE IF( cfrom.EQ.zero .OR. disnan(cfrom) ) THEN
124  info = -4
125  ELSE IF( disnan(cto) ) THEN
126  info = -5
127  ELSE IF( m.LT.0 ) THEN
128  info = -6
129  ELSE IF( n.LT.0 .OR. ( itype.EQ.4 .AND. n.NE.m ) .OR.
130  $ ( itype.EQ.5 .AND. n.NE.m ) ) THEN
131  info = -7
132  ELSE IF( itype.LE.3 .AND. lda.LT.max( 1, m ) ) THEN
133  info = -9
134  ELSE IF( itype.GE.4 ) THEN
135  IF( kl.LT.0 .OR. kl.GT.max( m-1, 0 ) ) THEN
136  info = -2
137  ELSE IF( ku.LT.0 .OR. ku.GT.max( n-1, 0 ) .OR.
138  $ ( ( itype.EQ.4 .OR. itype.EQ.5 ) .AND. kl.NE.ku ) )
139  $ THEN
140  info = -3
141  ELSE IF( ( itype.EQ.4 .AND. lda.LT.kl+1 ) .OR.
142  $ ( itype.EQ.5 .AND. lda.LT.ku+1 ) .OR.
143  $ ( itype.EQ.6 .AND. lda.LT.2*kl+ku+1 ) ) THEN
144  info = -9
145  END IF
146  END IF
147 *
148  IF( info.NE.0 ) THEN
149  CALL xerbla( 'ZLASCL', -info )
150  return
151  END IF
152 *
153 * Quick return if possible
154 *
155  IF( n.EQ.0 .OR. m.EQ.0 )
156  $ return
157 *
158 * Get machine parameters
159 *
160  smlnum = dlamch( 'S' )
161  bignum = one / smlnum
162 *
163  cfromc = cfrom
164  ctoc = cto
165 *
166  10 continue
167  cfrom1 = cfromc*smlnum
168  IF( cfrom1.EQ.cfromc ) THEN
169 ! CFROMC is an inf. Multiply by a correctly signed zero for
170 ! finite CTOC, or a NaN if CTOC is infinite.
171  mul = ctoc / cfromc
172  done = .true.
173  cto1 = ctoc
174  ELSE
175  cto1 = ctoc / bignum
176  IF( cto1.EQ.ctoc ) THEN
177 ! CTOC is either 0 or an inf. In both cases, CTOC itself
178 ! serves as the correct multiplication factor.
179  mul = ctoc
180  done = .true.
181  cfromc = one
182  ELSE IF( abs( cfrom1 ).GT.abs( ctoc ) .AND. ctoc.NE.zero ) THEN
183  mul = smlnum
184  done = .false.
185  cfromc = cfrom1
186  ELSE IF( abs( cto1 ).GT.abs( cfromc ) ) THEN
187  mul = bignum
188  done = .false.
189  ctoc = cto1
190  ELSE
191  mul = ctoc / cfromc
192  done = .true.
193  END IF
194  END IF
195 *
196  IF( itype.EQ.0 ) THEN
197 *
198 * Full matrix
199 *
200  DO 30 j = 1, n
201  DO 20 i = 1, m
202  a( i, j ) = a( i, j )*mul
203  20 continue
204  30 continue
205 *
206  ELSE IF( itype.EQ.1 ) THEN
207 *
208 * Lower triangular matrix
209 *
210  DO 50 j = 1, n
211  DO 40 i = j, m
212  a( i, j ) = a( i, j )*mul
213  40 continue
214  50 continue
215 *
216  ELSE IF( itype.EQ.2 ) THEN
217 *
218 * Upper triangular matrix
219 *
220  DO 70 j = 1, n
221  DO 60 i = 1, min( j, m )
222  a( i, j ) = a( i, j )*mul
223  60 continue
224  70 continue
225 *
226  ELSE IF( itype.EQ.3 ) THEN
227 *
228 * Upper Hessenberg matrix
229 *
230  DO 90 j = 1, n
231  DO 80 i = 1, min( j+1, m )
232  a( i, j ) = a( i, j )*mul
233  80 continue
234  90 continue
235 *
236  ELSE IF( itype.EQ.4 ) THEN
237 *
238 * Lower half of a symmetric band matrix
239 *
240  k3 = kl + 1
241  k4 = n + 1
242  DO 110 j = 1, n
243  DO 100 i = 1, min( k3, k4-j )
244  a( i, j ) = a( i, j )*mul
245  100 continue
246  110 continue
247 *
248  ELSE IF( itype.EQ.5 ) THEN
249 *
250 * Upper half of a symmetric band matrix
251 *
252  k1 = ku + 2
253  k3 = ku + 1
254  DO 130 j = 1, n
255  DO 120 i = max( k1-j, 1 ), k3
256  a( i, j ) = a( i, j )*mul
257  120 continue
258  130 continue
259 *
260  ELSE IF( itype.EQ.6 ) THEN
261 *
262 * Band matrix
263 *
264  k1 = kl + ku + 2
265  k2 = kl + 1
266  k3 = 2*kl + ku + 1
267  k4 = kl + ku + 1 + m
268  DO 150 j = 1, n
269  DO 140 i = max( k1-j, k2 ), min( k3, k4-j )
270  a( i, j ) = a( i, j )*mul
271  140 continue
272  150 continue
273 *
274  END IF
275 *
276  IF( .NOT.done )
277  $ go to 10
278 *
279  return
280 *
281 * End of ZLASCL
282 *
283  END