Skip to main content

compute_oblique_stencil

Function compute_oblique_stencil 

Source
pub fn compute_oblique_stencil(
    res: (f32, f32, f32),
    b0_dir: (f32, f32, f32),
) -> [[[f32; 3]; 3]; 3]
Expand description

Compute SVD-fitted oblique 27-point dipole stencil via DST-based Poisson solves.

Matches the Julia reference implementation from QuantitativeSusceptibilityMappingTGV.jl. For each unique centrosymmetric pair of the 26 off-center stencil positions, a Poisson equation is solved using DST-I to obtain Green’s function values. These are then fitted to the analytical dipole field via least squares, and resolution-weighted to produce the final stencil.

Note: The delta function for offsets (di,dj,dk) and (-di,-dj,-dk) are identical (both place +1 at mid±I and -2 at mid), so we only compute 13 unique Poisson solutions and solve a full-rank 13×13 system. This avoids the rank deficiency that would occur with all 26 positions.