CustomizingEigen_InheritingMatrix.dox 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. namespace Eigen {
  2. /** \page TopicCustomizing_InheritingMatrix Inheriting from Matrix
  3. Before inheriting from Matrix, be really, I mean REALLY, sure that using
  4. EIGEN_MATRIX_PLUGIN is not what you really want (see previous section).
  5. If you just need to add few members to Matrix, this is the way to go.
  6. An example of when you actually need to inherit Matrix, is when you
  7. have several layers of heritage such as
  8. MyVerySpecificVector1, MyVerySpecificVector2 -> MyVector1 -> Matrix and
  9. MyVerySpecificVector3, MyVerySpecificVector4 -> MyVector2 -> Matrix.
  10. In order for your object to work within the %Eigen framework, you need to
  11. define a few members in your inherited class.
  12. Here is a minimalistic example:
  13. \include CustomizingEigen_Inheritance.cpp
  14. Output: \verbinclude CustomizingEigen_Inheritance.out
  15. This is the kind of error you can get if you don't provide those methods
  16. \verbatim
  17. error: no match for ‘operator=’ in ‘v = Eigen::operator*(
  18. const Eigen::MatrixBase<Eigen::Matrix<double, -0x000000001, 1, 0, -0x000000001, 1> >::Scalar&,
  19. const Eigen::MatrixBase<Eigen::Matrix<double, -0x000000001, 1> >::StorageBaseType&)
  20. (((const Eigen::MatrixBase<Eigen::Matrix<double, -0x000000001, 1> >::StorageBaseType&)
  21. ((const Eigen::MatrixBase<Eigen::Matrix<double, -0x000000001, 1> >::StorageBaseType*)(& v))))’
  22. \endverbatim
  23. */
  24. }