[petsc-users] How to pass the Matrices between functions in c++

ehsan sadrfaridpour it.sadr at gmail.com
Mon Jun 15 16:12:57 CDT 2015


Hi,
Thanks for your great support.
I am developing my code in c++ and I have created 4 matrices in a function
and they are work fine.
In the end of the function I need to delete them to release the memory
space they occupied.

   - My question:

However, I need to pass these matrices to other functions (or another
class) and use their contents before I destroy them in the current function.

(I need it because now I have a long function and I want to make it
smaller. Also I need to make a recursive function that gets matrices as
input.)

I was thinking of using a pointer to the beginning of each of them, but I
am not very good at this. Also I am worried about how I destroy them.

Would you please let me know what is the best approach for this?

Best,
Ehsan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150615/5aa6a658/attachment.html>


More information about the petsc-users mailing list