"""Dense linear-system solves for small panel-system matrices."""
from __future__ import annotations
import numpy as np
from buffalo_panel.type_aliases import FloatArray
[docs]
def solve_dense(matrix: FloatArray, rhs: FloatArray) -> FloatArray:
"""Solve a dense linear system with NumPy.
Parameters
----------
matrix : FloatArray
Dense coefficient matrix with shape ``(n, n)``.
rhs : FloatArray
Right-hand-side vector or matrix with shape ``(n,)`` or ``(n, m)``.
Returns
-------
FloatArray
Solution vector or matrix with the same trailing shape as ``rhs``.
Raises
------
numpy.linalg.LinAlgError
Raised by NumPy when ``matrix`` is singular or otherwise cannot be
solved as a square dense system.
ValueError
Raised by NumPy when ``matrix`` and ``rhs`` have incompatible shapes.
"""
return np.asarray(np.linalg.solve(matrix, rhs), dtype=np.float64)