rustc -C opt-level=3): 2049 (203973 B .text / 53737 insns)22/9 Hz): 249004 B / 5979082 B (ratio 124502/2989541, saved 2865039/2989541, 11682 ″ dittos)| Rank & Crown | Function Name & Domain | Best Use & Snap-Circuit Role | Pin Signature & 64-Vec Hash | Hardware _rdtsc (p/q) | Details & Quick Peek |
|---|---|---|---|---|---|
| #1674 CROWN #1 of 2 | decay_pade domain: decay | id: 42764f8a71d0Aye: aye::Peter+Omni(0+1)::aarch64 @ 432Hz | Deterministic Sovereign Compute Kernel Pure-Rust C64-bounded integer transformation kernel verified across 64 canonical test vectors for deterministic Snap-Circuit composition. Specialized Multi-Pin Stage `(i64,i64,i64)->i64` — wire matching input pins via `snap_dag` or `snap_pipeline`. | (i64,i64,i64)->i6464-vec BLAKE3: d620cb1efe8aC64 RAM: 1399/32768 (2798 B src) | 2740867/100000 cyc/op 3427541/400000 ns/op | 400000000/3427541 ops/us 606 B .text (172 insns) | Trit + (1) | Inspect Details & ASM →Quick Peek Rust (2798 B)/// Q16.16 exponential decay by closed-form [3/3] Padé, integer-only.
///
/// `out = variance * exp(-elapsed / half_life)`, elapsed and half_life in
/// world ticks, amplitude Q16.16.
///
/// The exponent is clamped into the Padé domain without a 128-bit divide in the
/// common case. `((elapsed as i128) << 16) / half_life` is exact but lowers to
/// `__divti3`, and a ring holding many memories pays that per slot. Here:
///
/// * `elapsed > 40 * half_life` is "older than the domain" -> fully decayed,
/// decided before any divide;
/// * otherwise one `i64` multiply and one `i64` divide;
/// * the wide form survives only when `elapsed * 65536` would overflow, which
/// is where exactness matters and cost does not.
///
/// Total for every `i64`: `half_life <= 0` yields 0 (nothing can be said),
/// `elapsed <= 0` returns the input unchanged, and the final multiply is
/// clamped rather than allowed to wrap.
pub fn decay_pade(variance_q16: i64, elapsed: i64, half_life_ticks: i64) -> i64 {
const RATE_ONE: i128 = 1 << 16;
const INV_LN2_Q16: i128 = 94548;
const LN2_Q16: i128 = 45426;
const PADE_X_MAX: i64 = 40 << 16;
if half_life_ticks <= 0 {
return 0;
}
if elapsed <= 0 {
return variance_q16;
}
// Older than the Padé domain: the amplitude is exactly zero, and saying so
// here skips the divide -- the common case for a long-lived ring.
let x_q16 = if let Some(limit) = half_life_ticks.checked_mul(PADE_X_MAX >> 16) {
if elapsed >= limit {
PADE_X_MAX
} else {
match elapsed.checked_mul(1 << 16) {
Some(scaled) => (scaled / half_life_ticks).min(PADE_X_MAX),
None => {
(((elapsed as i128) << 16) / i128::from(half_life_ticks))
.min(i128::from(PADE_X_MAX)) as i64
}
}
}
} else {
match elapsed.checked_mul(1 << 16) {
Some(scaled) => (scaled / half_life_ticks).min(PADE_X_MAX),
None => {
(((elapsed as i128) << 16) / i128::from(half_life_ticks))
.min(i128::from(PADE_X_MAX)) as i64
}
}
};
let x = i128::from(x_q16);
let k = (x * INV_LN2_Q16) >> 32;
let r = x - k * LN2_Q16;
let r2 = (r * r) >> 16;
let r3 = (r2 * r) >> 16;
let num = 120 * RATE_ONE - 60 * r + 12 * r2 - r3;
let den = 120 * RATE_ONE + 60 * r + 12 * r2 + r3;
if den <= 0 || k >= 64 {
return 0;
}
let amplitude = ((num << 16) / den) >> k;
let out = (i128::from(variance_q16) * amplitude) >> 16;
if out > i128::from(i64::MAX) {
i64::MAX
} else if out < i128::from(i64::MIN) {
i64::MIN
} else {
out as i64
}
} |
| #1714 PEER of 2 | decay_pade domain: decay | id: 8c57c8977eaeAye: aye::Peter+Omni(0+1)::aarch64 @ 432Hz | Deterministic Sovereign Compute Kernel Pure-Rust C64-bounded integer transformation kernel verified across 64 canonical test vectors for deterministic Snap-Circuit composition. Specialized Multi-Pin Stage `(i64,i64,i64)->i64` — wire matching input pins via `snap_dag` or `snap_pipeline`. | (i64,i64,i64)->i6464-vec BLAKE3: d620cb1efe8aC64 RAM: 1257/65536 (1257 B src) | 6901067/100000 cyc/op 1725883/80000 ns/op | 80000000/1725883 ops/us 496 B .text (141 insns) | Trit + (1) | Inspect Details & ASM →Quick Peek Rust (1257 B)/// Q16.16 exponential decay by closed-form [3/3] Padé, integer-only.
///
/// `out = variance * exp(-elapsed / half_life)`, elapsed and half_life in
/// world ticks, amplitude Q16.16. Total for every i64 input.
pub fn decay_pade(variance_q16: i64, elapsed: i64, half_life_ticks: i64) -> i64 {
const RATE_ONE: i128 = 1 << 16;
const INV_LN2_Q16: i128 = 94548;
const LN2_Q16: i128 = 45426;
const PADE_X_MAX: i128 = 40 << 16;
if half_life_ticks <= 0 {
return 0;
}
if elapsed <= 0 {
return variance_q16;
}
let mut x = (elapsed as i128) << 16;
x /= half_life_ticks as i128;
if x > PADE_X_MAX {
return 0;
}
if x <= 0 {
return variance_q16;
}
let k = (x * INV_LN2_Q16) >> 32;
let r = x - k * LN2_Q16;
let r2 = (r * r) >> 16;
let r3 = (r2 * r) >> 16;
let num = 120 * RATE_ONE - 60 * r + 12 * r2 - r3;
let den = 120 * RATE_ONE + 60 * r + 12 * r2 + r3;
if den <= 0 || k >= 64 {
return 0;
}
let amplitude = ((num << 16) / den) >> k;
let out = (variance_q16 as i128 * amplitude) >> 16;
if out > i64::MAX as i128 {
i64::MAX
} else if out < i64::MIN as i128 {
i64::MIN
} else {
out as i64
}
} |