pub struct InteractionResidual {
factor: InteractionFactor,
value: DMatrix<Complex>,
}Expand description
What interaction saves for its pullback: the factorization of I - T C and
the interacting T-matrix X.
Fields§
§factor: InteractionFactor§value: DMatrix<Complex>Implementations§
Source§impl InteractionResidual
impl InteractionResidual
Sourcepub fn state_size(local_sizes: &[usize]) -> Result<usize>
pub fn state_size(local_sizes: &[usize]) -> Result<usize>
Bytes needed to save local blocks, coupling, LU and interacting T-matrix.
Sourcepub(crate) fn state_size_uniform(
block_size: usize,
particles: usize,
) -> Result<usize>
pub(crate) fn state_size_uniform( block_size: usize, particles: usize, ) -> Result<usize>
State size for equally sized particle blocks, without a temporary size list.
pub(crate) fn write_state(&self, writer: &mut Writer)
pub(crate) fn read_state(reader: &mut Reader<'_>) -> Result<Self>
Source§impl InteractionResidual
impl InteractionResidual
pub(crate) fn local_shapes( &self, ) -> impl ExactSizeIterator<Item = (usize, usize)>
Sourcepub fn pushforward(
&self,
local: &DMatrix<Complex>,
coupling: &DMatrix<Complex>,
) -> Result<DMatrix<Complex>>
pub fn pushforward( &self, local: &DMatrix<Complex>, coupling: &DMatrix<Complex>, ) -> Result<DMatrix<Complex>>
Directional derivative of the interacting T-matrix with respect to dense
T and C. Reuses the forward LU for one tangent solve.
Sourcepub fn pushforward_blocks(
&self,
local: &[DMatrix<Complex>],
coupling: &DMatrix<Complex>,
) -> Result<DMatrix<Complex>>
pub fn pushforward_blocks( &self, local: &[DMatrix<Complex>], coupling: &DMatrix<Complex>, ) -> Result<DMatrix<Complex>>
Like pushforward, with one tangent per local block.
Solves (I - T C) dX = dT (I + C X) + T dC X without expanding dT.
Sourcepub fn pullback(
&self,
cotangent: &DMatrix<Complex>,
) -> Result<InteractionGradient>
pub fn pullback( &self, cotangent: &DMatrix<Complex>, ) -> Result<InteractionGradient>
Gradients of T and C from cotangent, the gradient of a real loss with
respect to X.
The pullback solves one adjoint system with the forward LU. It has no Rayon
reduction; the LU solve and the matrix products run in faer with the worker
count of linalg.
Sourcepub fn pullback_blocks(
&self,
cotangent: &DMatrix<Complex>,
) -> Result<InteractionGradient<Vec<DMatrix<Complex>>>>
pub fn pullback_blocks( &self, cotangent: &DMatrix<Complex>, ) -> Result<InteractionGradient<Vec<DMatrix<Complex>>>>
Like pullback, with one gradient per diagonal block of a
block-diagonal T, or a single one for a dense T.
fn pullback_with<T>( &self, cotangent: &DMatrix<Complex>, local_gradient: impl FnOnce(&LocalMatrix, &DMatrix<Complex>, &DMatrix<Complex>) -> T, ) -> Result<InteractionGradient<T>>
Trait Implementations§
Source§impl Clone for InteractionResidual
impl Clone for InteractionResidual
Source§fn clone(&self) -> InteractionResidual
fn clone(&self) -> InteractionResidual
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InteractionResidual
impl Debug for InteractionResidual
Source§impl SavedState for InteractionResidual
impl SavedState for InteractionResidual
Auto Trait Implementations§
impl Freeze for InteractionResidual
impl RefUnwindSafe for InteractionResidual
impl Send for InteractionResidual
impl Sync for InteractionResidual
impl Unpin for InteractionResidual
impl UnwindSafe for InteractionResidual
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.