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

◆ pclaset()

subroutine pclaset ( character*1  uplo,
integer  m,
integer  n,
complex  alpha,
complex  beta,
complex, dimension( * )  a,
integer  ia,
integer  ja,
integer, dimension( * )  desca 
)

Definition at line 7507 of file pcblastst.f.

7508*
7509* -- PBLAS test routine (version 2.0) --
7510* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
7511* and University of California, Berkeley.
7512* April 1, 1998
7513*
7514* .. Scalar Arguments ..
7515 CHARACTER*1 UPLO
7516 INTEGER IA, JA, M, N
7517 COMPLEX ALPHA, BETA
7518* ..
7519* .. Array Arguments ..
7520 INTEGER DESCA( * )
7521 COMPLEX A( * )
7522* ..
7523*
7524* Purpose
7525* =======
7526*
7527* PCLASET initializes an m by n submatrix A(IA:IA+M-1,JA:JA+N-1) deno-
7528* ted by sub( A ) to beta on the diagonal and alpha on the offdiago-
7529* nals.
7530*
7531* Notes
7532* =====
7533*
7534* A description vector is associated with each 2D block-cyclicly dis-
7535* tributed matrix. This vector stores the information required to
7536* establish the mapping between a matrix entry and its corresponding
7537* process and memory location.
7538*
7539* In the following comments, the character _ should be read as
7540* "of the distributed matrix". Let A be a generic term for any 2D
7541* block cyclicly distributed matrix. Its description vector is DESCA:
7542*
7543* NOTATION STORED IN EXPLANATION
7544* ---------------- --------------- ------------------------------------
7545* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
7546* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
7547* the NPROW x NPCOL BLACS process grid
7548* A is distributed over. The context
7549* itself is global, but the handle
7550* (the integer value) may vary.
7551* M_A (global) DESCA( M_ ) The number of rows in the distribu-
7552* ted matrix A, M_A >= 0.
7553* N_A (global) DESCA( N_ ) The number of columns in the distri-
7554* buted matrix A, N_A >= 0.
7555* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
7556* block of the matrix A, IMB_A > 0.
7557* INB_A (global) DESCA( INB_ ) The number of columns of the upper
7558* left block of the matrix A,
7559* INB_A > 0.
7560* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
7561* bute the last M_A-IMB_A rows of A,
7562* MB_A > 0.
7563* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
7564* bute the last N_A-INB_A columns of
7565* A, NB_A > 0.
7566* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
7567* row of the matrix A is distributed,
7568* NPROW > RSRC_A >= 0.
7569* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
7570* first column of A is distributed.
7571* NPCOL > CSRC_A >= 0.
7572* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
7573* array storing the local blocks of
7574* the distributed matrix A,
7575* IF( Lc( 1, N_A ) > 0 )
7576* LLD_A >= MAX( 1, Lr( 1, M_A ) )
7577* ELSE
7578* LLD_A >= 1.
7579*
7580* Let K be the number of rows of a matrix A starting at the global in-
7581* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
7582* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
7583* receive if these K rows were distributed over NPROW processes. If K
7584* is the number of columns of a matrix A starting at the global index
7585* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
7586* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
7587* these K columns were distributed over NPCOL processes.
7588*
7589* The values of Lr() and Lc() may be determined via a call to the func-
7590* tion PB_NUMROC:
7591* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
7592* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
7593*
7594* Arguments
7595* =========
7596*
7597* UPLO (global input) CHARACTER*1
7598* On entry, UPLO specifies the part of the submatrix sub( A )
7599* to be set:
7600* = 'L' or 'l': Lower triangular part is set; the strictly
7601* upper triangular part of sub( A ) is not changed;
7602* = 'U' or 'u': Upper triangular part is set; the strictly
7603* lower triangular part of sub( A ) is not changed;
7604* Otherwise: All of the matrix sub( A ) is set.
7605*
7606* M (global input) INTEGER
7607* On entry, M specifies the number of rows of the submatrix
7608* sub( A ). M must be at least zero.
7609*
7610* N (global input) INTEGER
7611* On entry, N specifies the number of columns of the submatrix
7612* sub( A ). N must be at least zero.
7613*
7614* ALPHA (global input) COMPLEX
7615* On entry, ALPHA specifies the scalar alpha, i.e., the cons-
7616* tant to which the offdiagonal elements are to be set.
7617*
7618* BETA (global input) COMPLEX
7619* On entry, BETA specifies the scalar beta, i.e., the constant
7620* to which the diagonal elements are to be set.
7621*
7622* A (local input/local output) COMPLEX array
7623* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
7624* at least Lc( 1, JA+N-1 ). Before entry, this array contains
7625* the local entries of the matrix A to be set. On exit, the
7626* leading m by n submatrix sub( A ) is set as follows:
7627*
7628* if UPLO = 'U', A(IA+i-1,JA+j-1) = ALPHA, 1<=i<=j-1, 1<=j<=N,
7629* if UPLO = 'L', A(IA+i-1,JA+j-1) = ALPHA, j+1<=i<=M, 1<=j<=N,
7630* otherwise, A(IA+i-1,JA+j-1) = ALPHA, 1<=i<=M, 1<=j<=N,
7631* and IA+i.NE.JA+j,
7632* and, for all UPLO, A(IA+i-1,JA+i-1) = BETA, 1<=i<=min(M,N).
7633*
7634* IA (global input) INTEGER
7635* On entry, IA specifies A's global row index, which points to
7636* the beginning of the submatrix sub( A ).
7637*
7638* JA (global input) INTEGER
7639* On entry, JA specifies A's global column index, which points
7640* to the beginning of the submatrix sub( A ).
7641*
7642* DESCA (global and local input) INTEGER array
7643* On entry, DESCA is an integer array of dimension DLEN_. This
7644* is the array descriptor for the matrix A.
7645*
7646* -- Written on April 1, 1998 by
7647* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
7648*
7649* =====================================================================
7650*
7651* .. Parameters ..
7652 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
7653 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
7654 $ RSRC_
7655 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
7656 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
7657 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
7658 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
7659* ..
7660* .. Local Scalars ..
7661 LOGICAL GODOWN, GOLEFT, ISCOLREP, ISROWREP, LOWER,
7662 $ UPPER
7663 INTEGER IACOL, IAROW, ICTXT, IIA, IIMAX, ILOW, IMB1,
7664 $ IMBLOC, INB1, INBLOC, IOFFA, IOFFD, IUPP, JJA,
7665 $ JJMAX, JOFFA, JOFFD, LCMT, LCMT00, LDA, LMBLOC,
7666 $ LNBLOC, LOW, M1, MB, MBLKD, MBLKS, MBLOC, MP,
7667 $ MRCOL, MRROW, MYCOL, MYROW, N1, NB, NBLKD,
7668 $ NBLKS, NBLOC, NPCOL, NPROW, NQ, PMB, QNB, TMP1,
7669 $ UPP
7670* ..
7671* .. Local Arrays ..
7672 INTEGER DESCA2( DLEN_ )
7673* ..
7674* .. External Subroutines ..
7675 EXTERNAL blacs_gridinfo, pb_ainfog2l, pb_binfo,
7677* ..
7678* .. External Functions ..
7679 LOGICAL LSAME
7680 EXTERNAL lsame
7681* ..
7682* .. Intrinsic Functions ..
7683 INTRINSIC min
7684* ..
7685* .. Executable Statements ..
7686*
7687 IF( m.EQ.0 .OR. n.EQ.0 )
7688 $ RETURN
7689*
7690* Convert descriptor
7691*
7692 CALL pb_desctrans( desca, desca2 )
7693*
7694* Get grid parameters
7695*
7696 ictxt = desca2( ctxt_ )
7697 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
7698*
7699 CALL pb_ainfog2l( m, n, ia, ja, desca2, nprow, npcol, myrow,
7700 $ mycol, imb1, inb1, mp, nq, iia, jja, iarow,
7701 $ iacol, mrrow, mrcol )
7702*
7703 IF( mp.LE.0 .OR. nq.LE.0 )
7704 $ RETURN
7705*
7706 isrowrep = ( desca2( rsrc_ ).LT.0 )
7707 iscolrep = ( desca2( csrc_ ).LT.0 )
7708 lda = desca2( lld_ )
7709*
7710 upper = .NOT.( lsame( uplo, 'L' ) )
7711 lower = .NOT.( lsame( uplo, 'U' ) )
7712*
7713 IF( ( ( lower.AND.upper ).AND.( alpha.EQ.beta ) ).OR.
7714 $ ( isrowrep .AND. iscolrep ) ) THEN
7715 IF( ( mp.GT.0 ).AND.( nq.GT.0 ) )
7716 $ CALL pb_claset( uplo, mp, nq, 0, alpha, beta,
7717 $ a( iia + ( jja - 1 ) * lda ), lda )
7718 RETURN
7719 END IF
7720*
7721* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
7722* ILOW, LOW, IUPP, and UPP.
7723*
7724 mb = desca2( mb_ )
7725 nb = desca2( nb_ )
7726 CALL pb_binfo( 0, mp, nq, imb1, inb1, mb, nb, mrrow, mrcol,
7727 $ lcmt00, mblks, nblks, imbloc, inbloc, lmbloc,
7728 $ lnbloc, ilow, low, iupp, upp )
7729*
7730 ioffa = iia - 1
7731 joffa = jja - 1
7732 iimax = ioffa + mp
7733 jjmax = joffa + nq
7734*
7735 IF( isrowrep ) THEN
7736 pmb = mb
7737 ELSE
7738 pmb = nprow * mb
7739 END IF
7740 IF( iscolrep ) THEN
7741 qnb = nb
7742 ELSE
7743 qnb = npcol * nb
7744 END IF
7745*
7746 m1 = mp
7747 n1 = nq
7748*
7749* Handle the first block of rows or columns separately, and update
7750* LCMT00, MBLKS and NBLKS.
7751*
7752 godown = ( lcmt00.GT.iupp )
7753 goleft = ( lcmt00.LT.ilow )
7754*
7755 IF( .NOT.godown .AND. .NOT.goleft ) THEN
7756*
7757* LCMT00 >= ILOW && LCMT00 <= IUPP
7758*
7759 goleft = ( ( lcmt00 - ( iupp - upp + pmb ) ).LT.ilow )
7760 godown = .NOT.goleft
7761*
7762 CALL pb_claset( uplo, imbloc, inbloc, lcmt00, alpha, beta,
7763 $ a( iia+joffa*lda ), lda )
7764 IF( godown ) THEN
7765 IF( upper .AND. nq.GT.inbloc )
7766 $ CALL pb_claset( 'All', imbloc, nq-inbloc, 0, alpha,
7767 $ alpha, a( iia+(joffa+inbloc)*lda ), lda )
7768 iia = iia + imbloc
7769 m1 = m1 - imbloc
7770 ELSE
7771 IF( lower .AND. mp.GT.imbloc )
7772 $ CALL pb_claset( 'All', mp-imbloc, inbloc, 0, alpha,
7773 $ alpha, a( iia+imbloc+joffa*lda ), lda )
7774 jja = jja + inbloc
7775 n1 = n1 - inbloc
7776 END IF
7777*
7778 END IF
7779*
7780 IF( godown ) THEN
7781*
7782 lcmt00 = lcmt00 - ( iupp - upp + pmb )
7783 mblks = mblks - 1
7784 ioffa = ioffa + imbloc
7785*
7786 10 CONTINUE
7787 IF( mblks.GT.0 .AND. lcmt00.GT.upp ) THEN
7788 lcmt00 = lcmt00 - pmb
7789 mblks = mblks - 1
7790 ioffa = ioffa + mb
7791 GO TO 10
7792 END IF
7793*
7794 tmp1 = min( ioffa, iimax ) - iia + 1
7795 IF( upper .AND. tmp1.GT.0 ) THEN
7796 CALL pb_claset( 'All', tmp1, n1, 0, alpha, alpha,
7797 $ a( iia+joffa*lda ), lda )
7798 iia = iia + tmp1
7799 m1 = m1 - tmp1
7800 END IF
7801*
7802 IF( mblks.LE.0 )
7803 $ RETURN
7804*
7805 lcmt = lcmt00
7806 mblkd = mblks
7807 ioffd = ioffa
7808*
7809 mbloc = mb
7810 20 CONTINUE
7811 IF( mblkd.GT.0 .AND. lcmt.GE.ilow ) THEN
7812 IF( mblkd.EQ.1 )
7813 $ mbloc = lmbloc
7814 CALL pb_claset( uplo, mbloc, inbloc, lcmt, alpha, beta,
7815 $ a( ioffd+1+joffa*lda ), lda )
7816 lcmt00 = lcmt
7817 lcmt = lcmt - pmb
7818 mblks = mblkd
7819 mblkd = mblkd - 1
7820 ioffa = ioffd
7821 ioffd = ioffd + mbloc
7822 GO TO 20
7823 END IF
7824*
7825 tmp1 = m1 - ioffd + iia - 1
7826 IF( lower .AND. tmp1.GT.0 )
7827 $ CALL pb_claset( 'ALL', tmp1, inbloc, 0, alpha, alpha,
7828 $ a( ioffd+1+joffa*lda ), lda )
7829*
7830 tmp1 = ioffa - iia + 1
7831 m1 = m1 - tmp1
7832 n1 = n1 - inbloc
7833 lcmt00 = lcmt00 + low - ilow + qnb
7834 nblks = nblks - 1
7835 joffa = joffa + inbloc
7836*
7837 IF( upper .AND. tmp1.GT.0 .AND. n1.GT.0 )
7838 $ CALL pb_claset( 'ALL', tmp1, n1, 0, alpha, alpha,
7839 $ a( iia+joffa*lda ), lda )
7840*
7841 iia = ioffa + 1
7842 jja = joffa + 1
7843*
7844 ELSE IF( goleft ) THEN
7845*
7846 lcmt00 = lcmt00 + low - ilow + qnb
7847 nblks = nblks - 1
7848 joffa = joffa + inbloc
7849*
7850 30 CONTINUE
7851 IF( nblks.GT.0 .AND. lcmt00.LT.low ) THEN
7852 lcmt00 = lcmt00 + qnb
7853 nblks = nblks - 1
7854 joffa = joffa + nb
7855 GO TO 30
7856 END IF
7857*
7858 tmp1 = min( joffa, jjmax ) - jja + 1
7859 IF( lower .AND. tmp1.GT.0 ) THEN
7860 CALL pb_claset( 'All', m1, tmp1, 0, alpha, alpha,
7861 $ a( iia+(jja-1)*lda ), lda )
7862 jja = jja + tmp1
7863 n1 = n1 - tmp1
7864 END IF
7865*
7866 IF( nblks.LE.0 )
7867 $ RETURN
7868*
7869 lcmt = lcmt00
7870 nblkd = nblks
7871 joffd = joffa
7872*
7873 nbloc = nb
7874 40 CONTINUE
7875 IF( nblkd.GT.0 .AND. lcmt.LE.iupp ) THEN
7876 IF( nblkd.EQ.1 )
7877 $ nbloc = lnbloc
7878 CALL pb_claset( uplo, imbloc, nbloc, lcmt, alpha, beta,
7879 $ a( iia+joffd*lda ), lda )
7880 lcmt00 = lcmt
7881 lcmt = lcmt + qnb
7882 nblks = nblkd
7883 nblkd = nblkd - 1
7884 joffa = joffd
7885 joffd = joffd + nbloc
7886 GO TO 40
7887 END IF
7888*
7889 tmp1 = n1 - joffd + jja - 1
7890 IF( upper .AND. tmp1.GT.0 )
7891 $ CALL pb_claset( 'All', imbloc, tmp1, 0, alpha, alpha,
7892 $ a( iia+joffd*lda ), lda )
7893*
7894 tmp1 = joffa - jja + 1
7895 m1 = m1 - imbloc
7896 n1 = n1 - tmp1
7897 lcmt00 = lcmt00 - ( iupp - upp + pmb )
7898 mblks = mblks - 1
7899 ioffa = ioffa + imbloc
7900*
7901 IF( lower .AND. m1.GT.0 .AND. tmp1.GT.0 )
7902 $ CALL pb_claset( 'All', m1, tmp1, 0, alpha, alpha,
7903 $ a( ioffa+1+(jja-1)*lda ), lda )
7904*
7905 iia = ioffa + 1
7906 jja = joffa + 1
7907*
7908 END IF
7909*
7910 nbloc = nb
7911 50 CONTINUE
7912 IF( nblks.GT.0 ) THEN
7913 IF( nblks.EQ.1 )
7914 $ nbloc = lnbloc
7915 60 CONTINUE
7916 IF( mblks.GT.0 .AND. lcmt00.GT.upp ) THEN
7917 lcmt00 = lcmt00 - pmb
7918 mblks = mblks - 1
7919 ioffa = ioffa + mb
7920 GO TO 60
7921 END IF
7922*
7923 tmp1 = min( ioffa, iimax ) - iia + 1
7924 IF( upper .AND. tmp1.GT.0 ) THEN
7925 CALL pb_claset( 'All', tmp1, n1, 0, alpha, alpha,
7926 $ a( iia+joffa*lda ), lda )
7927 iia = iia + tmp1
7928 m1 = m1 - tmp1
7929 END IF
7930*
7931 IF( mblks.LE.0 )
7932 $ RETURN
7933*
7934 lcmt = lcmt00
7935 mblkd = mblks
7936 ioffd = ioffa
7937*
7938 mbloc = mb
7939 70 CONTINUE
7940 IF( mblkd.GT.0 .AND. lcmt.GE.low ) THEN
7941 IF( mblkd.EQ.1 )
7942 $ mbloc = lmbloc
7943 CALL pb_claset( uplo, mbloc, nbloc, lcmt, alpha, beta,
7944 $ a( ioffd+1+joffa*lda ), lda )
7945 lcmt00 = lcmt
7946 lcmt = lcmt - pmb
7947 mblks = mblkd
7948 mblkd = mblkd - 1
7949 ioffa = ioffd
7950 ioffd = ioffd + mbloc
7951 GO TO 70
7952 END IF
7953*
7954 tmp1 = m1 - ioffd + iia - 1
7955 IF( lower .AND. tmp1.GT.0 )
7956 $ CALL pb_claset( 'All', tmp1, nbloc, 0, alpha, alpha,
7957 $ a( ioffd+1+joffa*lda ), lda )
7958*
7959 tmp1 = min( ioffa, iimax ) - iia + 1
7960 m1 = m1 - tmp1
7961 n1 = n1 - nbloc
7962 lcmt00 = lcmt00 + qnb
7963 nblks = nblks - 1
7964 joffa = joffa + nbloc
7965*
7966 IF( upper .AND. tmp1.GT.0 .AND. n1.GT.0 )
7967 $ CALL pb_claset( 'All', tmp1, n1, 0, alpha, alpha,
7968 $ a( iia+joffa*lda ), lda )
7969*
7970 iia = ioffa + 1
7971 jja = joffa + 1
7972*
7973 GO TO 50
7974*
7975 END IF
7976*
7977 RETURN
7978*
7979* End of PCLASET
7980*
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_desctrans(descin, descout)
Definition pblastst.f:2964
subroutine pb_claset(uplo, m, n, ioffd, alpha, beta, a, lda)
#define min(A, B)
Definition pcgemr.c:181
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: