jeanluct / braidlab

Matlab package for analyzing data using braids
GNU General Public License v3.0
23 stars 9 forks source link

Length of loop vector #136

Open mbudisic opened 8 years ago

mbudisic commented 8 years ago

Consider a loop vector, e.g.,

A = braidlab.loop([1,2,3,4;2,2,2,2])

Presently, the way to tell the number of loops (2) in this vector is something like size(A.coords,1), which is a bit clunky. In particular length(A) will return 1. We should probably overload the length function, especially because a MATLAB array of loops has been superseded by our internal array of loops.

jeanluct commented 8 years ago

I'm not so sure about that. I recall thinking about that a while back, but there were some reasons to not do it. I'll ponder it for a bit...

mbudisic commented 7 years ago

We can create a .count() or .number() or .nloops() command if you think overloading length may mess with some internals. I think current size(A.coords,1) is clunky and makes a user think about the underlying implementation of the loop object.

jeanluct commented 7 years ago

I'm still not convinced we need a name for that command. But if we are going to, I would vote for nloops or even numloops. We might look elsewhere in braidlab to see if we can mimic terminology from elsewhere.

One argument against using length is that it could also be interpreted as the actual length of a loop. I notice that the braid class has a length which gives the unreduced length. But in that case it is standard mathematical terminology.

jeanluct commented 7 years ago

Reminder: see the comments in #140 opened by MRA and now marked as dupe.

It might be best to have arrays of loops, but to have the array "repacked" as 2D array before calling the C++ routine. The speed hit of recopying might not be so bad, and if we gain in elegance that would be good. Still, I'm a bit wary of such a large-scale change. Definitely experiment in a branch first.