jeanluct / braidlab

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

Special values as generator indices can cause zero generators #119

Closed mbudisic closed 9 years ago

mbudisic commented 9 years ago

Even though we disallowed "0" as input to braid, zero generators can still apparently be created.

Also inf can safely be passed to braid as well. We should consider disallowing special values as well or, alternatively, skipping them without error. For debugging purposes, I think it would be better if NaN and Inf were treated as errors in input.

Currently the situation looks like this:

>> braidlab.braid([1, nan, 2])
ans = 
 < 1  0  2 >
>> braidlab.braid([1, inf, 2])
ans = 
 < 1  2147483647           2 >
>> braidlab.braid([1, -inf, 2])
ans = 
 < 1 -2147483648           2 >
>> braidlab.braid([1, -nan, 2])
ans = 
 < 1  0  2 >
jeanluct commented 9 years ago

This is due directly to

>> int32(inf)

ans =

  2147483647

int32, unlike double, cannot have a representation for infinity. Also

>> int32(nan)

ans =

           0

That one's a bit weird! Again, int32 has no "redundant" codes that can be used to hide special meaning, as for double. I'll fix this.