@@ -20,9 +20,10 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor<
2020 typedef _MatrixType MatrixType;
2121 typedef typename MatrixType::Scalar Scalar;
2222 typedef Eigen::Tridiagonalization<MatrixType> Solver;
23+ typedef Eigen::VectorXd VectorType;
2324
2425 template <class PyClass >
25- void visit (PyClass& cl) const {
26+ void visit (PyClass & cl) const {
2627 cl.def (
2728 bp::init<Eigen::DenseIndex>(bp::arg (" size" ), " Default constructor. " ))
2829 .def (bp::init<MatrixType>(bp::arg (" matrix" ),
@@ -31,7 +32,7 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor<
3132
3233 .def (
3334 " compute" ,
34- (Solver & (Solver::*)(const Eigen::EigenBase<MatrixType>& matrix)) &
35+ (Solver & (Solver::*)(const Eigen::EigenBase<MatrixType> & matrix)) &
3536 Solver::compute,
3637 bp::args (" self" , " matrix" ),
3738 " Computes tridiagonal decomposition of given matrix. " ,
@@ -43,18 +44,28 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor<
4344 " Returns the internal representation of the decomposition. " ,
4445 bp::return_value_policy<bp::copy_const_reference>())
4546
46- // TODO: Expose so that the return type are convertible to np arrays
47- .def (" matrixQ" , &Solver::matrixQ, bp::arg (" self" ),
48- " Returns the unitary matrix Q in the decomposition. " )
49- .def (" matrixT" , &Solver::matrixT, bp::arg (" self" ),
50- " Returns the unitary matrix T in the decomposition. " )
47+ .def (
48+ " matrixQ" ,
49+ +[](const Solver &c) -> MatrixType { return c.matrixQ (); },
50+ " Returns the unitary matrix Q in the decomposition." )
51+ .def (
52+ " matrixT" , +[](Solver &c) -> MatrixType { return c.matrixT (); },
53+ " Returns an expression of the tridiagonal matrix T in the "
54+ " decomposition." )
5155
52- .def (" diagonal" , &Solver::diagonal, bp::arg (" self" ),
53- " Returns the diagonal of the tridiagonal matrix T in the "
54- " decomposition. " )
55- .def (" subDiagonal" , &Solver::subDiagonal, bp::arg (" self" ),
56- " Returns the subdiagonal of the tridiagonal matrix T in the "
57- " decomposition." );
56+ .def (
57+ " diagonal" ,
58+ +[](const Solver &c) -> VectorType { return c.diagonal (); },
59+ bp::arg (" self" ),
60+ " Returns the diagonal of the tridiagonal matrix T in the "
61+ " decomposition. " )
62+
63+ .def (
64+ " subDiagonal" ,
65+ +[](const Solver &c) -> VectorType { return c.subDiagonal (); },
66+ bp::arg (" self" ),
67+ " Returns the subdiagonal of the tridiagonal matrix T in the "
68+ " decomposition." );
5869 }
5970
6071 static void expose () {
@@ -63,7 +74,7 @@ struct TridiagonalizationVisitor : public boost::python::def_visitor<
6374 expose (classname);
6475 }
6576
66- static void expose (const std::string& name) {
77+ static void expose (const std::string & name) {
6778 bp::class_<Solver>(name.c_str (), bp::no_init)
6879 .def (TridiagonalizationVisitor ())
6980 .def (IdVisitor<Solver>());
0 commit comments