Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
beta_scalar.cpp File Reference

Scalar reference implementation of the beta batch kernel. More...

#include "simd_batch_detail.hpp"
#include "momentum/momentum.hpp"
#include <cmath>
#include <algorithm>

Go to the source code of this file.

Namespaces

namespace  srfm
 
namespace  srfm::simd
 
namespace  srfm::simd::detail
 

Functions

void srfm::simd::detail::compute_beta_scalar (const double *__restrict__ velocities, std::size_t n, double &running_max, double *__restrict__ out) noexcept
 Scalar reference implementation of the beta batch kernel.
 

Variables

static constexpr double srfm::simd::detail::BETA_CLAMP_LIMIT
 

Detailed Description

Scalar reference implementation of the beta batch kernel.

Module: src/simd/ Owner: AGT-08 — 2026-03-01

Algorithm: Batch-max

  1. Compute batch_max = max(|velocities[i]|) over all i in [0, n).
  2. Update running_max = max(running_max, batch_max).
  3. For each i: beta_i = |velocities[i]| / running_max.
  4. Clamp each beta_i to BETA_CLAMP_LIMIT.

Why batch-max (not element-wise max)?

Using the maximum of the entire batch as the denominator allows all SIMD variants to produce bit-identical results: AVX-512, AVX2, and scalar all compute the same running_max and perform identical divisions. Element-wise running_max updates introduce a serial dependency that breaks SIMD parallelism AND causes different betas depending on vector width.

Correctness: beta_i = |v_i| / running_max ≤ 1.0 because running_max ≥ batch_max ≥ |v_i|. The invariant beta_i ∈ [0, BETA_MAX_SAFE) is always preserved.

Definition in file beta_scalar.cpp.