bit manipulation - Inferring simplest method to convert bit array 1 to bit array 2 -
consider set of bit arrays of length n. consider set of 1-to-1 functions map set set.
now select single function out of latter set. there algorithm find "minimal" method of implementing function? assume have access fundamental bit array operators such , or xor not , left , right bitshifts.
in case you're wondering, reason want because i'm writing algorithm convert z-curve ordering of bits hilbert-curve ordering of bits. current method make lookup table, bet there's better option.
as simple example, let's have truth table looks this:
00 -> 10 01 -> 01 10 -> 00 11 -> 11
then should able infer that, given input bit string input
, output bit string output
(in java syntax)
output = ((~input) << 1) ^ input
here's proof in case:
00 -> 11 -> 10 -> 10 01 -> 10 -> 00 -> 01 10 -> 01 -> 10 -> 00 11 -> 00 -> 00 -> 11
Comments
Post a Comment