[petsc-users] Modifying the structure of a matrix.

Jed Brown jedbrown at mcs.anl.gov
Mon May 14 22:38:46 CDT 2012


On Mon, May 14, 2012 at 9:33 PM, Andrew Spott <andrew.spott at gmail.com>wrote:

> What is the best way to selectively add/remove columns/rows of a Mat?
>
> Is there a way to do it in place, or does it require essentially moving
> the values to a new matrix?
>

If you only need to add/remove a small number of values, it's best to
allocate for all that might be present and just store explicit zeros.

To add or remove rows, you are also changing the vector size that can be
multiplied against, and the data structure must be rebuilt. This is why
it's frequently preferable to use MatZeroRows (or a variant) instead of
removing them from the data structure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120514/48d8cd78/attachment.htm>


More information about the petsc-users mailing list