Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.

[ Thread Index | Date Index | More Archives ]

On Fri, Jan 6, 2017 at 3:50 AM, Massimiliano Janes <max.jns@xxxxxxxxx> wrote:

[…]. Last Massimilliano's post seems to imply that APL also uses this strategy to define bounds...


I didn’t mean that sorry, I was just referring to the general idea behind APL's iota function, eg. transform
an integer N into the sequence [1,…,N], then *lazily* apply operations like arithmetics, transpositions
,etc… to create/manipulate vectors.

the API you’re proposing clearly differs in that N is given by the 'source’ vector, and the resulting index set
is clamped to fit in, but the idea ( and its benefits ) seems the same conceptually …

as an alternative to gael’s iota < bounds, one could follow more closely APL by introducing an _expression_
representing the number of source elements:

A(iota(all)) // as A(all)
A(iota(5)) // first five elements
A(2+iota(5)) // from index 2 to 6 
A(2*iota(all) ) // even numbers

​In general, I think the behavior of how Iota or Iota(all) is auto-bounded needs further discussion.

Are out of bounds indices automatically pruned for expr involving Iota? Does A(-3 + Iota) generate an error upon indexing? What about A(-3 + iota(3))?

A(2*iota(5) ) // even numbers up to 8
A(3+2*iota(all-2) ) // 3,5,7,… up to N-2
A(all - iota(5) ) // N-1,N-2,..,N-5

where bound checking is meant to follow Eigen habits ( eg. hard error if compile time, assert on runtime )

Mail converted by MHonArc 2.6.19+