Special Relativity in Financial Modeling
1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
src
simd
gamma_scalar.cpp
Go to the documentation of this file.
1
/**
2
* @file gamma_scalar.cpp
3
* @brief Scalar reference implementation of the gamma batch kernel.
4
*
5
* Module: src/simd/
6
* Owner: AGT-08 — 2026-03-01
7
*
8
* Responsibility
9
* --------------
10
* Compute gamma_i = 1.0 / sqrt(1.0 - betas[i]^2) for all i in [0, n).
11
* This is the authoritative reference implementation. All SIMD variants
12
* must produce results within 1 ULP of the scalar path for any valid input.
13
*
14
* Correctness Notes
15
* -----------------
16
* • Input betas are expected to be in [0, BETA_MAX_SAFE) — the same range
17
* accepted by BetaVelocity::make().
18
* • A defensive clamp to BETA_CLAMP_LIMIT is applied before the sqrt to
19
* ensure the argument of sqrt is strictly positive even in edge cases.
20
* • gamma ≥ 1.0 for all valid betas; the result is always finite.
21
*/
22
23
#include "
simd_batch_detail.hpp
"
24
#include "
momentum/momentum.hpp
"
// BETA_MAX_SAFE
25
26
#include <cmath>
27
28
namespace
srfm::simd::detail
{
29
30
static
constexpr
double
BETA_CLAMP_LIMIT
=
31
srfm::momentum::BETA_MAX_SAFE
- 1.0e-10;
32
33
void
compute_gamma_scalar
(
34
const
double
*
SRFM_RESTRICT
betas,
35
std::size_t n,
36
double
*
SRFM_RESTRICT
out)
noexcept
37
{
38
for
(std::size_t i = 0; i < n; ++i) {
39
// Clamp to ensure sqrt argument > 0.
40
const
double
b = (betas[i] >
BETA_CLAMP_LIMIT
) ?
BETA_CLAMP_LIMIT
: betas[i];
41
const
double
b2 = b * b;
42
const
double
denom = 1.0 - b2;
// in (0, 1] for valid betas
43
out[i] = 1.0 / std::sqrt(denom);
44
}
45
}
46
47
}
// namespace srfm::simd::detail
srfm::momentum::BETA_MAX_SAFE
constexpr double BETA_MAX_SAFE
Definition
momentum.hpp:62
srfm::simd::detail
Definition
beta_avx2.cpp:28
srfm::simd::detail::BETA_CLAMP_LIMIT
static constexpr double BETA_CLAMP_LIMIT
Definition
beta_avx2.cpp:30
srfm::simd::detail::compute_gamma_scalar
void compute_gamma_scalar(const double *__restrict__ betas, std::size_t n, double *__restrict__ out) noexcept
Scalar reference implementation of the gamma batch kernel.
Definition
gamma_scalar.cpp:33
simd_batch_detail.hpp
Internal raw-double compute signatures for SIMD batch kernels.
SRFM_RESTRICT
#define SRFM_RESTRICT
Definition
simd_batch_detail.hpp:50
momentum.hpp
Momentum-Velocity Signal Processor (AGT-03 / SRFM)
Generated on Fri Sep 25 2026 23:20:56 for Special Relativity in Financial Modeling by
1.9.8