Safe Haskell | None |
---|---|
Language | Haskell2010 |
Reverse bits
There are several algorithms performing the same thing here (reversing bits into words of different sizes). There are benchmarks for them in Haskus's "bench" directory. The fastest one for the current architecture should be selected below. If you find that another algorithm is faster on your architecture, please report it.
- class BitReversable w where
- reverseBitsGeneric :: (FiniteBits a, Integral a) => a -> a
- reverseBitsObvious :: FiniteBits a => a -> a
- reverseBits3Ops :: Word8 -> Word8
- reverseBits4Ops :: Word8 -> Word8
- reverseBitsTable :: Word8 -> Word8
- reverseBits7Ops :: Word8 -> Word8
- reverseBits5LgN :: FiniteBits a => a -> a
- liftReverseBits :: (FiniteBits a, Integral a) => (Word8 -> Word8) -> a -> a
Generic
reverseBitsGeneric :: (FiniteBits a, Integral a) => a -> a Source #
Reverse bits in a Word
Algorithms
reverseBitsObvious :: FiniteBits a => a -> a Source #
Obvious recursive verion
reverseBits3Ops :: Word8 -> Word8 Source #
Reverse bits in a Word8 (3 64-bit operations, modulus division)
reverseBits4Ops :: Word8 -> Word8 Source #
Reverse bits in a Word8 (4 64-bit operations, no division)
reverseBitsTable :: Word8 -> Word8 Source #
Reverse bits using a lookup table
reverseBits7Ops :: Word8 -> Word8 Source #
Reverse bits in a Word8 (7 no 64-bit operations, no division)
reverseBits5LgN :: FiniteBits a => a -> a Source #
Parallel recursive version
liftReverseBits :: (FiniteBits a, Integral a) => (Word8 -> Word8) -> a -> a Source #
Convert a function working on Word8 to one working on any Word
The number of bits in the Word must be a multiple of 8