pub struct FieldResidual {
pub(super) vectors: Vec<[Complex; 3]>,
pub(super) polarizations: Vec<u8>,
pub(super) points: Vec<[f64; 3]>,
pub(super) coefficients: Option<Vec<Complex>>,
pub(super) helicity: bool,
pub(super) fixed_vectors: bool,
}Expand description
What field saves for its pullback: its inputs, for weighted fields or for the
matrix that samples every mode.
The pullback splits the longer of the point and mode axes into at most 32 blocks,
fixed by the shape, as PhasesResidual::pullback does. Each block writes the
gradients of its own points or modes and a partial sum of the gradients of the
other axis, and the partial sums add in block order; a mode’s polarization pulls
back once, from its total over all points. The blocks run in parallel from 4096
points times modes (PARALLEL_ENTRIES), and in the same order on the calling thread
below, so the thread count does not change the result.
Fields§
§vectors: Vec<[Complex; 3]>§polarizations: Vec<u8>§points: Vec<[f64; 3]>§coefficients: Option<Vec<Complex>>§helicity: bool§fixed_vectors: boolImplementations§
Source§impl FieldResidual
impl FieldResidual
Sourcepub fn coefficient_count(&self) -> usize
pub fn coefficient_count(&self) -> usize
Number of weighted amplitudes, or zero for a field operator.
Sourcepub fn shape(&self) -> (usize, usize)
pub fn shape(&self) -> (usize, usize)
Flattened output dimensions (3 * samples, modes or one weighted column).
Sourcepub fn validate_tangents(
&self,
coefficients: &[Complex],
points: &[[f64; 3]],
vectors: &[[Complex; 3]],
) -> Result<()>
pub fn validate_tangents( &self, coefficients: &[Complex], points: &[[f64; 3]], vectors: &[[Complex; 3]], ) -> Result<()>
Validate amplitude, sample-point and wavevector tangents. An operator takes an empty amplitude tangent because it has no amplitude input.
Sourcepub fn pushforward(
&self,
coefficients: &[Complex],
points: &[[f64; 3]],
vectors: &[[Complex; 3]],
) -> Result<DMatrix<Complex>>
pub fn pushforward( &self, coefficients: &[Complex], points: &[[f64; 3]], vectors: &[[Complex; 3]], ) -> Result<DMatrix<Complex>>
Push one direction through the amplitudes, phases and polarizations. Each mode’s polarization derivative is contracted once and reused at every point.
Sourcepub fn pullback(&self, cotangent: &DMatrix<Complex>) -> Result<FieldGradient>
pub fn pullback(&self, cotangent: &DMatrix<Complex>) -> Result<FieldGradient>
Gradients for a cotangent of the field’s shape. The pullback recomputes the
polarization and phase derivatives instead of storing a dense field Jacobian.
Sourcefn mode(&self, j: usize, variable: bool) -> Result<ModeTerms>
fn mode(&self, j: usize, variable: bool) -> Result<ModeTerms>
The wavevector, polarization jet and amplitude of plane mode j.
Sourcefn rows<'c>(
&self,
cotangent: &'c DMatrix<Complex>,
j: usize,
) -> &'c [[Complex; 3]]
fn rows<'c>( &self, cotangent: &'c DMatrix<Complex>, j: usize, ) -> &'c [[Complex; 3]]
The three Cartesian cotangents of each sample, contiguous in the cotangent
column of mode j, or in the one column of a weighted field.
Source§impl FieldResidual
impl FieldResidual
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.