# [SciPy-Dev] Sylvester equation solver for complex matrices

Nils Wagner nwagner@iam.uni-stuttgart...
Wed Feb 15 15:44:56 CST 2012

```On Wed, 15 Feb 2012 12:42:04 -0600
Warren Weckesser <warren.weckesser@enthought.com> wrote:
> On Sat, Feb 11, 2012 at 11:24 AM, Warren Weckesser <
> warren.weckesser@enthought.com> wrote:
>
>>
>>
>> On Sat, Feb 11, 2012 at 4:45 AM, Nils Wagner
>><nwagner@iam.uni-stuttgart.de
>> > wrote:
>>
>>> Hi all,
>>>
>>> I run a short test on the recent solver for Sylvester
>>> equations.
>>> In case of complex input matrices the method returns
>>>  ** On entry to ZTRSYL parameter number  2 had an
>>>illegal
>>> value
>>>
>>> Nils
>>>
>>>
>>
>> Thanks, Nils.  The new solve_sylvester function didn't
>>handle complex
>> matrices correctly. I have submitted a pull request (
>> https://github.com/scipy/scipy/pull/155) that should fix
>>this.
>>
>> Warren
>>
>>
>
> Nils, the fix has been committed to the master branch.
>  Let us know if you
> find any other problems.
>
> Warren
>
>
>
>>
>>> import numpy as np
>>> from scipy import linalg as la
>>> np.random.seed(10)
>>> a = np.random.rand(20,20)+1j*np.random.rand(20,20)
>>> b = np.random.rand(20,20)+1j*np.random.rand(20,20)
>>> q = np.random.rand(20,20)+1j*np.random.rand(20,20)
>>>
>>> x = la.solve_sylvester(a,b,q)
>>> res = la.norm(np.dot(a,x)+np.dot(x,b)-q)
>>> _______________________________________________
>>> SciPy-Dev mailing list
>>> SciPy-Dev@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/scipy-dev
>>>
>>
>>
Hi Warren,

Great. It works fine for me.
BTW, is the Sylvester equation solver part of the next
scipy release ?
How about Lyapunov and Riccati equation solvers ?

Cheers,
Nils
```