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

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



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

gael

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
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+ http://listengine.tuxfamily.org/