Re: [eigen] writing a function that takes Eigen::MatrixBase or Eigen::Block |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] writing a function that takes Eigen::MatrixBase or Eigen::Block
- From: Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 4 Oct 2019 17:23:28 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-bremen.de; s=2019; t=1570202608; i=@uni-bremen.de; bh=vgYO7/TltteQXxNHASk5w4mpkpBxpQsBXuuAB72Gg5U=; h=To:References:From:Date:In-Reply-To; b=b5RUM8y6rIbMVb0E32XD137kMaDmtemkFIoc2WftDXAI8iUscEFeus8mdpd24iVtz diQtjEFS1t8msJe0uZyezpfbDvDA+cdaBAX8a5pPA6jA6nHYqENTjxOJqLyy/F1YEO kc4NMt+fb5DohJljWHBvZiZdU0x80UxurB6RlT9JZmcdAa1ZhcR/GL5h3weYq7v0Aw nHaueUoFJZuAvp+N9+lyLGR5H4pKWHwR6h7nUSDUAMAR3qoJDspkNVLmPLteOqWawe I7biwgje3cTGOlkRvcDRP3HnoA1RThA9ZdI+GJWQ/QM/VSUg+JZabi+crw2Qe2roRh 3n2ICx5LxAY/A==
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`).
Christoph
--
Dr.-Ing. Christoph Hertzberg
Besuchsadresse der Nebengeschäftsstelle:
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Postadresse der Hauptgeschäftsstelle Standort Bremen:
DFKI GmbH
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: http://www.dfki.de/robotik
-------------------------------------------------------------
Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
Trippstadter Strasse 122, D-67663 Kaiserslautern, Germany
Geschäftsführung:
Prof. Dr. Jana Koehler (Vorsitzende)
Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats:
Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
-------------------------------------------------------------