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: Holds the #1 Equivalence Crown across 3 functionally identical implementations (fastest verified hardware _rdtsc). Low-latency L1-resident kernel (2222129/200000 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: 2222129/200000 cycles/op
Latency: 1205733/400000 ns/op
Throughput: 400000000/1205733 ops/us
Compiled ELF64 .text: 256 B (67 x86_64 insns)
C64 64KB RAM Budget: 825/65536 (825 B source)
Ternary Vote: + (score 1) | Salience: 28765/306
Pure-Rust Capsule Source Code (825 B)
pub const fn st_golf_b158_bitplane_swar_u64(trit_word: u64) -> u64 {
    const M: u64 = 0x1111_1111_1111_1111;
    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 mut p = (pos_nib | (pos_nib >> 3)) & 0x0303_0303_0303_0303;
    p = (p | (p >> 6)) & 0x000F_000F_000F_000F;
    p = (p | (p >> 12)) & 0x0000_00FF_0000_00FF;
    let pos_plane = (p | (p >> 24)) & 0xFFFF;
    let mut n = (neg_nib | (neg_nib >> 3)) & 0x0303_0303_0303_0303;
    n = (n | (n >> 6)) & 0x000F_000F_000F_000F;
    n = (n | (n >> 12)) & 0x0000_00FF_0000_00FF;
    let neg_plane = (n | (n >> 24)) & 0xFFFF;
    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 (256 B .text / 67 insns)
st_golf_b158_bitplane_swar_u64:
    mov    rcx, rdi
    shr    rcx, 3
    mov    rax, rdi
    shr    rax, 2
    mov    rdx, rdi
    shr    rdx
    and    rdx, rdi
    or    rdx, rax
    movabs    rax, 1229782938247303441
    and    rcx, rax
    and    rcx, rdx
    not    rdi
    mov    rdx, rdi
    shr    rdx, 3
    mov    rsi, rdi
    shr    rsi, 2
    shr    rdi
    or    rsi, rdi
    and    rdx, rax
    and    rdx, rsi
    mov    rax, rcx
    shr    rax, 3
    or    rax, rcx
    mov    rsi, rax
    shr    rsi, 6
    movabs    rdi, 3377751260921868
    and    rsi, rdi
    movabs    r8, 844437815230467
    and    rax, r8
    or    rax, rsi
    mov    rsi, rax
    shr    rsi, 12
    or    rsi, rax
    mov    rax, rsi
    shr    rax, 24
    or    eax, esi
    movzx    esi, ax
    mov    rax, rdx
    shr    rax, 3
    or    rax, rdx
    mov    r9, rax
    shr    r9, 6
    and    r9, rdi
    and    rax, r8
    or    rax, r9
    mov    rdi, rax
    shr    rdi, 12
    or    rdi, rax
    movzx    r8d, di
    mov    rax, rdi
    shr    rax, 24
    or    eax, r8d
    or    rdx, rcx
    mov    rcx, rdx
    shr    rcx, 4
    add    rcx, rdx
    movabs    rdx, 217020518514230019
    and    rdx, rcx
    movabs    rcx, 72340172838076673
    imul    rcx, rdx
    shr    rcx, 24
    movabs    rdx, 1095216660480
    and    rdx, rcx
    shl    eax, 16
    or    rax, rdx
    or    rax, rsi
    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 (THIS CAPSULE)
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
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