dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #05810
(py)dolfin.GenericMatrix and numpy integration
In PyCC, we have our own crs matrix named CRS, and up to now, we have made the
class quite useful from Python. We have started inheriting the Dolfin base
class GenericMatrix, and the way SWIG works, we need to implement the typemaps for
the (pure) virtual functions in Dolfin in order to keep our Python interface.
Spesifically, in PyCC the
GenericMatrix::add(const real* block, uint m, const uint* rows, uint n, const uint cols);
(and family) can accept numpy arrays from Python.
s = SparsityPattern()
s.init(n,n)
s.insert(0,0)
s.insert(0,1)
s.insert(1,0)
s.insert(1,1)
...
m = Matrix()
m.init(s)
# We want this
rows = numpy.array([1,2])
cols = numpy.array([1,2])
values = numpy.ones(4)
m.add(values, rows, cols) # Add 1 to the block matrix given by the first two rows/cols
# etc
I can add this if there are no objections. I know this is not a very important
feature, as most of the time, a CRS matrix will be filled from a compiled
assembler, but it would be nice with a tight Dolfin/numpy integration.
Ola
Follow ups