[SciPy-dev] Efficient algorithms for the matrix cosine and sine

Nils Wagner nwagner at mecha.uni-stuttgart.de
Mon Feb 21 09:36:48 CST 2005


Hi all,

This paper might be of interest

http://www.ma.man.ac.uk/~hargreaves/narep461.pdf

Nils

The current implementation uses a Pade approximant (7,7) of the matrix 
exponential.

def cosm(A):
    """matrix cosine.
    """
    A = asarray(A)
    if A.typecode() not in ['F','D']:
        return toreal(0.5*(expm(1j*A) + expm(-1j*A)))
    else:
        return 0.5*(expm(1j*A) + expm(-1j*A))


def sinm(A):
    """matrix sine.
    """
    A = asarray(A)
    if A.typecode() not in ['F','D']:
        return toreal(-0.5j*(expm(1j*A) - expm(-1j*A)))
    else:
        return -0.5j*(expm(1j*A) - expm(-1j*A))


 def expm(A,q=7):
    """Compute the matrix exponential using Pade approximation of order q.
    """
...






More information about the Scipy-dev mailing list