Skip to content

MurrellGroup/BitPacking.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitPacking.jl

Stable Dev Build Status Coverage

BitPacking.jl provides small bit-packed building blocks for Julia array code:

  • NArray, NVector, and NMatrix pack a static group of narrow values into one storage value.
  • NarrowArray, NarrowVector, and NarrowMatrix view an array of packed groups as a logical array of values.
  • NarrowTuple and @NarrowTuple pack heterogeneous isbits values, with optional padding fields.

Packages can extend BitPacking.bitwidth(::Type) for their own narrow scalar types.

Examples

using BitPacking

v = NVector(true, false, true, false, true, false, true, false)

Tuple(v)                 # (true, false, true, false, true, false, true, false)
reinterpret(UInt8, v)    # 0x55
x = Bool[1, 0, 1, 0, 1, 0, 1, 0]
packed = NarrowArray{Bool}(x)

copy(packed) == x        # true
parent(packed)           # Vector{NVector{Bool,8}}
t = @NarrowTuple(0x12, true)

Tuple(t)                 # (0x12, true)
BitPacking.bitwidth(t)   # 9

Installation

using Pkg
Pkg.add("BitPacking")

About

Fast, device-agnostic bitpacking in Julia

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages