Trait LinearizedRelation
pub trait LinearizedRelation<S>: Debug + Sync {
// Required methods
fn unknown_dimension(&self) -> usize;
fn parameter_dimension(&self) -> usize;
fn residual_dimension(&self) -> usize;
fn primal(&self, residual: &mut [S]) -> Result<(), Diagnostic>;
fn jvp(
&self,
tangent: RelationTangent<'_, S>,
residual_tangent: &mut [S],
) -> Result<(), Diagnostic>;
fn vjp(
&self,
residual_cotangent: &[S],
cotangent: RelationCotangent<'_, S>,
) -> Result<(), Diagnostic>;
}Description
One immutable linearization of a residual relation.
The contract is scalar-representation-parametric. Implementations expose the primal residual, a Jacobian-vector product (JVP), and the paired vector-Jacobian product (VJP) without prescribing symbolic, automatic, or handwritten differentiation.
Required Methods§
fn unknown_dimension(&self) -> usize
fn unknown_dimension(&self) -> usize
Number of implicitly solved coordinates.
fn parameter_dimension(&self) -> usize
fn parameter_dimension(&self) -> usize
Number of selected design coordinates.
fn residual_dimension(&self) -> usize
fn residual_dimension(&self) -> usize
Number of residual equations.
fn primal(&self, residual: &mut [S]) -> Result<(), Diagnostic>
fn primal(&self, residual: &mut [S]) -> Result<(), Diagnostic>
Evaluate the primal residual at the fixed linearization point.
§Errors
Returns a structured diagnostic for an output-shape mismatch or an invalid/non-finite evaluation.
fn jvp(
&self,
tangent: RelationTangent<'_, S>,
residual_tangent: &mut [S],
) -> Result<(), Diagnostic>
fn jvp( &self, tangent: RelationTangent<'_, S>, residual_tangent: &mut [S], ) -> Result<(), Diagnostic>
Evaluate a selected tangent action, including
R_w * unknown_tangent + R_p * parameter_tangent.
§Errors
Returns a structured diagnostic for a shape mismatch or an invalid/non-finite evaluation.
fn vjp(
&self,
residual_cotangent: &[S],
cotangent: RelationCotangent<'_, S>,
) -> Result<(), Diagnostic>
fn vjp( &self, residual_cotangent: &[S], cotangent: RelationCotangent<'_, S>, ) -> Result<(), Diagnostic>
Evaluate (R_w^T * c, R_p^T * c) for one residual cotangent c.
§Errors
Returns a structured diagnostic for a shape mismatch or an invalid/non-finite evaluation.