8#include "../../include/srfm/manifold/n_asset_interval.hpp"
17 const int N =
static_cast<int>(
prices.size());
18 Eigen::VectorXd coords(N + 1);
20 for (
int i = 0; i < N; ++i) {
26std::optional<NAssetEvent>
28 if (prices.size() == 0) {
33 ev.
prices = std::move(prices);
39std::optional<IntervalResult>
44 if (
static_cast<int>(a.prices.size()) != manifold.n_assets()) {
47 if (
static_cast<int>(b.prices.size()) != manifold.n_assets()) {
53 Eigen::VectorXd xb = b.to_coords();
54 Eigen::VectorXd dx = xb - xa;
57 Eigen::VectorXd x_mid = 0.5 * (xa + xb);
58 auto g_opt = manifold.metric_at(x_mid);
59 if (!g_opt) {
return std::nullopt; }
62 double ds_sq = dx.dot((*g_opt) * dx);
66 result.
type = classify(ds_sq);
67 result.
magnitude = std::sqrt(std::abs(ds_sq));
72std::optional<std::vector<IntervalResult>>
75 std::span<const NAssetEvent> events,
77 std::vector<IntervalResult> results;
78 results.reserve(events.size());
80 for (
const auto& ev : events) {
81 auto r = compute(ref, ev, manifold);
82 if (!r) {
return std::nullopt; }
83 results.push_back(std::move(*r));
std::optional< std::vector< IntervalResult > > batch_from_reference(const NAssetEvent &ref, std::span< const NAssetEvent > events, const NAssetManifold &manifold) const noexcept
Compute intervals from a reference event to many events.
std::optional< IntervalResult > compute(const NAssetEvent &a, const NAssetEvent &b, const NAssetManifold &manifold) const noexcept
Compute ds² = g_μν Δx^μ Δx^ν between two events.
(N+1)-dimensional Lorentzian manifold for N financial assets.
Result of a single interval computation.
double ds_sq
Squared interval ds².
IntervalType type
TIMELIKE, SPACELIKE, or LIGHTLIKE.
double magnitude
sqrt(|ds²|).
A spacetime event: a moment in time with N asset prices.
static std::optional< NAssetEvent > make(double t, Eigen::VectorXd prices) noexcept
Factory: validate and construct an NAssetEvent.
Eigen::VectorXd prices
N asset price coordinates.
Eigen::VectorXd to_coords() const noexcept
Concatenate (t, prices) into a single (N+1)-vector.