def solve_sylvester(a,b,q):
<EOL>r,u = schur(a, output='<STR_LIT>')<EOL>s,v = schur(b.conj().transpose(), output='<STR_LIT>')<EOL>f = np.dot(np.dot(u.conj().transpose(), q), v)<EOL>trsyl, = get_lapack_funcs(('<STR_LIT>',), (r,s,f))<EOL>if trsyl is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>y, scale, info = trsyl(r, s, f, tranb='<STR_LIT:C>')<EOL>y = scale*y<EOL>if info < <NUM_LIT:0>:<EOL><INDENT>raise LinAlgError("<STR_LIT>" % (-info,))<EOL><DEDENT>return np.dot(np.dot(u, y), v.conj().transpose())<EOL>
Computes a solution (X) to the Sylvester equation (AX + XB = Q).

Parameters
----------
a : (M, M) array_like
    Leading matrix of the Sylvester equation
b : (N, N) array_like
    Trailing matrix of the Sylvester equation
q : (M, N) array_like
    Right-hand side

Returns
-------
x : (M, N) ndarray
    The solution to the Sylvester equation.

Raises
------
LinAlgError
    If 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.

.. versionadded:: 0.11.0