[petsc-users] Push Back in Vector

Pedro Torres torres.pedrozpk at gmail.com
Thu Feb 25 10:37:21 CST 2010


2010/2/25 Jed Brown <jed at 59a2.org>

> On Thu, 25 Feb 2010 13:16:56 -0300, Pedro Torres <
> torres.pedrozpk at gmail.com> wrote:
> > Hello,
> >
> > There is function that work with Vector object similar to push_back() in
> > STL?. If not, which is the best way to deal with this?.
>
> What are you trying to do?  Vec is not a stack, queue, or dynamically
> sized list-like structure, you have to decide what size it is (and it's
> parallel layout) before using it.
>

Well, in my case I have a sequential vector and I'm trying to append one
element at the end of the array, without the need of destroy this. So, if I
can't, the procedure would be:

- Get the array of the old vector
- Create a new vector with size+1
- copy old array in the new array and append the element,
- destroy old vector

There is a better way?

Thanks a lot!


Pedro











>
> Jed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100225/ab05a07f/attachment.htm>


More information about the petsc-users mailing list