From 4a7609fa741e54610b27c6a30d6a9543e19f4031 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Thu, 5 Jul 2012 13:36:02 +0100 Subject: [PATCH] doc: Add constructor to example for inheritance. See "Error in Inheriting Eigen::Vector3d" on forum. (transplanted from b582b2ebdc5657c993698e89db699e885af68c55 ) --- doc/I00_CustomizingEigen.dox | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/I00_CustomizingEigen.dox b/doc/I00_CustomizingEigen.dox index 623ef31e1..43ac8509a 100644 --- a/doc/I00_CustomizingEigen.dox +++ b/doc/I00_CustomizingEigen.dox @@ -83,7 +83,7 @@ An example of when you actually need to inherit Matrix, is when you have several layers of heritage such as MyVerySpecificVector1,MyVerySpecificVector1 -> MyVector1 -> Matrix and. MyVerySpecificVector3,MyVerySpecificVector4 -> MyVector2 -> Matrix. -In order for your object to work within the Eigen framework, you need to +In order for your object to work within the %Eigen framework, you need to define a few members in your inherited class. Here is a minimalistic example:\n @@ -93,8 +93,15 @@ class MyVectorType : public Eigen::VectorXd public: MyVectorType(void):Eigen::VectorXd() {} - // You need to define this for your object to work typedef Eigen::VectorXd Base; + + // This constructor allows you to construct MyVectorType from Eigen expressions + template + Vector3D(const Eigen::MatrixBase& other) + : Eigen::Vector3d(other) + { } + + // This method allows you to assign Eigen expressions to MyVectorType template MyVectorType & operator= (const Eigen::MatrixBase & other) {