Can create malformed `DitStr`'s
When explicitly stating the type parameter N of a DitStr it is possible to form a malformed DitStr where
Int(dit_str) > D^N - 1. See the following example:
using BitBasis, Yao
julia> d = DitStr{2,2}(5)
101 ₍₂₎
julia> length(d)
2
julia> product_state(d)
ERROR: BoundsError: ...
I am not sure if this will ever cause problems, but I am happy to open a PR with a consistency check in the inner constructor of DitStr.
Thanks for the issue. I knew this one. I wanted to make some change but I am also worried about it may cause performance issue if we make any type of check since it is such an elementary type. On GPU, throwing an error is even not allowed. It also make sense if we do not make any check because our floating point numbers and integers never throw an error when the number overflows.
But I agree if we can add a checker for certain interface functions like product_state to prevent malformed user input.
FYI DitStr is technically a "ieee-like integer" so it overflows instead of an error.