pub struct AddResidual {
lower: [DMatrix<Complex>; 2],
upper: [DMatrix<Complex>; 2],
solve: InternalSolve,
down: DMatrix<Complex>,
}Expand description
What add saves for its pullback: four of the eight input blocks, the internal
fields and their factorization.
The pullback reads only blocks 1 and 3 of the lower S-matrix and blocks 0 and 2 of the upper one; the other four input blocks are released after the forward pass.
Fields§
§lower: [DMatrix<Complex>; 2]Lower blocks 1 and 3: reflection of waves incident from the positive side (above) and downward transmission.
upper: [DMatrix<Complex>; 2]Upper blocks 0 and 2: upward transmission and reflection of waves incident from the negative side (below).
solve: InternalSolveUpgoing internal fields (I - L1 U2)^-1 [L0, L1 U3] and their factorization.
down: DMatrix<Complex>Downgoing internal fields U2 up + [0, U3].
Implementations§
Source§impl AddResidual
impl AddResidual
Sourcepub fn state_size(n: usize) -> Result<usize>
pub fn state_size(n: usize) -> Result<usize>
Byte count for saved composition state with n modes per direction.
Source§impl AddResidual
impl AddResidual
Sourcepub fn shape(&self) -> (usize, usize)
pub fn shape(&self) -> (usize, usize)
The shape (n, n) of each scattering block, with n modes in each direction.
Sourcepub fn pushforward(&self, lower: &Blocks, upper: &Blocks) -> Result<Blocks>
pub fn pushforward(&self, lower: &Blocks, upper: &Blocks) -> Result<Blocks>
Propagate all eight block tangents through the recorded internal-field solve. The forward factorization is reused; no dense Jacobian is formed.
Sourcepub fn pullback(&self, cotangent: &Blocks) -> Result<AddGradient>
pub fn pullback(&self, cotangent: &Blocks) -> Result<AddGradient>
Input cotangents under dL = Re(sum(conj(g) * dx)).
Trait Implementations§
Source§impl Debug for AddResidual
impl Debug for AddResidual
Source§impl SavedState for AddResidual
impl SavedState for AddResidual
Auto Trait Implementations§
impl Freeze for AddResidual
impl RefUnwindSafe for AddResidual
impl Send for AddResidual
impl Sync for AddResidual
impl Unpin for AddResidual
impl UnwindSafe for AddResidual
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.