I'm implementing Charikar's fast search on a locality sensitive hash and I'm looking for a fast method of permuting bits (the kind of thing that can be done in one operation in MMIX) in C#.
The requirements are:
I know Knuth goes into this in detail but I was wondering if there was any .NET/C# specific solution.
EDIT: I'm using .NET version 3.5.
Since C# doesn't provide any bit-manipulation instructions that Knuth didn't have in C, no, there's no .NET/C#-specific solution.
At the same time, .NET does offer dynamic compilation which will help you repeatedly perform the shuffle efficiently.
What version of .NET? The easiest approach will probably be to use Knuth's algorithm and encode the resulting operations in an Expression<Func<ulong, ulong>>
, then compile the result as a Func<long, long>
delegate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With