# HG changeset patch # User Tuomo Valkonen # Date 1764356474 18000 # Node ID 794833f18a055674713686196d5e06693b9da28c # Parent 1f1b946fc656383084ab50c461d27a3b1f904f07 Add residual to DataTerm diff -r 1f1b946fc656 -r 794833f18a05 src/mapping/dataterm.rs --- a/src/mapping/dataterm.rs Fri Nov 28 13:28:17 2025 -0500 +++ b/src/mapping/dataterm.rs Fri Nov 28 14:01:14 2025 -0500 @@ -64,6 +64,16 @@ pub fn fidelity(&self) -> &'_ G { &self.g } + + /// Returns the residual $Ax-b$. + pub fn residual<'a, 'b>(&'b self, x: &'a Domain) -> >::Codomain + where + &'a Domain: Instance, + >::Codomain: + Sub<&'b >::Codomain, Output = >::Codomain>, + { + self.opA.apply(x) - &self.b + } } //+ AdjointProductBoundedBy, P, FloatType = F>,