Open mbudisic opened 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...
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.
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.
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.
Consider a loop vector, e.g.,
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 particularlength(A)
will return1
. We should probably overload thelength
function, especially because a MATLAB array of loops has been superseded by our internal array of loops.