1 SUBROUTINE pzmatgen( ICTXT, AFORM, DIAG, M, N, MB, NB, A, LDA,
2 $ IAROW, IACOL, ISEED, IROFF, IRNUM, ICOFF,
3 $ ICNUM, MYROW, MYCOL, NPROW, NPCOL )
11 CHARACTER*1 AFORM, DIAG
12 INTEGER IACOL, IAROW, ICNUM, ICOFF, ICTXT, IRNUM,
13 $ iroff, iseed, lda, m, mb, mycol, myrow, n,
17 COMPLEX*16 A( LDA, * )
115 INTEGER MULT0, MULT1, IADD0, IADD1
116 PARAMETER ( MULT0=20077, mult1=16838, iadd0=12345,
118 DOUBLE PRECISION ONE, TWO, ZERO
119 PARAMETER ( ONE = 1.0d+0, two = 2.0d+0, zero = 0.0d+0 )
122 LOGICAL SYMM, HERM, TRAN
123 INTEGER I, IC, IK, INFO, IOFFC, IOFFR, IR, J, JK,
124 $ jump1, jump2, jump3, jump4, jump5, jump6,
125 $ jump7, maxmn, mend, moff, mp, mrcol, mrrow,
126 $ nend, noff, npmb, nq, nqnb
127 DOUBLE PRECISION DUMMY
130 INTEGER IADD(2), IA1(2), IA2(2), IA3(2), IA4(2),
131 $ IA5(2), IB1(2), IB2(2), IB3(2), IC1(2), IC2(2),
132 $ ic3(2), ic4(2), ic5(2), iran1(2), iran2(2),
133 $ iran3(2), iran4(2), itmp1(2), itmp2(2),
134 $ itmp3(2), jseed(2), mult(2)
140 INTRINSIC abs, dble, dcmplx, dconjg, dimag,
max, mod
144 INTEGER ICEIL, NUMROC
145 DOUBLE PRECISION PDRAND
146 EXTERNAL iceil, numroc, lsame, pdrand
152 mp = numroc( m, mb, myrow, iarow, nprow )
153 nq = numroc( n, nb, mycol, iacol, npcol )
154 symm = lsame( aform,
'S' )
155 herm = lsame( aform,
'H' )
156 tran = lsame( aform,
'T' )
159 IF( .NOT.lsame( diag,
'D' ) .AND.
160 $ .NOT.lsame( diag,
'N' ) )
THEN
162 ELSE IF( symm.OR.herm )
THEN
165 ELSE IF( mb.NE.nb )
THEN
168 ELSE IF( m.LT.0 )
THEN
170 ELSE IF( n.LT.0 )
THEN
172 ELSE IF( mb.LT.1 )
THEN
174 ELSE IF( nb.LT.1 )
THEN
176 ELSE IF( lda.LT.0 )
THEN
178 ELSE IF( ( iarow.LT.0 ).OR.( iarow.GE.nprow ) )
THEN
180 ELSE IF( ( iacol.LT.0 ).OR.( iacol.GE.npcol ) )
THEN
182 ELSE IF( mod(iroff,mb).GT.0 )
THEN
184 ELSE IF( irnum.GT.(mp-iroff) )
THEN
186 ELSE IF( mod(icoff,nb).GT.0 )
THEN
188 ELSE IF( icnum.GT.(nq-icoff) )
THEN
190 ELSE IF( ( myrow.LT.0 ).OR.( myrow.GE.nprow ) )
THEN
192 ELSE IF( ( mycol.LT.0 ).OR.( mycol.GE.npcol ) )
THEN
196 CALL pxerbla( ictxt,
'PZMATGEN', info )
200 mrrow = mod( nprow+myrow-iarow, nprow )
201 mrcol = mod( npcol+mycol-iacol, npcol )
206 mend = iceil(irnum, mb) + moff
207 nend = iceil(icnum, nb) + noff
218 IF( symm.OR.herm )
THEN
230 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
231 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
232 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
233 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
234 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
235 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
236 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
237 CALL xjumpm( noff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
238 CALL xjumpm( moff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
239 CALL setran( iran1, ia1, ic1 )
248 DO 80 ic = noff+1, nend
249 ioffc = ((ic-1)*npcol+mrcol) * nb
251 IF( jk .GT. icnum )
GO TO 90
254 DO 50 ir = moff+1, mend
255 ioffr = ((ir-1)*nprow+mrrow) * mb
257 IF( ioffr .GT. ioffc )
THEN
259 IF( ik .GT. irnum )
GO TO 60
260 a(ik,jk) = dcmplx( one - two*pdrand(0),
261 $ one - two*pdrand(0) )
265 ELSE IF( ioffc .EQ. ioffr )
THEN
267 IF( ik .GT. irnum )
GO TO 60
269 a(ik,jk) = dcmplx( pdrand(0), pdrand(0) )
272 a(ik,jk) = dcmplx( one - two*pdrand(0),
273 $ one - two*pdrand(0) )
275 a(ik,jk) = dcmplx( one - two*pdrand(0), zero )
279 IF( ik+j .GT. irnum )
GO TO 60
280 a(ik+j,jk) = dcmplx( one - two*pdrand(0),
281 $ one - two*pdrand(0) )
283 a(ik,jk+j) = dconjg( a(ik+j,jk) )
285 a(ik,jk+j) = a(ik+j,jk)
293 CALL jumpit( ia2, ic2, ib1, iran2 )
300 CALL jumpit( ia3, ic3, ib2, iran3 )
307 CALL jumpit( ia4, ic4, ib3, iran4 )
334 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
335 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
336 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
337 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
338 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
339 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
340 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
341 CALL xjumpm( moff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
342 CALL xjumpm( noff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
343 CALL setran( iran1, ia1, ic1 )
352 DO 150 ir = moff+1, mend
353 ioffr = ((ir-1)*nprow+mrrow) * mb
355 IF( ik .GT. irnum )
GO TO 160
357 DO 120 ic = noff+1, nend
358 ioffc = ((ic-1)*npcol+mrcol) * nb
359 IF( ioffc .GT. ioffr )
THEN
361 IF( jk .GT. icnum )
GO TO 130
363 a(ik,jk) = dcmplx( one - two*pdrand(0),
364 $ one - two*pdrand(0) )
366 a(ik,jk) = dcmplx( one - two*pdrand(0),
367 $ two*pdrand(0) - one )
374 CALL jumpit( ia2, ic2, ib1, iran2 )
381 CALL jumpit( ia3, ic3, ib2, iran3 )
388 CALL jumpit( ia4, ic4, ib3, iran4 )
400 ELSE IF( tran .OR. lsame( aform,
'C' ) )
THEN
410 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
411 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
412 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
413 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
414 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
415 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
416 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
417 CALL xjumpm( moff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
418 CALL xjumpm( noff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
419 CALL setran( iran1, ia1, ic1 )
428 DO 220 ir = moff+1, mend
429 ioffr = ((ir-1)*nprow+mrrow) * mb
431 IF( ik .GT. irnum )
GO TO 230
433 DO 190 ic = noff+1, nend
434 ioffc = ((ic-1)*npcol+mrcol) * nb
436 IF( jk .GT. icnum )
GO TO 200
438 a(ik,jk) = dcmplx( one - two*pdrand(0),
439 $ one - two*pdrand(0) )
441 a(ik,jk) = dcmplx( one - two*pdrand(0),
442 $ two*pdrand(0) - one )
446 CALL jumpit( ia2, ic2, ib1, iran2 )
453 CALL jumpit( ia3, ic3, ib2, iran3 )
460 CALL jumpit( ia4, ic4, ib3, iran4 )
482 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
483 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
484 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
485 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
486 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
487 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
488 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
489 CALL xjumpm( noff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
490 CALL xjumpm( moff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
491 CALL setran( iran1, ia1, ic1 )
500 DO 290 ic = noff+1, nend
501 ioffc = ((ic-1)*npcol+mrcol) * nb
503 IF( jk .GT. icnum )
GO TO 300
505 DO 260 ir = moff+1, mend
506 ioffr = ((ir-1)*nprow+mrrow) * mb
508 IF( ik .GT. irnum )
GO TO 270
509 a(ik,jk) = dcmplx( one - two*pdrand(0),
510 $ one - two*pdrand(0) )
513 CALL jumpit( ia2, ic2, ib1, iran2 )
520 CALL jumpit( ia3, ic3, ib2, iran3 )
527 CALL jumpit( ia4, ic4, ib3, iran4 )
540 IF( lsame( diag,
'D' ) )
THEN
542 WRITE(*,*)
'Diagonally dominant matrices with rowNB not'//
543 $
' equal colNB is not supported!'
549 DO 340 ic = noff+1, nend
550 ioffc = ((ic-1)*npcol+mrcol) * nb
552 DO 320 ir = moff+1, mend
553 ioffr = ((ir-1)*nprow+mrrow) * mb
554 IF( ioffc.EQ.ioffr )
THEN
556 IF( ik .GT. irnum )
GO TO 330
559 $ abs(dble(a(ik,jk+j)))+2*maxmn, zero )
561 a(ik,jk+j)= dcmplx( abs(dble(a(ik,jk+j)))+maxmn,
562 $ abs(dimag(a(ik,jk+j)))+ maxmn )