[petsc-users] oddity in MatTranspose() under petsc4py
Ethan Coon
ecoon at lanl.gov
Fri Jan 18 11:55:09 CST 2013
First, apologies for not looking into this more closely, but I wanted to
make sure I wasn't missing something stupid before I rebuilt petsc-dev
and petsc4py-dev and started writing PETSc-only versions to see what is
going on.
See the following odd result:
In [1]: from petsc4py import PETSc
In [2]: import numpy as np
In [3]: n = [0,1]
In [4]: vals = np.array([[0,1],[0,0]], 'd')
In [5]: A = PETSc.Mat().createAIJ(2,2)
In [6]: A.assemble()
In [7]: B = A.duplicate()
In [8]: B.setValues(n,n,vals, PETSc.InsertMode.ADD_VALUES)
In [9]: B.assemble()
In [10]: B.transpose(out=A)
Out[10]: <petsc4py.PETSc.Mat at 0x2afb7e0>
In [11]: A.view()
Matrix Object: 1 MPI processes
type: seqbaij
row 0: (0, 0) (1, 0)
row 1: (0, 1) (1, 0)
In [12]: vals
Out[12]:
array([[ 0., 1.],
[ 0., 0.]])
In [13]: A.setValues(n,n,-vals.transpose(), PETSc.InsertMode.ADD_VALUES)
In [14]: A.assemble()
In [15]: A.view()
Matrix Object: 1 MPI processes
type: seqbaij
row 0: (0, 0) (1, -1)
row 1: (0, 1) (1, 0)
where I would have expected A to be all zeros...
This is on petsc4py-3.3 and petsc-3.3-p5, and I know this code worked on
older versions of petsc4py/petsc. If I'm not missing something dumb
I'll look a little closer into whether it is PETSc or petsc4py...
Thanks,
Ethan
--
------------------------------------
Ethan Coon
Post-Doctoral Researcher
Applied Mathematics - T-5
Los Alamos National Laboratory
505-665-8289
http://www.ldeo.columbia.edu/~ecoon/
------------------------------------
More information about the petsc-users
mailing list