haskus-binary-1.5: Haskus binary format manipulation

Safe HaskellNone
LanguageHaskell2010

Haskus.Binary.Bits.Reverse

Contents

Description

Reverse bits

There are several algorithms performing the same thing here (reversing bits into words of different sizes). There are benchmarks for them in the "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.

Synopsis

Generic

class ReversableBits w where Source #

Data whose bits can be reversed

Methods

reverseBits :: w -> w Source #

Instances
ReversableBits Int Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

Methods

reverseBits :: Int -> Int Source #

ReversableBits Int8 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Int16 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Int32 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Int64 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Word Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Word8 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Word16 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Word32 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits Word64 Source # 
Instance details

Defined in Haskus.Binary.Bits.Reverse

ReversableBits a => ReversableBits (AsLittleEndian a) Source # 
Instance details

Defined in Haskus.Binary.Endianness

ReversableBits a => ReversableBits (AsBigEndian a) Source # 
Instance details

Defined in Haskus.Binary.Endianness

reverseBitsGeneric :: (FiniteBits a, Integral a, ShiftableBits a, Bitwise a, KnownNat (BitSize a)) => a -> a Source #

Reverse bits in a Word

Algorithms

reverseBitsObvious :: forall a. (FiniteBits a, ShiftableBits a, IndexableBits a, Bitwise a, KnownNat (BitSize a), Eq a) => a -> a Source #

Obvious recursive version

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 :: forall a. (FiniteBits a, ShiftableBits a, Bitwise a, KnownNat (BitSize a)) => a -> a Source #

Parallel recursive version

liftReverseBits :: (ShiftableBits a, Bitwise a, FiniteBits a, Integral a, KnownNat (BitSize 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