yasfpy.coupling.ops#

Protocols for dense coupling operations.

The main simulation code routes dense coupling matvecs via a backend that implements yasfpy.coupling.backends.CouplingBackend.multiply(). For the “dense” backend, we further delegate to an object implementing the DenseCouplingOps protocol.

This extra level of indirection allows the implementation to:

  • choose a CPU or CUDA matvec implementation at runtime

  • attach per-Simulation persistent buffers/caches for performance

Classes#

DenseCouplingOps

Protocol for applying W in the dense coupling backend.

Module Contents#

class yasfpy.coupling.ops.DenseCouplingOps#

Bases: Protocol

Protocol for applying W in the dense coupling backend.

Implementations may maintain persistent device buffers, pinned host buffers, and/or autotuning state.

matvec(x, idx=None)#

Compute W @ x.

Parameters:
  • x – Input vector of unknowns. The expected shape is backend-dependent (typically a flattened VSWF coefficient array).

  • idx –

    Optional wavelength/channel index.

    • If provided, compute a single wavelength/channel (solver-style matvec on a 1D vector).

    • If None, compute all wavelengths at once (multi-wavelength matvec, usually producing a 2D array).

Returns:

The product W @ x.

Return type:

numpy.ndarray