From 3e0e77932229aa18431d269b01d74a892f0bbefd Mon Sep 17 00:00:00 2001 From: Ben North Date: Tue, 5 Jul 2016 21:00:05 +0100 Subject: [PATCH] Tests: Add further '2*' functions for matrices Add and declare to Python functions double_mat_cm() --- compute 2* a column-major matrix double_mat_rm() --- compute 2* a row-major matrix to 'eigen.cpp' tests / example. --- example/eigen.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/example/eigen.cpp b/example/eigen.cpp index 81c1f0bf4..f99ae3a40 100644 --- a/example/eigen.cpp +++ b/example/eigen.cpp @@ -16,6 +16,13 @@ Eigen::VectorXf double_col(const Eigen::VectorXf& x) Eigen::RowVectorXf double_row(const Eigen::RowVectorXf& x) { return 2.0f * x; } +Eigen::MatrixXf double_mat_cm(const Eigen::MatrixXf& x) +{ return 2.0f * x; } + +typedef Eigen::Matrix MatrixXfRowMajor; +MatrixXfRowMajor double_mat_rm(const MatrixXfRowMajor& x) +{ return 2.0f * x; } + void init_eigen(py::module &m) { typedef Eigen::Matrix FixedMatrixR; typedef Eigen::Matrix FixedMatrixC; @@ -31,6 +38,8 @@ void init_eigen(py::module &m) { m.def("double_col", &double_col); m.def("double_row", &double_row); + m.def("double_mat_cm", &double_mat_cm); + m.def("double_mat_rm", &double_mat_rm); m.def("fixed_r", [mat]() -> FixedMatrixR { return FixedMatrixR(mat);