Skip to main content

ForwardModel

Struct ForwardModel 

Source
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>

Source

pub fn new(model: &'a ImagePlaneModel) -> Result<Self>

Validates model and creates a CPU-backed evaluator borrowing it.

Source

pub fn with_backend( model: &'a ImagePlaneModel, backend: Arc<dyn Backend>, ) -> Result<Self>

Validates model and creates an evaluator using the shared execution backend.

Source

pub fn model(&self) -> &ImagePlaneModel

Returns the compiled model borrowed by this evaluator.

Source

pub fn workspace(&self) -> Result<ForwardWorkspace>

Allocates reusable buffers sized for the model’s low-resolution grid.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,