Skip to main content

solve_flat

Function solve_flat 

Source
pub fn solve_flat<T: Real>(
    q: &[T],
    k0: &[T],
    layers: &[LayerCoeffs<T>],
    n_layers: usize,
    parallel: bool,
) -> Result<Vec<PointResult<T>>>
Expand description

Solves many stacks of equal depth against a shared q-grid.

This is the batched entry point shaped for accelerator dispatch: inputs are flat, row-major buffers and every (stack, q) pair is independent.

§Parameters

  • q: scattering vectors in 1/Angstrom, length n_q.
  • k0: vacuum wavenumber per stack in 1/Angstrom, length n_stacks.
  • layers: row-major (n_stacks, n_layers) buffer of layer records.
  • n_layers: depth of every stack, at least two.
  • parallel: distribute (stack, q) pairs across rayon when true.

§Returns

Row-major (n_stacks, n_q) results.

§Errors

[RefloxideError::InvalidShape] when layers.len() != n_stacks * n_layers or n_layers < 2; [RefloxideError::SingularDynamicMatrix] with energy_index set to the stack index and q_index to the q index.