Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc. |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Still I'd say that changing the case to avoid a name collision is against most sane coding conventions, especially when the particular coding convention uses case to differentiate between the type of the name.To tell you the truth, I don't feel comfortable in introducing a "Size" function... it's just that the respective size/length/count/etc. property should be accessible through a 'size' function for consistency, and thus it feels odd not to call the respective argument 'size/Size'. I would thus rather try to make the option (A) below works out...Some more ideas for option (A). Suppose we define xxx(first, last, incr). Suffix it with "n" or "N" for the version that takes in (first, len, incr). Examples:seq(3, 3+n-1, 2) <-> seqn(3, n, 2) or seqN(3, n, 2) or seq_n(3, n, 2) (more STL like)Likewise:aseq(3, 3+n-1, 2) <-> aseqn(3, n, 2) or aseqN(3, n, 2)aprog(3, 3+n-1, 2) <-> aprogn(3, n, 2) or aprogN(a, n, 2)ap(3, 3+n-1, 2) <-> apn(3, n, 2) or apN(a, n, 2)The letter "n" serves as a mnemonic for length. This way, we don't have to remember which is the bounded version and which is sized version. The C++ standard library sets the precedents with its "_n" suffixed algorithms, e.g., copy vs copy_n, find vs find_n. A single undercase "n" as a suffix doesn't work too well for longer word like "span" or "range" though.
Fixed<V>This and the shorter "Fix" are both nice. I still prefer the all lower case version though, since it's a function and there's no name collision.
I also want to revisit the ordering of first, last, and the (optional) incr parameters. We have these existing conventions:- Matlab/Julia: (first, [incr,] last)- Numpy: (first, end [, incr]), and also indices can be negative numbers
As you can see, it matches neither.
I fail to see a good reason why we shouldn't just adopt Matlab's convention of (first, incr, last), similar to libigl's colon(), so that there's one few set of convention to remember.
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |