[petsc-users] MatShift and unassembled matrices

Harsh Sharma hsharma.tgjobs at gmail.com
Thu Oct 7 17:14:35 CDT 2010


Hi,

I am creating a square matrix using MatCreateMPIDense, then
zero-ing its entries using MatZeroEntries and finally using the
MatShift operation to make it the identity matrix. Here's the code
snippet that I'm using for doing this:

 Mat OP1;   /* n1xn1 matrix */


MatCreateMPIDense(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,n1,n1,PETSC_NULL,&OP1);
 MatZeroEntries(OP1);
 MatShift(OP1,1.0);

The error I get is:

[0]PETSC ERROR: --------------------- Error Message
------------------------------------
[0]PETSC ERROR: Object is in wrong state!
[0]PETSC ERROR: Not for unassembled matrix!
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: MatShift() line 110 in src/mat/utils/axpy.c
[0]PETSC ERROR: --------------------- Error Message
------------------------------------

Apparently, the matrix OP1 is in unassembled state. All the
examples that I have seen for MatShift() do not call any
assembly routines before or after calling the MatShift() function.

What am I doing wrong here?

Thanks very much,
Harsh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101007/d826007b/attachment.htm>


More information about the petsc-users mailing list