[SciPy-dev] sinm and cosm for matrices with real coefficients
Travis Oliphant
oliphant.travis at ieee.org
Sun Apr 30 01:46:06 CDT 2006
Robert Kern wrote:
> Vanuxem Grégory wrote:
>
>> Hi,
>>
>> The code of cosm and sinm for matrices with real coefficients can be
>> improved.
>>
>> The actual code is something like:
>>
>> sinm : (expm(j * M) - expm(- j*M)) / (2 * j)
>>
>> cosm : (expm(j * M) + expm(- j* M)) / 2
>>
>> But this can be changed to (only for matrices with real coefficients):
>>
>> sinm : imaginary_part(expm(j * M))
>>
>> cosm : real_part(expm(j * M))
>>
>
> However, we want the functions to work on complex matrices, too. The
> optimization is probably not worth the extra code to dispatch on the datatype.
> Of course, if someone comes along with a use-case where they need the extra
> speed, and they have a patch, unit tests, and benchmarks ready, we'd probably
> put it in.
>
Actually the code was already dispatching on the data-type (to convert
back to real instead of leaving it complex). So, this one was an easy
addition and I added it.
The functions still need to be adapted so they will return matrices when
given matrices.
-Travis
More information about the Scipy-dev
mailing list