jeanluct / braidlab

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

Size of multiple loop structure #140

Closed allshouse closed 7 years ago

allshouse commented 7 years ago

It is possible to have multiple loops stored in the same variable.

l = braidlab.loop([1 0 0 0; 0 1 0 0]);

When typing whos, Matlab says that l is 1 x 1 regardless of the number of loops in the structure. The built in function sizegives the same result. Is it possible to create an internal function l.size which gives the number of loops contained in l?

mbudisic commented 7 years ago

This is a valid problem, but it already has issue #136 assigned to it. At this point, we decided to use size(l.coords,1) to tell the number of loops stored, but this is not the most intuitive solution.

jeanluct commented 7 years ago

Yes, this is a longstanding and annoying issue. The reason for the current setup is that creating an actual array of loops loses the speed advantage of the C++ MEX files. i.e., a multiple loop object is better stored as a large 2D array wrapped inside a loop class, which the C++ routine can process rapidly. If it was an array of individual loops, they would need to be first packed into a 2D array, which would defeat the purpose. Or maybe it wouldn't make such a big difference.