Best Use & Engineering Application Guide

Engineering Category: Balanced Ternary & b158 Quantization

Best Use in Production: Separating packed ternary words into positive and negative bitplanes with popcount sparsity tracking for rank-1 quantum-inspired compression.

When to Select This Capsule: Verified baseline member of a 3-capsule Equivalence Class; useful as a reference or cross-validation peer. Low-latency L1-resident kernel (802421/40000 cyc/op); well-suited for high-frequency pipeline stages.

Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(u64)->u64` — snaps directly into linear pipelines or fan-out DAG branches.

Hardware _rdtsc: 802421/40000 cycles/op
Latency: 2177019/400000 ns/op
Throughput: 400000000/2177019 ops/us
Compiled ELF64 .text: 231 B (56 x86_64 insns)
C64 64KB RAM Budget: 99/8192 (792 B source)
Ternary Vote: + (score 1) | Salience: 4927/54
Pure-Rust Capsule Source Code (792 B)
pub const fn st_golf_b158_bitplane_swar_u64(trit_word: u64) -> u64 {
    const M: u64 = 0x1111_1111_1111_1111;
    const GATHER: u64 = 0x0001_0010_0100_1000;
    let pos_nib = ((trit_word >> 3) & ((trit_word >> 2) | ((trit_word >> 1) & trit_word))) & M;
    let nw = !trit_word;
    let neg_nib = ((nw >> 3) & ((nw >> 2) | (nw >> 1))) & M;
    let p2 = (pos_nib | (pos_nib >> 3)) & 0x0303_0303_0303_0303;
    let p4 = (p2 | (p2 >> 6)) & 0x000F_000F_000F_000F;
    let pos_plane = p4.wrapping_mul(GATHER) >> 48;
    let n2 = (neg_nib | (neg_nib >> 3)) & 0x0303_0303_0303_0303;
    let n4 = (n2 | (n2 >> 6)) & 0x000F_000F_000F_000F;
    let neg_plane = n4.wrapping_mul(GATHER) >> 48;
    let active = (pos_nib | neg_nib).count_ones() as u64;
    (active << 32) | (neg_plane << 16) | pos_plane
}
rustc -C opt-level=3 x86_64 Disassembly (231 B .text / 56 insns)
st_golf_b158_bitplane_swar_u64:
    mov    rax, rdi
    shr    rax, 3
    mov    rcx, rdi
    shr    rcx, 2
    mov    rdx, rdi
    shr    rdx
    and    rdx, rdi
    or    rdx, rcx
    movabs    rcx, 1229782938247303441
    and    rax, rcx
    and    rax, rdx
    not    rdi
    mov    rdx, rdi
    shr    rdx, 3
    mov    rsi, rdi
    shr    rsi, 2
    shr    rdi
    or    rsi, rdi
    and    rdx, rcx
    and    rdx, rsi
    mov    rcx, rax
    shr    rcx, 3
    or    rcx, rax
    mov    rsi, rcx
    shr    rsi, 6
    movabs    rdi, 3377751260921868
    and    rsi, rdi
    movabs    r8, 844437815230467
    and    rcx, r8
    or    rcx, rsi
    movabs    rsi, 281543712968704
    imul    rcx, rsi
    shr    rcx, 48
    mov    r9, rdx
    shr    r9, 3
    or    r9, rdx
    mov    r10, r9
    shr    r10, 6
    and    r10, rdi
    and    r9, r8
    or    r9, r10
    imul    r9, rsi
    or    rdx, rax
    mov    rax, rdx
    shr    rax, 4
    add    rax, rdx
    movabs    rdx, 1085102592571150095
    and    rdx, rax
    movabs    rsi, 72340172838076673
    imul    rsi, rdx
    shr    rsi, 56
    shld    rsi, r9, 32
    movabs    rax, 137438887936
    and    rax, rsi
    or    rax, rcx
    ret

Head-to-Head Functional Equivalence Class Peers (3 Implementation(s) Matching 64 Test Vectors)

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#331st_golf_b158_bitplane_swar_u64
domain: OneCompression | id: ad03cf6a56d8304f9fa9d5dbbed27066
2222129/200000 cyc/op1205733/400000 ns/op400000000/1205733 ops/us256 B .text (67 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1190st_golf_b158_bitplane_swar_u64 (THIS CAPSULE)
domain: OneCompression | id: 82481a0614b3ee6b172b3df6ae9e94ba
802421/40000 cyc/op2177019/400000 ns/op400000000/2177019 ops/us231 B .text (56 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1714onecompression_b158_bitplane_decompose
domain: OneCompression | id: ec740dcee41886836ec931a638661abb
3306553/50000 cyc/op8550889/400000 ns/op400000000/8550889 ops/us788 B .text (240 insns)0 (0)omni-toss-weaver @ 528Hz