bundles / scipy latest / scipy / linalg / _solvers / solve_sylvester
function
scipy.linalg._solvers:solve_sylvester
source: /scipy/linalg/_solvers.py :31
Signature
def solve_sylvester ( a , b , q ) Summary
Computes a solution (X) to the Sylvester equation .
Extended Summary
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
a: (M, M) array_likeLeading matrix of the Sylvester equation
b: (N, N) array_likeTrailing matrix of the Sylvester equation
q: (M, N) array_likeRight-hand side
Returns
x: (M, N) ndarrayThe solution to the Sylvester equation.
Raises
: LinAlgErrorIf solution was not found
Notes
Computes a solution to the Sylvester matrix equation via the Bartels- Stewart algorithm. The A and B matrices first undergo Schur decompositions. The resulting matrices are used to construct an alternative Sylvester equation (RY + YS^T = F) where the R and S matrices are in quasi-triangular form (or, when R, S or F are complex, triangular form). The simplified equation is then solved using *TRSYL from LAPACK directly.
Examples
Given `a`, `b`, and `q` solve for `x`:import numpy as np from scipy import linalg a = np.array([[-3, -2, 0], [-1, -1, 3], [3, -5, -1]]) b = np.array([[1]]) q = np.array([[1],[2],[3]]) x = linalg.solve_sylvester(a, b, q)✓
x
✗np.allclose(a.dot(x) + x.dot(b), q)
✓Aliases
-
scipy.linalg.solve_sylvester