[SciPy-dev] sinm and cosm for matrices with real coefficients

Robert Kern robert.kern at gmail.com
Sun Apr 30 00:08:29 CDT 2006

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.

Thank you for your interest, though. Please let us know if you find anything
else that seems bogus.

Robert Kern
robert.kern at gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Scipy-dev mailing list