Cast matrix as a vector?

Matthew Knepley knepley at gmail.com
Sun May 3 13:35:00 CDT 2009


On Sun, May 3, 2009 at 12:59 PM, liu chang <liuchangjohn at gmail.com> wrote:

> 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.


http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecCreateMPIWithArray.html

http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIDense.html

   Matt


>
> Regards,
> Liu Chang
>
> > On Sun, May 3, 2009 at 4:42 AM, liu chang <liuchangjohn at gmail.com>
> 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
> >
>



-- 
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/20090503/16c086f7/attachment.htm>


More information about the petsc-users mailing list