[petsc-users] Fwd: [dev at libelemental.org] Re: [elemental] Fwd: MatZeroRows and MATELEMENTAL

Jack Poulson jack.poulson at gmail.com
Tue Oct 28 00:20:29 CDT 2014


---------- Forwarded message ----------
From: Jack Poulson <poulson at stanford.edu>
Date: Mon, Oct 27, 2014 at 9:27 PM
Subject: [dev at libelemental.org] Re: [elemental] Fwd: [petsc-users]
MatZeroRows and MATELEMENTAL
To: "dev at libele >> Elemental" <dev at libelemental.org>, Matthew Knepley <
knepley at gmail.com>


Hi Matt,

At first glance, I would have suggested EntrywiseFill [1,2,3], which
takes an arbitrary function, say

    fill : (i,j) |-> T

and sets each entry (i,j) of a matrix of type T to fill(i,j), but the
documentation for MatZeroRows [4] states that only a subset of rows are
to be modified.

I would instead implement this as follows (in C++), for the slightly
more general case where the off-diagonal value can be arbitrary:

template<typename T>
void ModifyRows
( AbstractDistMatrix<T>& A, const std::vector<Int>& rowInd,
  T diagVal, T offDiagVal )
{
    DEBUG_ONLY(CallStackEntry cse("ModifyRows"))
    const Int numRows = rowInd.size();
    const Int localWidth = A.LocalWidth();
    for( Int s=0; s<numRows; ++s )
    {
        const Int row = rowInd[s];
        if( A.IsLocalRow(row) )
        {
            const Int iLoc = A.LocalRow(row);
            for( Int jLoc=0; jLoc<localWidth; ++jLoc )
            {
                const Int j = A.GlobalCol(jLoc);
                if( i == j )
                    A.SetLocal( iLoc, jLoc, diagVal );
                else
                    A.SetLocal( iLoc, jLoc, offDiagVal );
            }
        }
    }
}

If you are coming from C, one simply needs to convert the buffer into an
std::vector via

    std::vector<Int> rowInd(rows,rows+numRows);

Jack

P.S. The release candidate for 0.85 is coming in a few hours.

[1]
https://github.com/elemental/Elemental/blob/396a8cebc46ea13c4fbdc51a1f21fce2c1a75edf/include/El/blas_like/level1.hpp#L176

[2]
https://github.com/elemental/Elemental/blob/396a8cebc46ea13c4fbdc51a1f21fce2c1a75edf/include/El/blas_like/level1.h#L314

[3]
https://github.com/elemental/Elemental/blob/396a8cebc46ea13c4fbdc51a1f21fce2c1a75edf/include/El/blas_like/level1.py#L485


[4]
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatZeroRows.html

On 10/27/2014 02:36 PM, Matthew Knepley wrote:
> I do not know the answer to this one. Is there something in that does
> the equivalent of
> MatZeroRows(), or do you do it by hand?
>
>   Thanks,
>
>     Matt
>
> ---------- Forwarded message ----------
> From: *Francesco Ballarin* <francesco.ballarin at polimi.it
> <mailto:francesco.ballarin at polimi.it>>
> Date: Sun, Oct 26, 2014 at 4:32 AM
> Subject: [petsc-users] MatZeroRows and MATELEMENTAL
> To: petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>
>
>
> Dear PETSc users,
> I have a code for PETSc 3.3 in which the PLAPACK interface, now
> discontinued, was used. I am trying to update it to PETSc 3.5.2, using
> the Elemental interface.
>
> I see that MatZeroRows is not implemented for MATELEMENTAL. What
> function should I use instead? Does it also support the version with
> optional arguments x and b?
>
> Thanks,
> best regards,
> Francesco
>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which
> their experiments lead.
> -- Norbert Wiener
>
> --
> You received this message because you are subscribed to the Google
> Groups "elemental-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to elemental-dev+unsubscribe at googlegroups.com
> <mailto:elemental-dev+unsubscribe at googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141027/66dd7955/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141027/66dd7955/attachment.pgp>


More information about the petsc-users mailing list