Skip to content

num::thomas

Defined in header <linear/factorization/thomas.hpp>

template <typename Float = double>
void thomas(const vec<Float> &a, const vec<Float> &b, const vec<Float> &c,
            const vec<Float> &d, vec<Float> &x);

Solve a tridiagonal system by the Thomas algorithm: \(a_{i-1} x_{i-1} + b_i x_i + c_i x_{i+1} = d_i\). Uses LAPACK dgtsv when available.

Exceptions

  • std::invalid_argument: If the diagonal lengths are inconsistent.