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

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



the new sequence. However, with proper overloads, we can recognize expressions such as "10 <= _1 < n" as bounding predicate. Any arithmetic progression filtered by a bounding predicate will simply return another arithmetic progression.

​Actually I just realized that "10 <= _1 < n"​ is really syntax abuse in C++, as operator "<=" returns a bool and it does not make sense to compare a bool with a number using "<" (unless you case the bool to an int, which is what will happen in practice if you write something like 10 < x <= 100, which always returns true). The fact that it's doable doesn't mean we should do it. It should really be just 

10 <= _1 && _1 < n

or just

bound(10, n-1)

Unfortunately, "&&" has a lower precedence than "|", so we can either write

(A) a + iota * s | (10 <= _1 && _1 < n)
(B) a + iota * s | 10 <= _1 | _1 < n

Or overload "||" instead

(C) ​a + iota * s || 10 <= _1 && _1 < n

I think (A) and (B) both look fine to me, and (C) looks strange.

Actually using explicit bound functions has the benefit that you no longer need fixed<C>, i.e.:

aseq(a, 10, s) =  a + iota * s | _1 <= fixed<10> 
aseq(a, 10, s) =  a + iota * s | ubound<10>





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