[petsc-users] Check if a matrix has been created
Shashwat Sharma
shash.sharma at mail.utoronto.ca
Fri Mar 22 16:16:15 CDT 2019
Hello,
I'd like to be able to check if a Mat object has been created and allocated; if it hasn't been created yet, I want to create and allocate it, otherwise I want to reuse the existing allocation.
The context is that I have a Mat variable declared (but not defined) in a header file, so that it is available to the entire class. It is created (MatCreate) and allocated at a later point in the implementation, and may need to be reused with different values several times. But I don't want to allocate it unless it's needed, because it would be quite large.
Also, I want my destructor to only call MatDestroy on the matrix if it has been created (otherwise it gives seg faults).
How can I achieve this?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190322/1b8506bc/attachment.html>
More information about the petsc-users
mailing list