Cast matrix as a vector?

Matthew Knepley knepley at
Sun May 3 12:16:12 CDT 2009

1) I guarantee you the copy takes no time. Measure it.

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


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
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the petsc-users mailing list