MAT_KEEP_ZEROED_ROWS && MatZeroRows() on empty rows.

Lisandro Dalcin dalcinl at
Tue Jun 2 16:00:34 CDT 2009

A co-worker (CC'ed) pointed me this:

$ cat
from petsc4py import PETSc
A = PETSc.Mat().createAIJ(5)
A[0,0] = 1
A[4,4] = 1
A.setOption(PETSc.Mat.Option.KEEP_ZEROED_ROWS, True)

$ python
Traceback (most recent call last):
  File "", line 7, in <module>
  File "Mat.pyx", line 621, in petsc4py.PETSc.Mat.zeroRows
petsc4py.PETSc.Error: error code 73
[0] MatZeroRows() line 4822 in src/mat/interface/matrix.c
[0] MatZeroRows_SeqAIJ() line 1367 in src/mat/impls/aij/seq/aij.c
[0] Object is in wrong state
[0] Matrix is missing diagonal entry in row 3

If the setOption() is commented out, all work as expected.

Is this a bug? What do you think?
We could argue this is an abuse of ZeroRows() (I mean, use ZeroRows()
to put something on diagonal when we know in advance that the whole
row is empty).
However, as the call succeed  without the setOption(KEEP_ZEROED_...),
I'm inclined to think this is actually a bug.

Lisandro Dalcín
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

More information about the petsc-dev mailing list