Cast matrix as a vector?

liu chang liuchangjohn at
Sun May 3 12:59:40 CDT 2009

Thanks Matt.

> 2) If you are worried about memory, PETSc Vec and dense
>      matrix can have the same layout and share a pointer.

That's the ideal solution but how can I do that? I can't find a way to
create a Mat or Vec from an existing pointer.

Liu Chang

> On Sun, May 3, 2009 at 4:42 AM, liu chang <liuchangjohn at> wrote:
>> I'm using TAO's LMVM method for optimize a dense matrix, but TAO
>> expects its input as a Vec. Do I have to copy the content back and
>> forth between a Mat and a Vec? Can I somehow cast the Mat into a Vec?
>> Both the Mat and the Vec are distributed evenly across the processes
>> so ideally there doesn't need to be any copying at all.
>> Thanks,
>> Liu Chang
> --
> 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

More information about the petsc-users mailing list