Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc. |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
yes, my favorites so far are: ic<N>, fix<N>, fixed<N>There is a std::fixed, so fixed<N> is probably not good.
I personally find ic<N> too obscure. I would never be able to guess its meaning.
BTW, regarding inclusive vs exclusive upper bound, python's users seem to have several arguments, all grounded on the zero-based indexing thing: http://stackoverflow.com/questions/11364533/why-are-s .lice-and-range-upper-bound-exc lusive I think half-open interval is very reasonable and conceptually clean with positive strides, but can get confusing with negative strides. For example, to express (n-1, ..., 0), aseq(n-1, -1, -1) looks really strange. With python you cannot even write A[n-1:-1:-1] since -1 is interpreted as n-1, so you write A[n-1::-1] instead, which does not fly with the notion of aseq defining a vector by itself.
But then again, aseq cannot stand on its own if we allow the "last" literal: what exactly is aseq(0, last)?
At this point of discussion, maybe we need to think more carefully about handling indexing relative to end. Here're some not very well-thought out ideas:
1. Have a "last" literal, and overload the shit out of its relevant arithmetic. This is a lot of work, and breaks as soon as an unsuspecting user invokes a function on "last". This is in the wiki.2. Allow negative indices like python, so all indices are understood to be (mod size)?
3. Similar to 2, but use a special "rev" mark to indicate the an index is taken with respect to end, e.g., A(aseq(0, rev(0))); A(aseq(0, rev(some complex computation)));
4: Differentiate between a forward aseq and backward aseq, i.e., A(seq(0, n-1)) gives A[0, ..., n-1], and A(rseq(n-1, 0)) gives A[n-1, ... 0]
gael
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |