[petsc-users] Reading values from a matrix into a different format

Matthew Knepley knepley at gmail.com
Wed Jun 10 10:05:08 CDT 2015


On Wed, Jun 10, 2015 at 10:03 AM, Tim Steinhoff <kandanovian at gmail.com>
wrote:

> Hi all
>
> assume that a sparse matrix is constructed via
>
> MPI_Comm comm;
> Mat A;
> PetscInt n = 10000; /* dimension of matrix */
> comm = PETSC_COMM_SELF;
> MatCreate(comm,&A);
> MatSetSizes(Amat,n,n,n,n);
> MatSetBlockSize(A,6);
> MatSetType(A,MATAIJ);
>
> followd by some suitable preallocation and setting of values.
>
> What can be done to efficiently read the values from the matrix A and
> store them in a format like the coordinate format COO?
>

Using MatGetRow() should be fine for this.

  Thanks,

    Matt


> Regards
> Tim
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150610/9aeb2ca2/attachment.html>


More information about the petsc-users mailing list