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

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



a + iota * s | until(b) = seq(a, b, s)
BTW we are sort of revisiting the "named parameter" API: 

Iota  == Count
"A+" == Start
"*S" == Incr
"until(b)" == Last

A few key advantages:

- optional argument with default values can just be omitted. 
- no confusion on ordering of parameter.
- the whole _expression_ has a well-defined meaning. It can be seen a special case of indexing with a concrete vector.
- at least for "Count" and "Last", we can omit fixed<N>, and just write iota<Count> and until<Last>.

​And of course everything is composable, e.g.,
(1 + iota * 3 | until(10) | every(2)) + 4 | reverse
= (1 + [0, 3, 6, ...] | until(10) | every(2)) + 4 | reverse 
= ([1, 4, 7, 10] | every(2)) + 4 | reverse
= [1, 7] + 4 | reverse
= [5, 12] | reverse
= [12, 5]
And we have lots of composition rules: Denote arithmetic progression as AP, finite or infinite, then

AP | until(N) = AP
AP | every(k) = AP
AP | reverse = AP
AP * int = AP
AP + int = AP
AP | ubound(U) = AP
AP | lbound(L) = AP
AP | first(N) = AP   // take first N elements

More generic operations, such as filter, transform, ..., can only be applied to finite AP, which gets turned into into a concrete vector, i.e.,

AP | transform(int -> T) = vec<T>
AP | filter(int -> boolean) = vec<int>

 




 



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