diff --git a/dune/xt/la/bindings.cc b/dune/xt/la/bindings.cc index 80514f6f22242bbb1a530d450a6715e328189fab..7e88ef138c1b6a50cc3a003e70017950616ac201 100644 --- a/dune/xt/la/bindings.cc +++ b/dune/xt/la/bindings.cc @@ -43,12 +43,12 @@ PYBIND11_PLUGIN(_la) LA::bind_Backends(m); - LA::bind_Vector<LA::CommonDenseVector<double>>(m, "CommonDenseVector_double"); + auto common_dense_vector_double = LA::bind_Vector<LA::CommonDenseVector<double>>(m, "CommonDenseVector_double"); #if HAVE_DUNE_ISTL - LA::bind_Vector<LA::IstlDenseVector<double>>(m, "IstlDenseVector_double"); + auto istl_dense_vector_double = LA::bind_Vector<LA::IstlDenseVector<double>>(m, "IstlDenseVector_double"); #endif #if HAVE_EIGEN - LA::bind_Vector<LA::EigenDenseVector<double>>(m, "EigenDenseVector_double"); + auto eigen_dense_vector_double = LA::bind_Vector<LA::EigenDenseVector<double>>(m, "EigenDenseVector_double"); #endif LA::bind_SparsityPatternDefault(m); @@ -56,7 +56,7 @@ PYBIND11_PLUGIN(_la) #define BIND_MATRIX(C, s, c, id) auto c = LA::bind_Matrix<C, s>(m, id); BIND_MATRIX(LA::CommonDenseMatrix<double>, false, common_dense_matrix_double, "CommonDenseMatrix_double"); - BIND_MATRIX(LA::CommonSparseMatrix<double>, true, common_sparse_matrix_double, "CommonSparseMatrix_double"); +// BIND_MATRIX(LA::CommonSparseMatrix<double>, true, common_sparse_matrix_double, "CommonSparseMatrix_double"); #if HAVE_DUNE_ISTL BIND_MATRIX(LA::IstlRowMajorSparseMatrix<double>, true, @@ -71,14 +71,14 @@ PYBIND11_PLUGIN(_la) "EigenRowMajorSparseMatrix_double"); #endif #undef BIND_MATRIX - LA::addbind_Matrix_Vector_interaction<LA::CommonDenseVector<double>>(common_dense_matrix_double); - LA::addbind_Matrix_Vector_interaction<LA::CommonDenseVector<double>>(common_sparse_matrix_double); + LA::addbind_Matrix_Vector_interaction(common_dense_matrix_double, common_dense_vector_double); +// LA::addbind_Matrix_Vector_interaction(common_sparse_matrix_double, common_dense_vector_double); #if HAVE_DUNE_ISTL - LA::addbind_Matrix_Vector_interaction<LA::IstlDenseVector<double>>(istl_row_major_sparse_matrix_double); + LA::addbind_Matrix_Vector_interaction(istl_row_major_sparse_matrix_double, istl_dense_vector_double); #endif #if HAVE_EIGEN - LA::addbind_Matrix_Vector_interaction<LA::EigenDenseVector<double>>(eigen_dense_matrix_double); - LA::addbind_Matrix_Vector_interaction<LA::EigenDenseVector<double>>(eigen_row_major_sparse_matrix_double); + LA::addbind_Matrix_Vector_interaction(eigen_dense_matrix_double, eigen_dense_vector_double); + LA::addbind_Matrix_Vector_interaction(eigen_row_major_sparse_matrix_double, eigen_dense_vector_double); #endif LA::bind_Solver<LA::CommonDenseMatrix<double>>(m, "CommonDenseMatrix_double"); diff --git a/dune/xt/la/container/matrix-interface.pbh b/dune/xt/la/container/matrix-interface.pbh index 8ba811444cd95b7e5c01e0edeb6f64c73659d5ba..68f9dc6e42c7c9c9a62c99c6cc2fb888a74d10f7 100644 --- a/dune/xt/la/container/matrix-interface.pbh +++ b/dune/xt/la/container/matrix-interface.pbh @@ -99,8 +99,6 @@ typename std::enable_if<is_matrix<C>::value, pybind11::class_<C>>::type bind_Mat addbind_ProvidesBackend(c); - c.def_property_readonly_static("vector_type", [](py::object /*self*/) { return C::vector_type; }); - internal::addbind_Matrix<C, sparse>::template ctor<S>(c); c.def("__init__", [](C& self, const ssize_t rows, const ssize_t cols, const SparsityPatternDefault& pattern) { @@ -161,14 +159,17 @@ typename std::enable_if<is_matrix<C>::value, pybind11::class_<C>>::type bind_Mat } // ... bind_Matrix(...) -template <class V, class M> -void addbind_Matrix_Vector_interaction(pybind11::class_<M>& c) +template <class M, class V> +void addbind_Matrix_Vector_interaction(pybind11::class_<M>& mat, pybind11::class_<V>& vec) { namespace py = pybind11; - c.def("mv", [](const M& self, const V& xx, V& yy) { self.mv(xx, yy); }, "source", "range"); + mat.def("mv", [](const M& self, const V& xx, V& yy) { self.mv(xx, yy); }, "source", "range"); + + mat.def(py::self * V()); - c.def(py::self * V()); + mat.def("vector_type", [vec](M& /*self*/) { return vec; }); + vec.def("matrix_type", [mat](V& /*self*/) { return mat; }); } // ... addbind_Matrix_Vector_interaction(...) diff --git a/dune/xt/la/container/vector-interface.pbh b/dune/xt/la/container/vector-interface.pbh index 94f025f64dd08ab4cfb017bbc03f073c910d1c61..437522a1c5cb5796d7d5ae3fd142df423e0cfdad 100644 --- a/dune/xt/la/container/vector-interface.pbh +++ b/dune/xt/la/container/vector-interface.pbh @@ -43,9 +43,6 @@ typename std::enable_if<is_vector<C>::value, pybind11::class_<C>>::type bind_Vec py::class_<C> c = bind_ProvidesDataAccess<C>(m, id, id); addbind_ProvidesBackend(c); - c.def_property_readonly_static("dense_matrix_type", [](py::object /*self*/) { return C::dense_matrix_type; }); - c.def_property_readonly_static("sparse_matrix_type", [](py::object /*self*/) { return C::sparse_matrix_type; }); - c.def("__init__", [](C& vec, const ssize_t size, const S& value) { try {