Re: [eigen] writing a function that takes Eigen::MatrixBase or Eigen::Block

[ Thread Index | Date Index | More Archives ]

On 04/10/2019 15.53, Dale Lukas Peterson wrote:

I ended up doing this as:
Eigen::Matrix<typename Derived::Scalar, Derived::RowsAtCompileTime,
Derived::ColsAtCompileTime> aa;

However I like your solution better since it is shorter and presumably it
also captures the Options, MaxRows, and MaxCols template parameters
correctly from Derived, whereas what I did will use whatever the defaults
are configured to be.

Yes, `typename Derived::PlainObject` will also copy `MaxRowsAtCompileTime` and `MaxColsAtCompileTime`. However, from the Options it will only take the Majornes (RowMajor or ColumnMajor) but always use `AutoAlign`. In your case the default values are the same.

Also, if you used `DenseBase<Derived>` instead of `MatrixBase<Derived>` it would automatically choose either the corresponding Matrix or Array class. If you explicitly want a Matrix (or an Array) you could use `Derived::PlainMatrix` (or `Derived::PlainArray`).


 Dr.-Ing. Christoph Hertzberg

 Besuchsadresse der Nebengeschäftsstelle:
 Robotics Innovation Center
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Postadresse der Hauptgeschäftsstelle Standort Bremen:
 Robotics Innovation Center
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Tel.:     +49 421 178 45-4021
 Zentrale: +49 421 178 45-0
 E-Mail:   christoph.hertzberg@xxxxxxx

 Weitere Informationen:
  Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
  Trippstadter Strasse 122, D-67663 Kaiserslautern, Germany

  Prof. Dr. Jana Koehler (Vorsitzende)
  Dr. Walter Olthoff

  Vorsitzender des Aufsichtsrats:
  Prof. Dr. h.c. Hans A. Aukes
  Amtsgericht Kaiserslautern, HRB 2313

Mail converted by MHonArc 2.6.19+