_mti_kernel
tit._mti_kernel ¶
Fused numba kernel for the K>=2 mTI envelope direction search.
This is a per-element re-implementation of the NumPy pipeline in
:mod:tit.calc -- _quadratic_forms -> coarse Fibonacci sweep ->
_diverse_top_m_directions -> _refine_local_directions -- that
walks every element once and keeps all intermediates (the 192-direction
sweep, the seed table, the patch evaluations) in small per-element
scratch instead of (n, 192) / (n, 6, 16) temporaries. The
NumPy path is memory-bound on those temporaries; this kernel is
compute-bound and parallel over elements (prange).
Every step mirrors the NumPy code's arithmetic and tie-breaking (first
maximum wins in every argmax, the grid-cosine seed exclusion, the
patch geometry and the shrinking round schedule), so results agree with
the NumPy path to floating-point round-off. :func:tit.calc selects it
automatically when numba is importable; see :func:sweep_refine.
The module imports cleanly without numba (HAVE_NUMBA is False and
:func:sweep_refine raises), so the caller can fall back.
sweep_refine ¶
Run the fused sweep(+refine) kernel.
Parameters¶
arrs : list of np.ndarray, each (N, 3) float64
Validated field list [E_1a, E_1b, ...] (2K arrays).
psi : np.ndarray (K,) or None
Per-pair envelope phase; None/all-zero selects the real path.
directions : np.ndarray (D, 3)
Coarse sweep grid (:func:tit.calc._fibonacci_sphere).
too_close : np.ndarray (D, D) bool
Seed-exclusion table directions @ directions.T > cos(min_angle).
patch_weights : np.ndarray (R, patch, 3)
Frame weights for every refinement round (already shrunk per round).
n_seeds : int
refine : bool
Returns¶
md, carrier_power, best_direction