spsolve_with_known
- compas.numerical.spsolve_with_known(A, b, x, known)[source]
Solve (sparse) a system of linear equations with part of solution known.
- Parameters:
- Aarray
Coefficient matrix (sparse) represented as an (m x n) array.
- barray
Right-hand-side represented as an (m x 1) array.
- xarray
Unknowns/knowns represented as an (n x 1) array.
- knownlist
The indices of the known elements of
x
.
- Returns:
- array
(n x 1) vector solution.
Notes
Computes the solution (using spsolve) of the system of linear equations.
\[\mathbf{A} \mathbf{x} = \mathbf{b}\]Same function as solve_with_known, but for sparse matrix A.
Examples
>>> A = array([[2, 1, 3], [2, 6, 8], [6, 8, 18]]) >>> b = array([[1], [3], [5]]) >>> x = array([[0.3], [0], [0]]) >>> x = solve_with_known(A, b, x, [0]) >>> allclose(x, array([[0.3], [0.4], [0.0]])) True