diff options
author | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2012-07-05 13:36:02 +0100 |
---|---|---|
committer | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2012-07-05 13:36:02 +0100 |
commit | b582b2ebdc5657c993698e89db699e885af68c55 (patch) | |
tree | 116cdcb8c129168afd3b91fbccfaeae9772d0325 /doc | |
parent | 0a7ce6ad695a33b8e8f08c78725baf982c20fcbd (diff) |
doc: Add constructor to example for inheritance.
See "Error in Inheriting Eigen::Vector3d" on forum.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/I00_CustomizingEigen.dox | 11 |
1 files 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<typename OtherDerived> + Vector3D(const Eigen::MatrixBase<OtherDerived>& other) + : Eigen::Vector3d(other) + { } + + // This method allows you to assign Eigen expressions to MyVectorType template<typename OtherDerived> MyVectorType & operator= (const Eigen::MatrixBase <OtherDerived>& other) { |