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

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] New indexing/slicing API: almost ready to be merged*From*: Yuanchen Zhu <yuanchen.zhu@xxxxxxxxx>*Date*: Fri, 13 Jan 2017 14:24:08 -0500*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=RhMDyqZnWGToWuATAvfYDB9oKVIrChzJ0fSHtI2ap64=; b=MtZBXeATedN8nIukhQlqDQ7qZQU5Tsd7ypIETT7k3luZe1ZH8AtvUXulj5+tmpb6+F mb2+eMWzLTUkHX/UXUP38LeMDNPMnrff5U5iJ9d0ersRxpYrWZU5UQf0Stzc2vJvFBd8 LZat3Wxb2W5p4mlds3yAam9CL/Ig7ouHR8jPoj5eQdS0MpBXdEX2zsttV4dTTxl+Ggpr Jw3l5iTA3boxor/jUdaQ3e9kPSTYTWqxN3AphHx6hs99eBMR+Oz2Efl6IEpu3WPyvv2j BNSvSPgvTl9N02JXhvqXAd3f5+cUYjuGSuiHZUip+qkk43LKSpoc2vMw2fRXkB4au02B v7vg==

On Fri, Jan 13, 2017 at 3:18 AM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:

On Thu, Jan 12, 2017 at 9:54 PM, Yuanchen Zhu <yuanchen.zhu@xxxxxxxxx> wrote:Great work. Looks really advanced.One small suggestion: seq(a, b, d) should allow the case where (b-a+d)/d < 0, and clamp the length to 0. seqN on the other hand should treat N < 0 as a compile time or run time error.I'm not sure, it does not look right to call say, seq(13,2,2). The current code gives some tolerance to define an empty range with inclusive bounds from: b=a-1 to b=a-d (for d>0).

But this is basically the convention of matlab and numpy (dont know about fortran).

A good reason for allowing it is that you can represent an empty sequence using seq, i.e., seq(n, m, 1) with m < n. In the current version, seq(n, n-1, 1) is indeed an empty sequence, but seq(n, n-2, 1) is runtime error.

gaelOn Wed, Jan 11, 2017 at 12:09 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote: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:Of particular interest is the respective unit test that demonstrate its use and guarantees: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 parametersseq(start, stop [, incr])seqN(start, size [, incr])placeholders::allplaceholders::lastplaceholders::end = last+1PLEASE, 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 seqNRegarding 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:gael

**Follow-Ups**:**Re: [eigen] New indexing/slicing API: almost ready to be merged***From:*Gael Guennebaud

**References**:**[eigen] New indexing/slicing API: almost ready to be merged***From:*Gael Guennebaud

**Re: [eigen] New indexing/slicing API: almost ready to be merged***From:*Yuanchen Zhu

**Re: [eigen] New indexing/slicing API: almost ready to be merged***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Let's get reshape in shape for 3.4** - Next by Date:
**Re: [eigen] New indexing/slicing API: almost ready to be merged** - Previous by thread:
**Re: [eigen] New indexing/slicing API: almost ready to be merged** - Next by thread:
**Re: [eigen] New indexing/slicing API: almost ready to be merged**

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