pub struct FieldResidual {
waves: WaveSet,
points: Vec<[f64; 3]>,
coefficients: Vec<Complex>,
}Expand description
What field saves for its pullback: the wave set, the points and the
coefficients. Its size grows with the samples plus the modes, not their product.
Fields§
§waves: WaveSet§points: Vec<[f64; 3]>§coefficients: Vec<Complex>Implementations§
Source§impl FieldResidual
impl FieldResidual
Sourcepub fn state_size(
modes: usize,
positions: usize,
points: usize,
cylindrical: bool,
) -> Result<usize>
pub fn state_size( modes: usize, positions: usize, points: usize, cylindrical: bool, ) -> Result<usize>
Saved-state byte count determined solely by the input dimensions and wave family, independent of material values or derivative directions.
Sourcepub fn shape(&self) -> (usize, usize)
pub fn shape(&self) -> (usize, usize)
Samples and Cartesian components: the shape of the field array.
Sourcepub fn input_sizes(&self) -> (usize, usize)
pub fn input_sizes(&self) -> (usize, usize)
Number of mode coefficients and expansion centres in the input.
Sourcepub fn pushforward(
&self,
coefficients: &[Complex],
points: &[[f64; 3]],
positions: &[[f64; 3]],
ks: [Complex; 2],
) -> Result<Vec<[Complex; 3]>>
pub fn pushforward( &self, coefficients: &[Complex], points: &[[f64; 3]], positions: &[[f64; 3]], ks: [Complex; 2], ) -> Result<Vec<[Complex; 3]>>
Field tangent in one direction of coefficients, sample points, expansion centres and medium wavenumbers. Each sample reuses the primal wave caches.
Sourcepub fn pushforward_axial(
&self,
coefficients: &[Complex],
points: &[[f64; 3]],
positions: &[[f64; 3]],
ks: [Complex; 2],
kz: &[f64],
) -> Result<Vec<[Complex; 3]>>
pub fn pushforward_axial( &self, coefficients: &[Complex], points: &[[f64; 3]], positions: &[[f64; 3]], ks: [Complex; 2], kz: &[f64], ) -> Result<Vec<[Complex; 3]>>
Self::pushforward with an axial-wavenumber tangent per cylindrical mode.
fn pushforward_impl<const N: usize>( &self, coefficients: &[Complex], tangent: GeometryTangent<'_>, ) -> Result<Vec<[Complex; 3]>>
Sourcepub fn pullback(&self, cotangent: &[[Complex; 3]]) -> Result<FieldGradient>
pub fn pullback(&self, cotangent: &[[Complex; 3]]) -> Result<FieldGradient>
Input gradients from cotangent, the gradient of a real loss with respect to the
field, one Cartesian vector per sample. The waves are evaluated again per sample;
no dense Jacobian is stored.
Each point gradient comes from its own sample only. The coefficient, position
and wavenumber gradients add in chunks of consecutive samples fixed by the
sample count, and the chunk sums in chunk order
(numerics::parallel::try_fold_ordered), so the thread count does not change
them.
Sourcepub fn pullback_axial(
&self,
cotangent: &[[Complex; 3]],
) -> Result<(FieldGradient, Vec<f64>)>
pub fn pullback_axial( &self, cotangent: &[[Complex; 3]], ) -> Result<(FieldGradient, Vec<f64>)>
Self::pullback plus a real axial-wavenumber gradient for each mode of a
cylindrical basis; the axial gradients add their chunk sums the same way.
fn pullback_impl<const N: usize>( &self, cotangent: &[[Complex; 3]], ) -> Result<(FieldGradient, Vec<f64>)>
Trait Implementations§
Source§impl Debug for FieldResidual
impl Debug for FieldResidual
Source§impl SavedState for FieldResidual
impl SavedState for FieldResidual
Auto Trait Implementations§
impl Freeze for FieldResidual
impl RefUnwindSafe for FieldResidual
impl Send for FieldResidual
impl Sync for FieldResidual
impl Unpin for FieldResidual
impl UnwindSafe for FieldResidual
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.