SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pzlagen()

subroutine pzlagen ( logical  inplace,
character*1  aform,
character*1  diag,
integer  offa,
integer  m,
integer  n,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
integer  iaseed,
complex*16, dimension( lda, * )  a,
integer  lda 
)

Definition at line 8490 of file pzblastst.f.

8492*
8493* -- PBLAS test routine (version 2.0) --
8494* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
8495* and University of California, Berkeley.
8496* April 1, 1998
8497*
8498* .. Scalar Arguments ..
8499 LOGICAL INPLACE
8500 CHARACTER*1 AFORM, DIAG
8501 INTEGER IA, IASEED, JA, LDA, M, N, OFFA
8502* ..
8503* .. Array Arguments ..
8504 INTEGER DESCA( * )
8505 COMPLEX*16 A( LDA, * )
8506* ..
8507*
8508* Purpose
8509* =======
8510*
8511* PZLAGEN generates (or regenerates) a submatrix sub( A ) denoting
8512* A(IA:IA+M-1,JA:JA+N-1).
8513*
8514* Notes
8515* =====
8516*
8517* A description vector is associated with each 2D block-cyclicly dis-
8518* tributed matrix. This vector stores the information required to
8519* establish the mapping between a matrix entry and its corresponding
8520* process and memory location.
8521*
8522* In the following comments, the character _ should be read as
8523* "of the distributed matrix". Let A be a generic term for any 2D
8524* block cyclicly distributed matrix. Its description vector is DESCA:
8525*
8526* NOTATION STORED IN EXPLANATION
8527* ---------------- --------------- ------------------------------------
8528* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
8529* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
8530* the NPROW x NPCOL BLACS process grid
8531* A is distributed over. The context
8532* itself is global, but the handle
8533* (the integer value) may vary.
8534* M_A (global) DESCA( M_ ) The number of rows in the distribu-
8535* ted matrix A, M_A >= 0.
8536* N_A (global) DESCA( N_ ) The number of columns in the distri-
8537* buted matrix A, N_A >= 0.
8538* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
8539* block of the matrix A, IMB_A > 0.
8540* INB_A (global) DESCA( INB_ ) The number of columns of the upper
8541* left block of the matrix A,
8542* INB_A > 0.
8543* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
8544* bute the last M_A-IMB_A rows of A,
8545* MB_A > 0.
8546* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
8547* bute the last N_A-INB_A columns of
8548* A, NB_A > 0.
8549* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
8550* row of the matrix A is distributed,
8551* NPROW > RSRC_A >= 0.
8552* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
8553* first column of A is distributed.
8554* NPCOL > CSRC_A >= 0.
8555* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
8556* array storing the local blocks of
8557* the distributed matrix A,
8558* IF( Lc( 1, N_A ) > 0 )
8559* LLD_A >= MAX( 1, Lr( 1, M_A ) )
8560* ELSE
8561* LLD_A >= 1.
8562*
8563* Let K be the number of rows of a matrix A starting at the global in-
8564* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
8565* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
8566* receive if these K rows were distributed over NPROW processes. If K
8567* is the number of columns of a matrix A starting at the global index
8568* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
8569* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
8570* these K columns were distributed over NPCOL processes.
8571*
8572* The values of Lr() and Lc() may be determined via a call to the func-
8573* tion PB_NUMROC:
8574* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
8575* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
8576*
8577* Arguments
8578* =========
8579*
8580* INPLACE (global input) LOGICAL
8581* On entry, INPLACE specifies if the matrix should be generated
8582* in place or not. If INPLACE is .TRUE., the local random array
8583* to be generated will start in memory at the local memory lo-
8584* cation A( 1, 1 ), otherwise it will start at the local posi-
8585* tion induced by IA and JA.
8586*
8587* AFORM (global input) CHARACTER*1
8588* On entry, AFORM specifies the type of submatrix to be genera-
8589* ted as follows:
8590* AFORM = 'S', sub( A ) is a symmetric matrix,
8591* AFORM = 'H', sub( A ) is a Hermitian matrix,
8592* AFORM = 'T', sub( A ) is overrwritten with the transpose
8593* of what would normally be generated,
8594* AFORM = 'C', sub( A ) is overwritten with the conjugate
8595* transpose of what would normally be genera-
8596* ted.
8597* AFORM = 'N', a random submatrix is generated.
8598*
8599* DIAG (global input) CHARACTER*1
8600* On entry, DIAG specifies if the generated submatrix is diago-
8601* nally dominant or not as follows:
8602* DIAG = 'D' : sub( A ) is diagonally dominant,
8603* DIAG = 'N' : sub( A ) is not diagonally dominant.
8604*
8605* OFFA (global input) INTEGER
8606* On entry, OFFA specifies the offdiagonal of the underlying
8607* matrix A(1:DESCA(M_),1:DESCA(N_)) of interest when the subma-
8608* trix is symmetric, Hermitian or diagonally dominant. OFFA = 0
8609* specifies the main diagonal, OFFA > 0 specifies a subdiago-
8610* nal, and OFFA < 0 specifies a superdiagonal (see further de-
8611* tails).
8612*
8613* M (global input) INTEGER
8614* On entry, M specifies the global number of matrix rows of the
8615* submatrix sub( A ) to be generated. M must be at least zero.
8616*
8617* N (global input) INTEGER
8618* On entry, N specifies the global number of matrix columns of
8619* the submatrix sub( A ) to be generated. N must be at least
8620* zero.
8621*
8622* IA (global input) INTEGER
8623* On entry, IA specifies A's global row index, which points to
8624* the beginning of the submatrix sub( A ).
8625*
8626* JA (global input) INTEGER
8627* On entry, JA specifies A's global column index, which points
8628* to the beginning of the submatrix sub( A ).
8629*
8630* DESCA (global and local input) INTEGER array
8631* On entry, DESCA is an integer array of dimension DLEN_. This
8632* is the array descriptor for the matrix A.
8633*
8634* IASEED (global input) INTEGER
8635* On entry, IASEED specifies the seed number to generate the
8636* matrix A. IASEED must be at least zero.
8637*
8638* A (local output) COMPLEX*16 array
8639* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
8640* at least Lc( 1, JA+N-1 ). On exit, this array contains the
8641* local entries of the randomly generated submatrix sub( A ).
8642*
8643* LDA (local input) INTEGER
8644* On entry, LDA specifies the local leading dimension of the
8645* array A. When INPLACE is .FALSE., LDA is usually DESCA(LLD_).
8646* This restriction is however not enforced, and this subroutine
8647* requires only that LDA >= MAX( 1, Mp ) where
8648*
8649* Mp = PB_NUMROC( M, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW ).
8650*
8651* PB_NUMROC is a ScaLAPACK tool function; MYROW, MYCOL, NPROW
8652* and NPCOL can be determined by calling the BLACS subroutine
8653* BLACS_GRIDINFO.
8654*
8655* Further Details
8656* ===============
8657*
8658* OFFD is tied to the matrix described by DESCA, as opposed to the
8659* piece that is currently (re)generated. This is a global information
8660* independent from the distribution parameters. Below are examples of
8661* the meaning of OFFD for a global 7 by 5 matrix:
8662*
8663* ---------------------------------------------------------------------
8664* OFFD | 0 -1 -2 -3 -4 0 -1 -2 -3 -4 0 -1 -2 -3 -4
8665* -------|-------------------------------------------------------------
8666* | | OFFD=-1 | OFFD=0 OFFD=2
8667* | V V
8668* 0 | . d . . . -> d . . . . . . . . .
8669* 1 | . . d . . . d . . . . . . . .
8670* 2 | . . . d . . . d . . -> d . . . .
8671* 3 | . . . . d . . . d . . d . . .
8672* 4 | . . . . . . . . . d . . d . .
8673* 5 | . . . . . . . . . . . . . d .
8674* 6 | . . . . . . . . . . . . . . d
8675* ---------------------------------------------------------------------
8676*
8677* -- Written on April 1, 1998 by
8678* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
8679*
8680* =====================================================================
8681*
8682* .. Parameters ..
8683 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
8684 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
8685 $ RSRC_
8686 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
8687 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
8688 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
8689 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
8690 INTEGER JMP_1, JMP_COL, JMP_IMBV, JMP_INBV, JMP_LEN,
8691 $ JMP_MB, JMP_NB, JMP_NPIMBLOC, JMP_NPMB,
8692 $ JMP_NQINBLOC, JMP_NQNB, JMP_ROW
8693 parameter( jmp_1 = 1, jmp_row = 2, jmp_col = 3,
8694 $ jmp_mb = 4, jmp_imbv = 5, jmp_npmb = 6,
8695 $ jmp_npimbloc = 7, jmp_nb = 8, jmp_inbv = 9,
8696 $ jmp_nqnb = 10, jmp_nqinbloc = 11,
8697 $ jmp_len = 11 )
8698 DOUBLE PRECISION ZERO
8699 parameter( zero = 0.0d+0 )
8700* ..
8701* .. Local Scalars ..
8702 LOGICAL DIAGDO, SYMM, HERM, NOTRAN
8703 INTEGER CSRC, I, IACOL, IAROW, ICTXT, IIA, ILOCBLK,
8704 $ ILOCOFF, ILOW, IMB, IMB1, IMBLOC, IMBVIR, INB,
8705 $ INB1, INBLOC, INBVIR, INFO, IOFFDA, ITMP, IUPP,
8706 $ IVIR, JJA, JLOCBLK, JLOCOFF, JVIR, LCMT00,
8707 $ LMBLOC, LNBLOC, LOW, MAXMN, MB, MBLKS, MP,
8708 $ MRCOL, MRROW, MYCDIST, MYCOL, MYRDIST, MYROW,
8709 $ NB, NBLKS, NPCOL, NPROW, NQ, NVIR, RSRC, UPP
8710 COMPLEX*16 ALPHA
8711* ..
8712* .. Local Arrays ..
8713 INTEGER DESCA2( DLEN_ ), IMULADD( 4, JMP_LEN ),
8714 $ IRAN( 2 ), JMP( JMP_LEN ), MULADD0( 4 )
8715* ..
8716* .. External Subroutines ..
8717 EXTERNAL blacs_gridinfo, pb_ainfog2l, pb_binfo,
8721 $ pzladom
8722* ..
8723* .. External Functions ..
8724 LOGICAL LSAME
8725 EXTERNAL lsame
8726* ..
8727* .. Intrinsic Functions ..
8728 INTRINSIC dble, dcmplx, max, min
8729* ..
8730* .. Data Statements ..
8731 DATA ( muladd0( i ), i = 1, 4 ) / 20077, 16838,
8732 $ 12345, 0 /
8733* ..
8734* .. Executable Statements ..
8735*
8736* Convert descriptor
8737*
8738 CALL pb_desctrans( desca, desca2 )
8739*
8740* Test the input arguments
8741*
8742 ictxt = desca2( ctxt_ )
8743 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
8744*
8745* Test the input parameters
8746*
8747 info = 0
8748 IF( nprow.EQ.-1 ) THEN
8749 info = -( 1000 + ctxt_ )
8750 ELSE
8751 symm = lsame( aform, 'S' )
8752 herm = lsame( aform, 'H' )
8753 notran = lsame( aform, 'N' )
8754 diagdo = lsame( diag, 'D' )
8755 IF( .NOT.( symm.OR.herm.OR.notran ) .AND.
8756 $ .NOT.( lsame( aform, 'T' ) ) .AND.
8757 $ .NOT.( lsame( aform, 'C' ) ) ) THEN
8758 info = -2
8759 ELSE IF( ( .NOT.diagdo ) .AND.
8760 $ ( .NOT.lsame( diag, 'N' ) ) ) THEN
8761 info = -3
8762 END IF
8763 CALL pb_chkmat( ictxt, m, 5, n, 6, ia, ja, desca2, 10, info )
8764 END IF
8765*
8766 IF( info.NE.0 ) THEN
8767 CALL pxerbla( ictxt, 'PZLAGEN', -info )
8768 RETURN
8769 END IF
8770*
8771* Quick return if possible
8772*
8773 IF( ( m.LE.0 ).OR.( n.LE.0 ) )
8774 $ RETURN
8775*
8776* Start the operations
8777*
8778 mb = desca2( mb_ )
8779 nb = desca2( nb_ )
8780 imb = desca2( imb_ )
8781 inb = desca2( inb_ )
8782 rsrc = desca2( rsrc_ )
8783 csrc = desca2( csrc_ )
8784*
8785* Figure out local information about the distributed matrix operand
8786*
8787 CALL pb_ainfog2l( m, n, ia, ja, desca2, nprow, npcol, myrow,
8788 $ mycol, imb1, inb1, mp, nq, iia, jja, iarow,
8789 $ iacol, mrrow, mrcol )
8790*
8791* Decide where the entries shall be stored in memory
8792*
8793 IF( inplace ) THEN
8794 iia = 1
8795 jja = 1
8796 END IF
8797*
8798* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
8799* ILOW, LOW, IUPP, and UPP.
8800*
8801 ioffda = ja + offa - ia
8802 CALL pb_binfo( ioffda, mp, nq, imb1, inb1, mb, nb, mrrow,
8803 $ mrcol, lcmt00, mblks, nblks, imbloc, inbloc,
8804 $ lmbloc, lnbloc, ilow, low, iupp, upp )
8805*
8806* Initialize ILOCBLK, ILOCOFF, MYRDIST, JLOCBLK, JLOCOFF, MYCDIST
8807* This values correspond to the square virtual underlying matrix
8808* of size MAX( M_ + MAX( 0, -OFFA ), N_ + MAX( 0, OFFA ) ) used
8809* to set up the random sequence. For practical purposes, the size
8810* of this virtual matrix is upper bounded by M_ + N_ - 1.
8811*
8812 itmp = max( 0, -offa )
8813 ivir = ia + itmp
8814 imbvir = imb + itmp
8815 nvir = desca2( m_ ) + itmp
8816*
8817 CALL pb_locinfo( ivir, imbvir, mb, myrow, rsrc, nprow, ilocblk,
8818 $ ilocoff, myrdist )
8819*
8820 itmp = max( 0, offa )
8821 jvir = ja + itmp
8822 inbvir = inb + itmp
8823 nvir = max( max( nvir, desca2( n_ ) + itmp ),
8824 $ desca2( m_ ) + desca2( n_ ) - 1 )
8825*
8826 CALL pb_locinfo( jvir, inbvir, nb, mycol, csrc, npcol, jlocblk,
8827 $ jlocoff, mycdist )
8828*
8829 IF( symm .OR. herm .OR. notran ) THEN
8830*
8831 CALL pb_initjmp( .true., nvir, imbvir, inbvir, imbloc, inbloc,
8832 $ mb, nb, rsrc, csrc, nprow, npcol, 2, jmp )
8833*
8834* Compute constants to jump JMP( * ) numbers in the sequence
8835*
8836 CALL pb_initmuladd( muladd0, jmp, imuladd )
8837*
8838* Compute and set the random value corresponding to A( IA, JA )
8839*
8840 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
8841 $ myrdist, mycdist, nprow, npcol, jmp,
8842 $ imuladd, iran )
8843*
8844 CALL pb_zlagen( 'Lower', aform, a( iia, jja ), lda, lcmt00,
8845 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
8846 $ nb, lnbloc, jmp, imuladd )
8847*
8848 END IF
8849*
8850 IF( symm .OR. herm .OR. ( .NOT. notran ) ) THEN
8851*
8852 CALL pb_initjmp( .false., nvir, imbvir, inbvir, imbloc, inbloc,
8853 $ mb, nb, rsrc, csrc, nprow, npcol, 2, jmp )
8854*
8855* Compute constants to jump JMP( * ) numbers in the sequence
8856*
8857 CALL pb_initmuladd( muladd0, jmp, imuladd )
8858*
8859* Compute and set the random value corresponding to A( IA, JA )
8860*
8861 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
8862 $ myrdist, mycdist, nprow, npcol, jmp,
8863 $ imuladd, iran )
8864*
8865 CALL pb_zlagen( 'Upper', aform, a( iia, jja ), lda, lcmt00,
8866 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
8867 $ nb, lnbloc, jmp, imuladd )
8868*
8869 END IF
8870*
8871 IF( diagdo ) THEN
8872*
8873 maxmn = max( desca2( m_ ), desca2( n_ ) )
8874 IF( herm ) THEN
8875 alpha = dcmplx( dble( 2 * maxmn ), zero )
8876 ELSE
8877 alpha = dcmplx( dble( nvir ), dble( maxmn ) )
8878 END IF
8879*
8880 IF( ioffda.GE.0 ) THEN
8881 CALL pzladom( inplace, min( max( 0, m-ioffda ), n ), alpha,
8882 $ a, min( ia+ioffda, ia+m-1 ), ja, desca )
8883 ELSE
8884 CALL pzladom( inplace, min( m, max( 0, n+ioffda ) ), alpha,
8885 $ a, ia, min( ja-ioffda, ja+n-1 ), desca )
8886 END IF
8887*
8888 END IF
8889*
8890 RETURN
8891*
8892* End of PZLAGEN
8893*
subroutine pb_ainfog2l(m, n, i, j, desc, nprow, npcol, myrow, mycol, imb1, inb1, mp, nq, ii, jj, prow, pcol, rprow, rpcol)
Definition pblastst.f:2023
subroutine pb_binfo(offd, m, n, imb1, inb1, mb, nb, mrrow, mrcol, lcmt00, mblks, nblks, imbloc, inbloc, lmbloc, lnbloc, ilow, low, iupp, upp)
Definition pblastst.f:3577
subroutine pb_setran(iran, iac)
Definition pblastst.f:4759
subroutine pb_locinfo(i, inb, nb, myroc, srcproc, nprocs, ilocblk, ilocoff, mydist)
Definition pblastst.f:3910
subroutine pb_chkmat(ictxt, m, mpos0, n, npos0, ia, ja, desca, dpos0, info)
Definition pblastst.f:2742
subroutine pb_jump(k, muladd, irann, iranm, ima)
Definition pblastst.f:4648
subroutine pb_setlocran(seed, ilocblk, jlocblk, ilocoff, jlocoff, myrdist, mycdist, nprow, npcol, jmp, imuladd, iran)
Definition pblastst.f:4302
subroutine pb_initmuladd(muladd0, jmp, imuladd)
Definition pblastst.f:4196
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964
subroutine pb_initjmp(colmaj, nvir, imbvir, inbvir, imbloc, inbloc, mb, nb, rsrc, csrc, nprow, npcol, stride, jmp)
Definition pblastst.f:4045
subroutine pb_jumpit(muladd, irann, iranm)
Definition pblastst.f:4822
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
subroutine pb_zlagen(uplo, aform, a, lda, lcmt00, iran, mblks, imbloc, mb, lmbloc, nblks, inbloc, nb, lnbloc, jmp, imuladd)
subroutine pzladom(inplace, n, alpha, a, ia, ja, desca)
Definition pzblastst.f:8896
logical function lsame(ca, cb)
Definition tools.f:1724
Here is the call graph for this function:
Here is the caller graph for this function: