Special values as generator indices can cause zero generators
Closed this issue · 1 comments
mbudisic commented
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
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.