# Solving a General System of Linear Equations (sv)

sv computes the solution to a real system of linear equations $$AX=B$$, where $$A$$ is an $$n \times n$$ matrix and $$X$$ and $$B$$ are $$n \times n_{\text{rhs}}$$ matrices.

The $$LU$$ decomposition with partial pivoting and row interchanges is used to factor $$A$$ as

$A = P L U$

where $$P$$ is a permutation matrix, $$L$$ is unit lower triangular, and $$U$$ is upper triangular. The factored form of $$A$$ is then used to solve the system of equations $$A X = B$$.

## Multiple Right-Hand Sides

 A (input/output) real or complex valued GeMatrix On entry, the $$m \times n$$ matrix to be factored. On exit, the factors $$L$$ and $$U$$ from the factorization $$A = PLU$$. The unit diagonal elements of $$L$$ are not stored. piv (output) integer valued DenseVector The pivot indices. For $$1 \leq i \leq \min\{m, n\}$$, row $$i$$ of the matrix was interchanged with row $$piv_i$$. B (input/output) real or complex valued GeMatrix On entry, the $$n \times n_{\text{rhs}}$$ matrix of right hand side matrix $$B$$. On exit, if the return value equals zero, the $$n \times n_{\text{rhs}}$$ solution matrix $$X$$.

Return value:

 i=0 Successful exit. i>0 $$U_{i,i}$$ is exactly zero. The factorization has been completed, but the factor $$U$$ is exactly singular, so the solution could not be computed.

## Single Right-Hand Side

 A (input/output) real or complex valued GeMatrix On entry, the $$m \times n$$ matrix to be factored. On exit, the factors $$L$$ and $$U$$ from the factorization $$A = PLU$$. The unit diagonal elements of $$L$$ are not stored. piv (output) integer valued DenseVector The pivot indices. For $$1 \leq i \leq \min\{m, n\}$$, row $$i$$ of the matrix was interchanged with row $$piv_i$$. b (input/output) real or complex valued DenseVector On entry, the right hand side vector $$b$$. On exit, if the return value equals zero, the solution vector $$x$$.

Return value:

 i=0 Successful exit. i>0 $$U_{i,i}$$ is exactly zero. The factorization has been completed, but the factor $$U$$ is exactly singular, so the solution could not be computed.