ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pzqrt13.f
Go to the documentation of this file.
1  SUBROUTINE pzqrt13( SCALE, M, N, A, IA, JA, DESCA, NORMA, ISEED,
2  $ WORK )
3 *
4 * -- ScaLAPACK routine (version 1.7) --
5 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6 * and University of California, Berkeley.
7 * May 1, 1997
8 *
9 * .. Scalar Arguments ..
10  INTEGER IA, ISEED, JA, M, N, SCALE
11  DOUBLE PRECISION NORMA
12 * ..
13 * .. Array Arguments ..
14  INTEGER DESCA( * )
15  DOUBLE PRECISION WORK( * )
16  COMPLEX*16 A( * )
17 * ..
18 *
19 * Purpose
20 * =======
21 *
22 * PZQRT13 generates a full-rank matrix that may be scaled to have
23 * large or small norm.
24 *
25 * Notes
26 * =====
27 *
28 * Each global data object is described by an associated description
29 * vector. This vector stores the information required to establish
30 * the mapping between an object element and its corresponding process
31 * and memory location.
32 *
33 * Let A be a generic term for any 2D block cyclicly distributed array.
34 * Such a global array has an associated description vector DESCA.
35 * In the following comments, the character _ should be read as
36 * "of the global array".
37 *
38 * NOTATION STORED IN EXPLANATION
39 * --------------- -------------- --------------------------------------
40 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
41 * DTYPE_A = 1.
42 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
43 * the BLACS process grid A is distribu-
44 * ted over. The context itself is glo-
45 * bal, but the handle (the integer
46 * value) may vary.
47 * M_A (global) DESCA( M_ ) The number of rows in the global
48 * array A.
49 * N_A (global) DESCA( N_ ) The number of columns in the global
50 * array A.
51 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
52 * the rows of the array.
53 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
54 * the columns of the array.
55 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
56 * row of the array A is distributed.
57 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the
58 * first column of the array A is
59 * distributed.
60 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
61 * array. LLD_A >= MAX(1,LOCr(M_A)).
62 *
63 * Let K be the number of rows or columns of a distributed matrix,
64 * and assume that its process grid has dimension p x q.
65 * LOCr( K ) denotes the number of elements of K that a process
66 * would receive if K were distributed over the p processes of its
67 * process column.
68 * Similarly, LOCc( K ) denotes the number of elements of K that a
69 * process would receive if K were distributed over the q processes of
70 * its process row.
71 * The values of LOCr() and LOCc() may be determined via a call to the
72 * ScaLAPACK tool function, NUMROC:
73 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
74 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
75 * An upper bound for these quantities may be computed by:
76 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
77 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
78 *
79 * Arguments
80 * =========
81 *
82 * SCALE (global input) INTEGER
83 * SCALE = 1: normally scaled matrix
84 * SCALE = 2: matrix scaled up
85 * SCALE = 3: matrix scaled down
86 *
87 * M (global input) INTEGER
88 * The number of rows to be operated on, i.e. the number of rows
89 * of the distributed submatrix sub( A ). M >= 0.
90 *
91 * N (global input) INTEGER
92 * The number of columns to be operated on, i.e. the number of
93 * columns of the distributed submatrix sub( A ). N >= 0.
94 *
95 * A (local output) COMPLEX*16 pointer into the local memory
96 * to an array of dimension (LLD_A,LOCc(JA+N-1)). This array
97 * contains the local pieces of the distributed matrix sub( A ).
98 *
99 * IA (global input) INTEGER
100 * The row index in the global array A indicating the first
101 * row of sub( A ).
102 *
103 * JA (global input) INTEGER
104 * The column index in the global array A indicating the
105 * first column of sub( A ).
106 *
107 * DESCA (global and local input) INTEGER array of dimension DLEN_.
108 * The array descriptor for the distributed matrix A.
109 *
110 * NORMA (global output) DOUBLE PRECISION
111 * The one-norm of A.
112 *
113 * ISEED (global input/global output) INTEGER
114 * Seed for random number generator.
115 *
116 * WORK (local workspace) DOUBLE PRECISION array, dimension (LWORK)
117 * LWORK >= Nq0, where
118 *
119 * ICOFFA = MOD( JA-1, NB_A ),
120 * IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ), and
121 * Nq0 = NUMROC( N+ICOFFA, NB_A, MYCOL, IACOL, NPCOL ).
122 *
123 * INDXG2P and NUMROC are ScaLAPACK tool functions; MYROW,
124 * MYCOL, NPROW and NPCOL can be determined by calling the
125 * subroutine BLACS_GRIDINFO.
126 *
127 * =====================================================================
128 *
129 * .. Parameters ..
130  INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
131  $ lld_, mb_, m_, nb_, n_, rsrc_
132  parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
133  $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
134  $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
135  DOUBLE PRECISION ONE
136  parameter( one = 1.0d0 )
137 * ..
138 * .. Local Scalars ..
139  INTEGER I, IACOL, IAROW, ICOFFA, ICTXT, IIA, INFO,
140  $ iroffa, j, jja, mp, mycol, myrow, npcol,
141  $ nprow, nq
142  DOUBLE PRECISION ASUM, BIGNUM, SMLNUM
143  COMPLEX*16 AJJ
144 * ..
145 * .. External Functions ..
146  INTEGER NUMROC
147  DOUBLE PRECISION PDLAMCH, PZLANGE
148  EXTERNAL numroc, pdlamch, pdlange
149 * ..
150 * .. External Subroutines ..
151  EXTERNAL blacs_gridinfo, infog2l, pdlabad,
152  $ pdzasum, pzlascl, pzmatgen,
153  $ pzelget, pzelset
154 * ..
155 * .. Intrinsic Functions ..
156  INTRINSIC dble, dcmplx, mod, sign
157 * ..
158 * .. Executable Statements ..
159 *
160  ictxt = desca( ctxt_ )
161  CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
162 *
163  IF( m.LE.0 .OR. n.LE.0 )
164  $ RETURN
165 *
166 * generate the matrix
167 *
168  iroffa = mod( ia-1, desca( mb_ ) )
169  icoffa = mod( ja-1, desca( nb_ ) )
170  CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia,
171  $ jja, iarow, iacol )
172  mp = numroc( m+iroffa, desca( mb_ ), myrow, iarow, nprow )
173  nq = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
174  IF( myrow.EQ.iarow )
175  $ mp = mp - iroffa
176  IF( mycol.EQ.iacol )
177  $ nq = nq - icoffa
178 *
179  CALL pzmatgen( ictxt, 'N', 'N', desca( m_ ), desca( n_ ),
180  $ desca( mb_ ), desca( nb_ ), a, desca( lld_ ),
181  $ desca( rsrc_ ), desca( csrc_ ), iseed, iia-1, mp,
182  $ jja-1, nq, myrow, mycol, nprow, npcol )
183 *
184  DO 10 j = ja, ja+n-1
185  i = ia + j - ja
186  IF( i.LE.ia+m-1 ) THEN
187  CALL pdzasum( m, asum, a, ia, j, desca, 1 )
188  CALL pzelget( 'Column', ' ', ajj, a, i, j, desca )
189  ajj = ajj + dcmplx( sign( asum, dble( ajj ) ) )
190  CALL pzelset( a, i, j, desca, ajj )
191  END IF
192  10 CONTINUE
193 *
194 * scaled versions
195 *
196  IF( scale.NE.1 ) THEN
197 *
198  norma = pzlange( 'M', m, n, a, ia, ja, desca, work )
199  smlnum = pdlamch( ictxt, 'Safe minimum' )
200  bignum = one / smlnum
201  CALL pdlabad( ictxt, smlnum, bignum )
202  smlnum = smlnum / pdlamch( ictxt, 'Epsilon' )
203  bignum = one / smlnum
204 *
205  IF( scale.EQ.2 ) THEN
206 *
207 * matrix scaled up
208 *
209  CALL pzlascl( 'General', norma, bignum, m, n, a, ia,
210  $ ja, desca, info )
211 *
212  ELSE IF( scale.EQ.3 ) THEN
213 *
214 * matrix scaled down
215 *
216  CALL pzlascl( 'General', norma, smlnum, m, n, a, ia,
217  $ ja, desca, info )
218 *
219  END IF
220 *
221  END IF
222 *
223  norma = pzlange( 'One-norm', m, n, a, ia, ja, desca, work )
224 *
225  RETURN
226 *
227 * End of PZQRT13
228 *
229  END
pzelget
subroutine pzelget(SCOPE, TOP, ALPHA, A, IA, JA, DESCA)
Definition: pzelget.f:2
infog2l
subroutine infog2l(GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW, MYCOL, LRINDX, LCINDX, RSRC, CSRC)
Definition: infog2l.f:3
pdlabad
subroutine pdlabad(ICTXT, SMALL, LARGE)
Definition: pdlabad.f:2
pzlascl
subroutine pzlascl(TYPE, CFROM, CTO, M, N, A, IA, JA, DESCA, INFO)
Definition: pzlascl.f:3
pzqrt13
subroutine pzqrt13(SCALE, M, N, A, IA, JA, DESCA, NORMA, ISEED, WORK)
Definition: pzqrt13.f:3
pzmatgen
subroutine pzmatgen(ICTXT, AFORM, DIAG, M, N, MB, NB, A, LDA, IAROW, IACOL, ISEED, IROFF, IRNUM, ICOFF, ICNUM, MYROW, MYCOL, NPROW, NPCOL)
Definition: pzmatgen.f:4
pdlange
double precision function pdlange(NORM, M, N, A, IA, JA, DESCA, WORK)
Definition: pdlange.f:3
pzelset
subroutine pzelset(A, IA, JA, DESCA, ALPHA)
Definition: pzelset.f:2