Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
srfm::tensor::CachedMetricTensor Class Reference

#include <tensor.hpp>

Public Member Functions

 CachedMetricTensor (MetricTensor metric, double tol=1e-8)
 
MetricMatrix evaluate (const SpacetimePoint &x) const
 
std::optional< MetricMatrix > inverse (const SpacetimePoint &x) const
 Delegate: compute g^μν (inverse metric) at x.
 
bool is_lorentzian (const SpacetimePoint &x) const
 Delegate: return true iff metric has Lorentzian signature (−,+,+,+) at x.
 
double spacetime_interval (const SpacetimePoint &x, const FourVelocity &dx) const
 Delegate: compute ds² = g_μν dx^μ dx^ν at x.
 
void invalidate () const noexcept
 Invalidate the cache, forcing re-evaluation on the next call to evaluate().
 

Static Public Member Functions

static CachedMetricTensor make_minkowski (double time_scale=1.0, double spatial_scale=1.0)
 Flat Minkowski-like metric: g = diag(−time_scale², σ², σ², σ²).
 
static CachedMetricTensor make_diagonal (double time_scale, const std::array< double, 3 > &vol)
 Diagonal metric from per-asset volatilities.
 
static CachedMetricTensor make_from_covariance (double time_scale, const Eigen::Matrix3d &cov)
 Full covariance-based metric from a 3×3 asset covariance matrix.
 

Detailed Description

Cache wrapper around MetricTensor::evaluate().

MetricTensor::evaluate() is called many times per geodesic integration step (once per Christoffel finite-difference probe). When the probe points are close together, the metric value changes negligibly. This wrapper avoids redundant computation by caching the most recently evaluated (point, result) pair and returning the cached result whenever the requested point is within tol (L∞ norm) of the cached point.

All other MetricTensor operations (inverse, is_lorentzian, spacetime_interval) are delegated directly to the inner MetricTensor without caching, as they are called far less frequently.

Usage

auto cached = CachedMetricTensor::make_minkowski(1.0, 0.2);
auto g = cached.evaluate(pt); // fast on repeated nearby calls
cached.invalidate(); // force re-evaluation on next call
static CachedMetricTensor make_minkowski(double time_scale=1.0, double spatial_scale=1.0)
Flat Minkowski-like metric: g = diag(−time_scale², σ², σ², σ²).
Definition tensor.hpp:314

Thread safety

NOT thread-safe — one instance per thread / per GeodesicSolver.

Definition at line 271 of file tensor.hpp.

Constructor & Destructor Documentation

◆ CachedMetricTensor()

srfm::tensor::CachedMetricTensor::CachedMetricTensor ( MetricTensor  metric,
double  tol = 1e-8 
)
inlineexplicit

Construct wrapping an existing MetricTensor with an optional tolerance.

Parameters
metricMetricTensor to wrap (copied by value).
tolL∞ distance threshold for cache hit (default 1e-8).

Definition at line 277 of file tensor.hpp.

Member Function Documentation

◆ evaluate()

MetricMatrix srfm::tensor::CachedMetricTensor::evaluate ( const SpacetimePoint &  x) const
inline

Evaluate g_μν at x, returning a cached result when the point is close enough to the previously cached point (L∞ distance < tol).

Definition at line 282 of file tensor.hpp.

◆ invalidate()

void srfm::tensor::CachedMetricTensor::invalidate ( ) const
inlinenoexcept

Invalidate the cache, forcing re-evaluation on the next call to evaluate().

Definition at line 309 of file tensor.hpp.

◆ inverse()

std::optional< MetricMatrix > srfm::tensor::CachedMetricTensor::inverse ( const SpacetimePoint &  x) const
inline

Delegate: compute g^μν (inverse metric) at x.

Definition at line 293 of file tensor.hpp.

◆ is_lorentzian()

bool srfm::tensor::CachedMetricTensor::is_lorentzian ( const SpacetimePoint &  x) const
inline

Delegate: return true iff metric has Lorentzian signature (−,+,+,+) at x.

Definition at line 298 of file tensor.hpp.

◆ make_diagonal()

static CachedMetricTensor srfm::tensor::CachedMetricTensor::make_diagonal ( double  time_scale,
const std::array< double, 3 > &  vol 
)
inlinestatic

Diagonal metric from per-asset volatilities.

Definition at line 321 of file tensor.hpp.

◆ make_from_covariance()

static CachedMetricTensor srfm::tensor::CachedMetricTensor::make_from_covariance ( double  time_scale,
const Eigen::Matrix3d &  cov 
)
inlinestatic

Full covariance-based metric from a 3×3 asset covariance matrix.

Definition at line 327 of file tensor.hpp.

◆ make_minkowski()

static CachedMetricTensor srfm::tensor::CachedMetricTensor::make_minkowski ( double  time_scale = 1.0,
double  spatial_scale = 1.0 
)
inlinestatic

Flat Minkowski-like metric: g = diag(−time_scale², σ², σ², σ²).

Definition at line 314 of file tensor.hpp.

◆ spacetime_interval()

double srfm::tensor::CachedMetricTensor::spacetime_interval ( const SpacetimePoint &  x,
const FourVelocity &  dx 
) const
inline

Delegate: compute ds² = g_μν dx^μ dx^ν at x.

Definition at line 303 of file tensor.hpp.


The documentation for this class was generated from the following file: