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

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


fantastic work!

I love the

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

syntax.

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/