pub struct ForwardModel<'a> { /* private fields */ }Expand description
Allocation-friendly CPU implementation of the image-plane FPM forward model.
Public spectrum and two-dimensional destination views must have standard
C-style row-major layout. The layout is validated once at each public
computational boundary and nonstandard views are rejected without copying.
Methods returning an Array2 allocate their result; _into methods borrow
caller-provided workspace and destinations.
Implementations§
Source§impl<'a> ForwardModel<'a>
impl<'a> ForwardModel<'a>
Sourcepub fn new(model: &'a ImagePlaneModel) -> Result<Self>
pub fn new(model: &'a ImagePlaneModel) -> Result<Self>
Validates model and creates a CPU-backed evaluator borrowing it.
Sourcepub fn with_backend(
model: &'a ImagePlaneModel,
backend: Arc<dyn Backend>,
) -> Result<Self>
pub fn with_backend( model: &'a ImagePlaneModel, backend: Arc<dyn Backend>, ) -> Result<Self>
Validates model and creates an evaluator using the shared execution backend.
Sourcepub fn model(&self) -> &ImagePlaneModel
pub fn model(&self) -> &ImagePlaneModel
Returns the compiled model borrowed by this evaluator.
Sourcepub fn workspace(&self) -> Result<ForwardWorkspace>
pub fn workspace(&self) -> Result<ForwardWorkspace>
Allocates reusable buffers sized for the model’s low-resolution grid.
Sourcepub fn extract_patch(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
source: usize,
) -> Result<Array2<Complex64>>
pub fn extract_patch( &self, object_spectrum: ArrayView2<'_, Complex64>, source: usize, ) -> Result<Array2<Complex64>>
Allocates and returns one source’s low-resolution complex Fourier patch.
Sourcepub fn insert_patch_update(
&self,
object_spectrum: ArrayViewMut2<'_, Complex64>,
source: usize,
update: &[Complex64],
scale: f64,
) -> Result<()>
pub fn insert_patch_update( &self, object_spectrum: ArrayViewMut2<'_, Complex64>, source: usize, update: &[Complex64], scale: f64, ) -> Result<()>
Adds scale * update through the adjoint crop operator into object_spectrum.
Sourcepub fn apply_pupil(
&self,
patch: &[Complex64],
pupil: &Pupil,
destination: &mut [Complex64],
) -> Result<()>
pub fn apply_pupil( &self, patch: &[Complex64], pupil: &Pupil, destination: &mut [Complex64], ) -> Result<()>
Multiplies a row-major complex patch by the same-shaped sampled pupil.
Sourcepub fn forward_source_field(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
source: usize,
) -> Result<Array2<Complex64>>
pub fn forward_source_field( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, source: usize, ) -> Result<Array2<Complex64>>
Coherent low-resolution field for one illumination source.
Sourcepub fn forward_field(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
frame: usize,
) -> Result<Array2<Complex64>>
pub fn forward_field( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, frame: usize, ) -> Result<Array2<Complex64>>
Coherent field for a non-multiplexed frame. A coded frame with exactly one source is represented by a field scaled by the square-root weight.
Sourcepub fn forward_intensity(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
frame: usize,
) -> Result<Array2<f64>>
pub fn forward_intensity( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, frame: usize, ) -> Result<Array2<f64>>
Allocates the predicted (row, column) intensity array for one acquisition frame.
Coded frames are incoherent weighted sums of source intensities. Optional frame gain and optical background are applied to the result.
Sourcepub fn forward_intensity_into(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
frame: usize,
workspace: &mut ForwardWorkspace,
destination: &mut [f64],
) -> Result<()>
pub fn forward_intensity_into( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, frame: usize, workspace: &mut ForwardWorkspace, destination: &mut [f64], ) -> Result<()>
Writes one predicted frame to row-major destination, reusing workspace.
Sourcepub fn forward_intensity_stack_into(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
destination: &mut [f64],
worker_count: usize,
) -> Result<()>
pub fn forward_intensity_stack_into( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, destination: &mut [f64], worker_count: usize, ) -> Result<()>
Predicts every measured frame into a contiguous
[frame][row][column] destination using independent worker scratch.
Frame order and floating-point results within each frame are unchanged
by worker_count. Values larger than the frame count are capped; zero is
rejected. A worker count of one executes directly without spawning.
Sourcepub fn forward_intensity_stack(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
worker_count: usize,
) -> Result<Vec<f64>>
pub fn forward_intensity_stack( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, worker_count: usize, ) -> Result<Vec<f64>>
Allocation-owning convenience wrapper for Self::forward_intensity_stack_into.
Sourcepub fn residual(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
frame: usize,
measured: &[f64],
) -> Result<Vec<f64>>
pub fn residual( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, frame: usize, measured: &[f64], ) -> Result<Vec<f64>>
Returns row-major predicted - measured intensity residuals for one frame.
Sourcepub fn amplitude_projection(
&self,
field: &[Complex64],
measured_intensity: &[f64],
frame: usize,
epsilon: f64,
) -> Result<Vec<Complex64>>
pub fn amplitude_projection( &self, field: &[Complex64], measured_intensity: &[f64], frame: usize, epsilon: f64, ) -> Result<Vec<Complex64>>
Replaces coherent-field amplitude with measured amplitude while retaining phase.
Frame gain and background are inverted before taking the square root of measured
intensity. epsilon is a positive floor for dark predicted amplitudes.
Sourcepub fn frame_loss(
&self,
object_spectrum: ArrayView2<'_, Complex64>,
pupil: &Pupil,
frame: usize,
measured: &[f64],
loss_type: LossType,
) -> Result<f64>
pub fn frame_loss( &self, object_spectrum: ArrayView2<'_, Complex64>, pupil: &Pupil, frame: usize, measured: &[f64], loss_type: LossType, ) -> Result<f64>
Evaluates loss_type between one predicted and measured intensity frame.
Auto Trait Implementations§
impl<'a> Freeze for ForwardModel<'a>
impl<'a> !RefUnwindSafe for ForwardModel<'a>
impl<'a> Send for ForwardModel<'a>
impl<'a> Sync for ForwardModel<'a>
impl<'a> Unpin for ForwardModel<'a>
impl<'a> UnsafeUnpin for ForwardModel<'a>
impl<'a> !UnwindSafe for ForwardModel<'a>
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