Re: [eigen] New indexing/slicing API: almost ready to be merged

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]




On Wed, Jan 11, 2017 at 6:34 PM, Andre Krause <post@xxxxxxxxxxxxxxxx> wrote:
fantastic work!

I love the

A(all,{3, 1, 6, 5})

syntax.

right, and here the number of columns is known at compile-time!

However I don't see how to generalize it to multi-dimensional tensors because {3, 1, 6, 5} does not have a default type, so we have to explicitly catch for inputs of the form T[N], and we thus have to explicitly add overloads for all possibilities. For 2D matrices, we have only 3 possibilities (x2 for the const/non-const), so that's manageable, but for 3D that's already 7*2 cases, and in general (2^d-1)*2.

gael
 

cheers !

Am 11.01.2017 um 18:09 schrieb Gael Guennebaud:
>
> Hi everyone,
>
> my implementation of a generic operator() for sub-matrix indexing and
> slicing is pretty well advanced, and nearly OK to be merged. The diff is
> quite huge, about 1600 lines of code and comments:
>
> https://bitbucket.org/ggael/eigen-flexidexing/branches/compare/ggael/eigen-flexidexing:tip%0Deigen/eigen:default#diff
>
> Of particular interest is the respective unit test that demonstrate its
> use and guarantees:
>
> https://bitbucket.org/ggael/eigen-flexidexing/src/2d5a84ca1d4b41d693ef8d2617ae97cccc421043/test/indexed_view.cpp?at=default&fileviewer=file-view-default#indexed_view.cpp-52
>
> The main missing part is to update the user manual to present this new
> feature and API in an intelligible way. It would be of great help if
> someone would volunteer on this task.
>
>
>
> On the user side, it provides the following static variables and functions:
>
>   fix<N> // for fixed size parameters
>   seq(start, stop [, incr])
>   seqN(start, size [, incr])
>   placeholders::all
>   placeholders::last
>   placeholders::end = last+1
>
> PLEASE, do everyone agree on this? From the last discussions, I've
> introduced a placeholders namespace to ease importing the whole Eigen
> namespace. The user can then cherry pick the placeholders they
> frequently use:
>
>   using Eigen::placeholders::last;
>
> or all of them, or make aliases... Perhaps we can find a shorter name
> for this namespace?
>
> Each parameter of the new DenseBase::operator() is compatible with:
>   - a single integer
>   - Eigen::all
>   - any return-type of seq and seqN
>   - any type providing a size() and operator[](integer) members
>   - plain C array like A({2,3,4}) in c++11 (and not too old clang)
>
> Some remarks:
>
>  - expressions of booleans (aka masking) is not supported yet. It could
> be by first converting it to an array of indices if there is a high demand.
>
> - The last and end symbols can be used as the start, stop, and size
> parameters of seq and seqN
>
> - They support any arithmetic operations, including, e.g.,  end/2+1, and
> supporting sqrt(end) is a matter of 5 lines of code max.
>
> - fix<N> can be used as the size and incr parameters of seq and seqN
>
>
> Regarding some internal implementation details:
>
>  - The return type of operator() is a old good Eigen::Block if possible.
> This means that A.tail(a) is strictly equivalent to A(seq(a,last)),
> there are more equivalence example in the unit test.
>
>  - seq(a,b,d) is just an alias to seqN(a,(b-a+d)/d,d) where (b-a+d)/d
> can be a symbolic _expression_ if a and/or b are based on the last/end
> symbols. (the c++11 implementation of seq is trivial, the c++98 is horrible)
>
>  - to support arbitrary expressions on last/end symbols I've implemented
> a minimalistic _expression_ template engine specialized for expressions of
> Index types. In C++14 it can support an arbitrary number of symbols,
> might become handy in the future. There is an example there:
>
> https://bitbucket.org/ggael/eigen-flexidexing/src/2d5a84ca1d4b41d693ef8d2617ae97cccc421043/Eigen/src/Core/util/SymbolicIndex..h?fileviewer=file-view-default#SymbolicIndex.h-15
>
>
> gael





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/