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 | Public Attributes | Friends | List of all members
srfm::tensor::DualNumber Struct Reference

#include <tensor.hpp>

Public Member Functions

constexpr DualNumber operator+ (const DualNumber &o) const noexcept
 
constexpr DualNumber operator- (const DualNumber &o) const noexcept
 
constexpr DualNumber operator* (const DualNumber &o) const noexcept
 
constexpr DualNumber operator/ (const DualNumber &o) const noexcept
 
constexpr DualNumber operator+ (double s) const noexcept
 
constexpr DualNumber operator- (double s) const noexcept
 
constexpr DualNumber operator* (double s) const noexcept
 
constexpr DualNumber operator/ (double s) const noexcept
 
constexpr DualNumber operator- () const noexcept
 

Public Attributes

double value
 Real part.
 
double deriv
 Infinitesimal (ε) part: the directional derivative.
 

Friends

constexpr DualNumber operator+ (double s, const DualNumber &d) noexcept
 
constexpr DualNumber operator* (double s, const DualNumber &d) noexcept
 

Detailed Description

Forward-mode automatic differentiation scalar: x = value + deriv·ε, ε² = 0.

A dual number carries a real value and its directional derivative simultaneously. Arithmetic operations propagate both components according to the standard rules of dual-number algebra: (a+bε) + (c+dε) = (a+c) + (b+d)ε (a+bε) × (c+dε) = ac + (ad+bc)ε [ε² = 0] (a+bε) / (c+dε) = a/c + (bc−ad)/c²ε [c≠0]

Usage for metric derivatives

To compute ∂g_μν/∂x^σ exactly (without finite-difference truncation error):

// Seed coordinate σ with derivative 1; all others with derivative 0.
for (int k = 0; k < 4; ++k)
xd[k] = DualNumber{x(k), k == sigma ? 1.0 : 0.0};
// Evaluate the dual-number metric; extract the .deriv component.
auto gd_mu_nu = dual_metric_fn(xd);
// gd_mu_nu(mu, nu).deriv == ∂g_μν/∂x^σ (exact, no rounding)
Eigen::Matrix< DualNumber, SPACETIME_DIM, 1 > DualSpacetimePoint
Definition tensor.hpp:131

Definition at line 80 of file tensor.hpp.

Member Function Documentation

◆ operator*() [1/2]

constexpr DualNumber srfm::tensor::DualNumber::operator* ( const DualNumber &  o) const
inlineconstexprnoexcept

Definition at line 92 of file tensor.hpp.

◆ operator*() [2/2]

constexpr DualNumber srfm::tensor::DualNumber::operator* ( double  s) const
inlineconstexprnoexcept

Definition at line 111 of file tensor.hpp.

◆ operator+() [1/2]

constexpr DualNumber srfm::tensor::DualNumber::operator+ ( const DualNumber &  o) const
inlineconstexprnoexcept

Definition at line 86 of file tensor.hpp.

◆ operator+() [2/2]

constexpr DualNumber srfm::tensor::DualNumber::operator+ ( double  s) const
inlineconstexprnoexcept

Definition at line 105 of file tensor.hpp.

◆ operator-() [1/3]

constexpr DualNumber srfm::tensor::DualNumber::operator- ( ) const
inlineconstexprnoexcept

Definition at line 117 of file tensor.hpp.

◆ operator-() [2/3]

constexpr DualNumber srfm::tensor::DualNumber::operator- ( const DualNumber &  o) const
inlineconstexprnoexcept

Definition at line 89 of file tensor.hpp.

◆ operator-() [3/3]

constexpr DualNumber srfm::tensor::DualNumber::operator- ( double  s) const
inlineconstexprnoexcept

Definition at line 108 of file tensor.hpp.

◆ operator/() [1/2]

constexpr DualNumber srfm::tensor::DualNumber::operator/ ( const DualNumber &  o) const
inlineconstexprnoexcept

Definition at line 96 of file tensor.hpp.

◆ operator/() [2/2]

constexpr DualNumber srfm::tensor::DualNumber::operator/ ( double  s) const
inlineconstexprnoexcept

Definition at line 114 of file tensor.hpp.

Friends And Related Symbol Documentation

◆ operator*

constexpr DualNumber operator* ( double  s,
const DualNumber &  d 
)
friend

Definition at line 124 of file tensor.hpp.

◆ operator+

constexpr DualNumber operator+ ( double  s,
const DualNumber &  d 
)
friend

Definition at line 121 of file tensor.hpp.

Member Data Documentation

◆ deriv

double srfm::tensor::DualNumber::deriv

Infinitesimal (ε) part: the directional derivative.

Definition at line 82 of file tensor.hpp.

◆ value

double srfm::tensor::DualNumber::value

Real part.

Definition at line 81 of file tensor.hpp.


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