pulsatrix
Loading...
Searching...
No Matches
pulsatrix::datalog::DualNumber< T > Struct Template Reference

A dual number (value, grad): value is the ordinary real-valued semiring result, grad is its derivative w.r.t. whichever single base fact's weight was seeded with grad = 1 (every other base fact's weight is seeded with grad = 0, i.e. treated as a constant). More...

#include <datalog_dual_semiring.hpp>

Public Member Functions

bool operator== (const DualNumber &other) const
 Epsilon-tolerant equality, mirroring RealSemiring<T>'s own reason for needing one (see datalog_weighted_engine.cpp's values_equal): the weighted engine's fixpoint-termination check compares a Semiring::Value produced by one round against the previous round's stored value, and floating-point summation order can differ (bit-for-bit) across std::unordered_map iteration orders even when mathematically identical. values_equal<Value> falls back to this operator== for any non-floating-point Value (a struct, here), so this type supplies its own epsilon comparison directly rather than relying on values_equal's floating-point branch (which never fires for a struct Value).
 
bool operator!= (const DualNumber &other) const
 

Public Attributes

T value
 
T grad
 

Detailed Description

template<typename T>
struct pulsatrix::datalog::DualNumber< T >

A dual number (value, grad): value is the ordinary real-valued semiring result, grad is its derivative w.r.t. whichever single base fact's weight was seeded with grad = 1 (every other base fact's weight is seeded with grad = 0, i.e. treated as a constant).

Note
This is forward-mode automatic differentiation, implemented as an ordinary algebraic (closed-form) construction – not a new virtual/graph type. See datalog_semiring.hpp's own trait-shape note: any type supplying Value, zero(), one(), add(), mul() is a legal Semiring for naive_evaluate_weighted/ semi_naive_evaluate_weighted, with zero changes to the evaluator itself. add/mul below are just the sum rule (d(a+b) = da + db) and product rule (d(a*b) = da*b + a*db) of ordinary calculus, applied at every semiring operation the already-proven-correct weighted engine performs – so a whole fixpoint evaluation under DualSemiring<T> computes, for every derived fact, both its real-valued provenance-semiring weight and the exact partial derivative of that weight w.r.t. the one seeded base fact, in a single pass, with no separate symbolic-differentiation step and no numerical approximation.

Member Function Documentation

◆ operator!=()

template<typename T >
bool pulsatrix::datalog::DualNumber< T >::operator!= ( const DualNumber< T > &  other) const
inline

◆ operator==()

template<typename T >
bool pulsatrix::datalog::DualNumber< T >::operator== ( const DualNumber< T > &  other) const
inline

Epsilon-tolerant equality, mirroring RealSemiring<T>'s own reason for needing one (see datalog_weighted_engine.cpp's values_equal): the weighted engine's fixpoint-termination check compares a Semiring::Value produced by one round against the previous round's stored value, and floating-point summation order can differ (bit-for-bit) across std::unordered_map iteration orders even when mathematically identical. values_equal<Value> falls back to this operator== for any non-floating-point Value (a struct, here), so this type supplies its own epsilon comparison directly rather than relying on values_equal's floating-point branch (which never fires for a struct Value).

Member Data Documentation

◆ grad

template<typename T >
T pulsatrix::datalog::DualNumber< T >::grad

◆ value

template<typename T >
T pulsatrix::datalog::DualNumber< T >::value

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