11/*
22 * Copyright 2014-2019, CNRS
3- * Copyright 2018-2020 , INRIA
3+ * Copyright 2018-2022 , INRIA
44 */
55
66#include < iostream>
77
88#include " eigenpy/eigenpy.hpp"
9+ #include " eigenpy/eigen-from-python.hpp"
910
1011using namespace Eigen ;
1112using namespace eigenpy ;
@@ -41,6 +42,16 @@ Eigen::Ref<MatType> asRef(const int rows, const int cols) {
4142 return mat;
4243}
4344
45+ template <typename MatType>
46+ Eigen::Ref<MatType> asRef (Eigen::Ref<MatType> mat) {
47+ return Eigen::Ref<MatType>(mat);
48+ }
49+
50+ template <typename MatType>
51+ const Eigen::Ref<const MatType> asConstRef (Eigen::Ref<MatType> mat) {
52+ return Eigen::Ref<const MatType>(mat);
53+ }
54+
4455BOOST_PYTHON_MODULE (eigen_ref) {
4556 namespace bp = boost::python;
4657 eigenpy::enableEigenPy ();
@@ -60,5 +71,10 @@ BOOST_PYTHON_MODULE(eigen_ref) {
6071 bp::def (" fillVec" , fill<VectorXd>);
6172 bp::def (" fill" , fill<MatrixXd>);
6273
63- bp::def (" asRef" , asRef<MatrixXd>);
74+ bp::def (" asRef" ,
75+ (Eigen::Ref<MatrixXd>(*)(const int , const int ))asRef<MatrixXd>);
76+ bp::def (" asRef" ,
77+ (Eigen::Ref<MatrixXd>(*)(Eigen::Ref<MatrixXd>))asRef<MatrixXd>);
78+ bp::def (" asConstRef" , (const Eigen::Ref<const MatrixXd> (*)(
79+ Eigen::Ref<MatrixXd>))asConstRef<MatrixXd>);
6480}
0 commit comments