mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Update slicing tutorial docs to reflect Eigen::placeholders namespace
libeigen/eigen!2360 Closes #3064 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
@@ -18,6 +18,21 @@ Each argument can be:
|
||||
- An ArithmeticSequence as constructed by the Eigen::seq, Eigen::seqN, or Eigen::placeholders::lastN functions.
|
||||
- Any 1D vector/array of integers including %Eigen's vector/array, expressions, std::vector, std::array, as well as plain C arrays: `int[N]`.
|
||||
|
||||
The symbols \c last, \c lastp1, \c end, \c all, and \c lastN live in the Eigen::placeholders namespace,
|
||||
while \c seq, \c seqN, and \c fix live directly in the Eigen namespace.
|
||||
For convenience, they are all re-exported via the Eigen::indexing namespace.
|
||||
To make the code examples on this page compile, add one of the following:
|
||||
\code
|
||||
using namespace Eigen::indexing;
|
||||
// or individually:
|
||||
using Eigen::placeholders::last;
|
||||
using Eigen::placeholders::all;
|
||||
using Eigen::placeholders::lastN;
|
||||
using Eigen::seq;
|
||||
using Eigen::seqN;
|
||||
using Eigen::fix;
|
||||
\endcode
|
||||
|
||||
More generally, it can accepts any object exposing the following two member functions:
|
||||
\code
|
||||
<integral type> operator[](<integral type>) const;
|
||||
@@ -57,7 +72,7 @@ Taking a set of rows, columns, or elements, uniformly spaced within a matrix or
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
The \c firstIdx and \c lastIdx parameters can also be defined with the help of the Eigen::last symbol representing the index of the last row, column or element of the underlying matrix/vector once the arithmetic sequence is passed to it through operator().
|
||||
The \c firstIdx and \c lastIdx parameters can also be defined with the help of the Eigen::placeholders::last symbol representing the index of the last row, column or element of the underlying matrix/vector once the arithmetic sequence is passed to it through operator().
|
||||
Here are some examples for a 2D array/matrix \c A and a 1D array/vector \c v.
|
||||
<table class="manual">
|
||||
<tr>
|
||||
@@ -148,7 +163,7 @@ Here comes \ref Eigen_placeholders_lastN :
|
||||
|
||||
In terms of performance, %Eigen and the compiler can take advantage of compile-time size and increment.
|
||||
To this end, you can enforce compile-time parameters using Eigen::fix<val>.
|
||||
Such compile-time value can be combined with the Eigen::last symbol:
|
||||
Such compile-time value can be combined with the Eigen::placeholders::last symbol:
|
||||
\code v(seq(last-fix<7>, last-fix<2>))
|
||||
\endcode
|
||||
In this example %Eigen knowns at compile-time that the returned expression has 6 elements.
|
||||
|
||||
Reference in New Issue
Block a user