On Mon, Dec 21, 2009 at 5:01 PM, Umut Tabak <span dir="ltr"><<a href="mailto:u.tabak@tudelft.nl">u.tabak@tudelft.nl</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear all,<br>
<br>
I was trying to wrap around some Petsc code into a class, so that there is a neat interface and implementation, I got into a problem at the very beginning and did not understand the reason maybe some of you could help me to understand this.<br>
<br>
I have a Matrix A in the private section of my simple class.<br>
<br>
And I would like to create this matrix inside the class ctor. Whenever I call the MatCreate function I get a segmentation fault with<br></blockquote><div><br>Without seeing the code, we cannot say anything, but I bet you misdeclared A.<br>
<br> Matt<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
MatCreate(MPI_COMM_SELF, &A)<br>
<br>
I checked the documentation that the Matrices in Petsc are also pointers.<br>
<br>
The point I did not understand is that if there is a pointer member of a class, say<br>
...<br>
private:<br>
int* b<br>
...<br>
<br>
I can initialize that to null in the constructor and make the necessary allocation with some member functions. With the same reasoning I thought that If I do not apply similar null pointer assignment for the matrix(there is not such thing I suppose) that I would like to initialize in the ctor, I will get a segfault. I could not figure my way out and wondered when you write the topdown code. I mean in the code below,<br>
<br>
Mat A;<br>
<br>
MatCreate(MPI_COMM_SELF, &A);<br>
MatSetSizes(A, m, n, 0, 0);<br>
MatSetType(A,MATSEQAIJ);<br>
<br>
"Mat A" initializes the pointer to null internally, am I right? Is there sth similar for the above class situation or am I mistaken at some other point(which could be highly likely)?<br>
<br>
Any pointers are appreciated.<br><font color="#888888">
Umut<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>