<div>Hi,</div>
<div> </div>
<div>I am creating a square matrix using MatCreateMPIDense, then</div>
<div>zero-ing its entries using MatZeroEntries and finally using the</div>
<div>MatShift operation to make it the identity matrix. Here's the code</div>
<div>snippet that I'm using for doing this:</div>
<div> </div>
<div><font face="courier new,monospace"> Mat OP1; /* n1xn1 matrix */</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="courier new,monospace"> </font><font face="courier new,monospace">MatCreateMPIDense(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,n1,n1,PETSC_NULL,&OP1);</font></div>
<div><font face="courier new,monospace"> MatZeroEntries(OP1);</font></div>
<div><font face="courier new,monospace"> MatShift(OP1,1.0);</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="arial,helvetica,sans-serif">The error I get is:</font></div>
<div> </div>
<div><font face="verdana,sans-serif">[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[0]PETSC ERROR: Object is in wrong state!<br>[0]PETSC ERROR: Not for unassembled matrix!<br>
[0]PETSC ERROR: ------------------------------------------------------------------------</font></div>
<div><font face="verdana,sans-serif">[0]PETSC ERROR: MatShift() line 110 in src/mat/utils/axpy.c<br>[0]PETSC ERROR: --------------------- Error Message ------------------------------------</font></div>
<div><font face="Verdana"></font> </div>
<div><font face="arial,helvetica,sans-serif">Apparently, the matrix OP1 is in unassembled state. All the</font></div>
<div><font face="arial,helvetica,sans-serif">examples </font>that I have seen for MatShift() do not call any</div>
<div>assembly routines before or after calling the MatShift() function.</div>
<div> </div>
<div>What am I doing wrong here?</div>
<div> </div>
<div>Thanks very much,</div>
<div>Harsh</div>