<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
Hello,</div>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
<br>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
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.</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
<br>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
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.</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
<br>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
Also, I want my destructor to only call MatDestroy on the matrix if it has been created (otherwise it gives seg faults).</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
<br>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
How can I achieve this?</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
<br>
</div>
<div class="m_1083750009899479956gmail_signature" data-smartmail="gmail_signature">
Thanks.</div>
<div dir="ltr"><br>
</div>
</div>
</body>
</html>