You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BinaryInteger/ilog2() is basically a bit counting operation, which is why it returns Count<IX>. This is awkward when you want the result as an instance of Self. Instead of adding a bunch of overloads, I think it might be better to perform this conversion in an arbitrary base function. The latter offers additional utility and a constant binary base argument should fold into a simple conversion, assuming I add an appropriate fast path.
The text was updated successfully, but these errors were encountered:
I might need a Radix<T> (natural ≥ 2) type so that Nonzero<T.Magnitude> can return a nonoptional result. Hm. Never-mind. Nonzero<T.Magnitude> may be infinite. I would also need Nonzero<Natural<T.Magnitude>>. Meh. Alternatively, I could get the guarantee of Natural<T.Magnitude> from an UnsignedInteger & SystemsInteger constraint.
oscbyspro
changed the title
Add: Logarithms for arbitrary bases
Add: BinaryInteger/ilog(_:)
Aug 28, 2024
Tangentially, it turns out that the discrete logarithm problem is trivial when the group size is a power of 2. But, everybody already knows that. No dice, but a fun rabbit hole nonetheless.
BinaryInteger/ilog2() is basically a bit counting operation, which is why it returns Count<IX>. This is awkward when you want the result as an instance of Self. Instead of adding a bunch of overloads, I think it might be better to perform this conversion in an arbitrary base function. The latter offers additional utility and a constant binary base argument should fold into a simple conversion, assuming I add an appropriate fast path.
The text was updated successfully, but these errors were encountered: