Change Matrix and Vector to be factories in Python interface
Issue #956
new
The letter-envelope design of Matrix
and Vector
adds unnecessary complexity and is not needed. In the Python interface with pybind11, these could simply be factories. Simpler code and design, and no user changes.
This also fits the pybind11 design which automatically upcasts, i.e. it makes a GenericVector
a PETScVector
if it is a PETScVector
. This removes the need for as_backend_type
, except for Matrix
and Vector
types which presenting require unwrapping. Making them into factories would remove this need.
pybind11 has features to make support of factories simple, see http://pybind11.readthedocs.io/en/stable/advanced/classes.html?highlight=factory#custom-constructors.