[petsc-users] MatConvert
Jed Brown
jedbrown at mcs.anl.gov
Tue Nov 5 10:00:36 CST 2013
Harshad Sahasrabudhe <hsahasra at purdue.edu> writes:
> Hi,
>
> Can we use the original Mat in Matconvert to store the converted matrix?
>
> E.g. MatConvert(A, MATDENSE, MAT_INITIAL_MATRIX, &A);
> Or do I need MAT_REUSE_MATRIX flag instead of MAT_INITIAL_MATRIX?
Do this:
MatConvert(A, MATDENSE, MAT_REUSE_MATRIX, &A);
Note that conversion is not really "in place", it creates a new matrix
and destroys the old one (all except the header). This is potentially
dangerous if other components of your code hold references to the old
matrix and do not expect its type to change. It does not use more
memory to create a new matrix and eventually destroy the old one.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131105/ecb5b77e/attachment-0001.pgp>
More information about the petsc-users
mailing list