ScaLAPACK 2.1  2.1 ScaLAPACK: Scalable Linear Algebra PACKage
Go to the documentation of this file.
1  SUBROUTINE ctzpadcpy( UPLO, DIAG, M, N, IOFFD, A, LDA, B, LDB )
2 *
3 * -- PBLAS auxiliary routine (version 2.0) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * April 1, 1998
7 *
8 * .. Scalar Arguments ..
9  CHARACTER*1 DIAG, UPLO
10  INTEGER IOFFD, LDA, LDB, M, N
11 * ..
12 * .. Array Arguments ..
13  COMPLEX A( LDA, * ), B( LDB, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * CTZPADCPY copies an array A into an array B. The unchanged part of B
20 * is padded with zeros. The diagonal of B specified by IOFFD may be set
21 * to ones.
22 *
23 * Arguments
24 * =========
25 *
26 * UPLO (input) CHARACTER*1
27 * On entry, UPLO specifies which trapezoidal part of the ar-
28 * ray A is to be copied as follows:
29 * = 'L' or 'l': Lower triangular part is copied; the
30 * strictly upper triangular part of B is
31 * padded with zeros,
32 * = 'U' or 'u': Upper triangular part is copied; the
33 * strictly lower triangular part of B is
34 * padded with zeros.
35 *
36 * DIAG (input) CHARACTER*1
37 * On entry, DIAG specifies whether or not the diagonal of B is
38 * to be set to ones or not as follows:
39 *
40 * DIAG = 'N' or 'n': the diagonals of A are copied into the
41 * diagonals of B, otherwise the diagonals of B are set to ones.
42 *
43 * M (input) INTEGER
44 * On entry, M specifies the number of rows of the array A. M
45 * must be at least zero.
46 *
47 * N (input) INTEGER
48 * On entry, N specifies the number of columns of the array A.
49 * N must be at least zero.
50 *
51 * IOFFD (input) INTEGER
52 * On entry, IOFFD specifies the position of the offdiagonal de-
53 * limiting the upper and lower trapezoidal part of A as follows
54 * (see the notes below):
55 *
56 * IOFFD = 0 specifies the main diagonal A( i, i ),
57 * with i = 1 ... MIN( M, N ),
58 * IOFFD > 0 specifies the subdiagonal A( i+IOFFD, i ),
59 * with i = 1 ... MIN( M-IOFFD, N ),
60 * IOFFD < 0 specifies the superdiagonal A( i, i-IOFFD ),
61 * with i = 1 ... MIN( M, N+IOFFD ).
62 *
63 * A (input) COMPLEX array
64 * On entry, A is an array of dimension (LDA,N). Before entry
65 * with UPLO = 'U', the leading m by n part of the array A must
66 * contain the upper trapezoidal part of the matrix to be copied
67 * as specified by IOFFD, UPLO and DIAG, and the strictly lower
68 * trapezoidal part of A is not referenced; When UPLO = 'L',the
69 * leading m by n part of the array A must contain the lower
70 * trapezoidal part of the matrix to be copied as specified by
71 * IOFFD, UPLO and DIAG and the strictly upper trapezoidal part
72 * of A is not referenced.
73 *
74 * LDA (input) INTEGER
75 * On entry, LDA specifies the leading dimension of the array A.
76 * LDA must be at least max( 1, M ).
77 *
78 * B (output) COMPLEX array
79 * On entry, B is an array of dimension (LDB,N). On exit, this
80 * array contains the padded copy of A as specified by IOFFD,
81 * UPLO and DIAG.
82 *
83 * LDB (input) INTEGER
84 * On entry, LDB specifies the leading dimension of the array B.
85 * LDB must be at least max( 1, M ).
86 *
87 * Notes
88 * =====
89 * N N
90 * ---------------------------- -----------
91 * | d | | |
92 * M | d 'U' | | 'U' |
93 * | 'L' 'D' | |d |
94 * | d | M | d |
95 * ---------------------------- | 'D' |
96 * | d |
97 * IOFFD < 0 | 'L' d |
98 * | d|
99 * N | |
100 * ----------- -----------
101 * | d 'U'|
102 * | d | IOFFD > 0
103 * M | 'D' |
104 * | d| N
105 * | 'L' | ----------------------------
106 * | | | 'U' |
107 * | | |d |
108 * | | | 'D' |
109 * | | | d |
110 * | | |'L' d |
111 * ----------- ----------------------------
112 *
113 * -- Written on April 1, 1998 by
114 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
115 *
116 * =====================================================================
117 *
118 * .. Parameters ..
119  COMPLEX ONE, ZERO
120  parameter( one = ( 1.0e+0, 0.0e+0 ),
121  \$ zero = ( 0.0e+0, 0.0e+0 ) )
122 * ..
123 * .. Local Scalars ..
124  INTEGER I, ITMP, J, JTMP, MN
125 * ..
126 * .. External Functions ..
127  LOGICAL LSAME
128  EXTERNAL lsame
129 * ..
130 * .. Intrinsic Functions ..
131  INTRINSIC max, min
132 * .. Executable Statements ..
133 *
134 * Quick return if possible
135 *
136  IF( m.LE.0 .OR. n.LE.0 )
137  \$ RETURN
138 *
139 * Start the operations
140 *
141  IF( lsame( uplo, 'L' ) ) THEN
142 *
143  mn = max( 0, -ioffd )
144  DO 20 j = 1, min( mn, n )
145  DO 10 i = 1, m
146  b( i, j ) = a( i, j )
147  10 CONTINUE
148  20 CONTINUE
149 *
150  jtmp = min( m - ioffd, n )
151 *
152  IF( lsame( diag, 'N' ) ) THEN
153  DO 50 j = mn + 1, jtmp
154  itmp = j + ioffd
155  DO 30 i = 1, itmp - 1
156  b( i, j ) = zero
157  30 CONTINUE
158  DO 40 i = itmp, m
159  b( i, j ) = a( i, j )
160  40 CONTINUE
161  50 CONTINUE
162  ELSE
163  DO 80 j = mn + 1, jtmp
164  itmp = j + ioffd
165  DO 60 i = 1, itmp - 1
166  b( i, j ) = zero
167  60 CONTINUE
168  b( itmp, j ) = one
169  DO 70 i = itmp + 1, m
170  b( i, j ) = a( i, j )
171  70 CONTINUE
172  80 CONTINUE
173  END IF
174 *
175  DO 100 j = jtmp + 1, n
176  DO 90 i = 1, m
177  b( i, j ) = zero
178  90 CONTINUE
179  100 CONTINUE
180 *
181  ELSE IF( lsame( uplo, 'U' ) ) THEN
182 *
183  jtmp = max( 0, -ioffd )
184 *
185  DO 120 j = 1, jtmp
186  DO 110 i = 1, m
187  b( i, j ) = zero
188  110 CONTINUE
189  120 CONTINUE
190 *
191  mn = min( m - ioffd, n )
192 *
193  IF( lsame( diag, 'N' ) ) THEN
194  DO 150 j = jtmp + 1, mn
195  itmp = j + ioffd
196  DO 130 i = 1, itmp
197  b( i, j ) = a( i, j )
198  130 CONTINUE
199  DO 140 i = itmp + 1, m
200  b( i, j ) = zero
201  140 CONTINUE
202  150 CONTINUE
203  ELSE
204  DO 180 j = jtmp + 1, mn
205  itmp = j + ioffd
206  DO 160 i = 1, itmp - 1
207  b( i, j ) = a( i, j )
208  160 CONTINUE
209  b( itmp, j ) = one
210  DO 170 i = itmp + 1, m
211  b( i, j ) = zero
212  170 CONTINUE
213  180 CONTINUE
214  END IF
215 *
216  DO 200 j = max( 0, mn ) + 1, n
217  DO 190 i = 1, m
218  b( i, j ) = a( i, j )
219  190 CONTINUE
220  200 CONTINUE
221 *
222  ELSE
223 *
224  DO 220 j = 1, n
225  DO 210 i = 1, m
226  b( i, j ) = a( i, j )
227  210 CONTINUE
228  220 CONTINUE
229 *
230  END IF
231 *
232  RETURN
233 *
234 * End of CTZPADCPY
235 *
236  END
max
#define max(A, B)
Definition: pcgemr.c:180