Add (Vector|Matrix)Backend for numpy array and csr matrix
This adds a Dune::Functions::VectorBackend
for flat numpy
vectors represented by pybind11::array_t
and a
Dune::Fufem::MatrixBackend
for flat sparse matrices
with CSR storage represented by numpy arrays.
Since there's no C/C++ API for scipy.sparse.csr_matrix´, we cannot directly implement a
MatrixBackendfor this. However,
csr_matrixuses a simple triple of numpy arrays as storage and can be constructed from one. Thus we can almost rely on automatic pybind11 conversion to create a
csr_matrix. To this end we let pybind11 auto-convert the result of
asTuple()to Python. This will not be a
csr_matrixdirectly, but a nested tuple of numpy arrays. The result can be used to construct a
csr_matrixin Python using
csr_matrix(data[0], shape=data[1])`.
To make this work, seamlessly, it also makes the use
of VectorBackend
in the global functional assembler
more flexible and user-friendly by, on the one hand,
not relying on support for vector=0
and, on the other hand,
auto-generating istlVectorBackend()
if needed.