Skip to main content

tridiagonal_solve

Function tridiagonal_solve 

Source
pub fn tridiagonal_solve<T: GpuFloat>(
    _handle: &SolverHandle,
    lower: &[T],
    diag: &[T],
    upper: &[T],
    rhs: &mut [T],
    n: usize,
) -> SolverResult<()>
Expand description

Solves a tridiagonal system using the Thomas algorithm (sequential).

The system is: lower[i] * x[i-1] + diag[i] * x[i] + upper[i] * x[i+1] = rhs[i] where lower[0] corresponds to a_1 (the sub-diagonal starting at row 1).

On exit, rhs is overwritten with the solution vector x.

§Arguments

  • _handle — solver handle (reserved for future GPU-accelerated variants).
  • lower — sub-diagonal array of length n - 1.
  • diag — main diagonal array of length n.
  • upper — super-diagonal array of length n - 1.
  • rhs — right-hand side of length n, overwritten with the solution.
  • n — system dimension.

§Errors

Returns SolverError::DimensionMismatch if array lengths are invalid. Returns SolverError::SingularMatrix if a zero pivot is encountered.