[SciPy-user] Matrix sign function

Pearu Peterson pearu at scipy.org
Wed Sep 24 06:44:07 EDT 2003


On Wed, 24 Sep 2003, Nils Wagner wrote:

> Pearu Peterson schrieb:
> > 
> > On Wed, 24 Sep 2003, Nils Wagner wrote:
> > 
> > > It would be nice to have the matrix sign function in scipy.
> > 
> > Try the following:
> > 
> >   signm=lambda a:linalg.funm(a,lambda v:sign(v)+0j)
> > 
> > This assumes that `a` has real eigenvalues. Otherwise one most use some
> > other sign function that is properly defined for complex values, the
> > current sign is acctually
> >   v |-> sign(real(v))
> 
> To account for complex values, a generalized sign matrix can be defined
> as follows
> 
> sign(v) = \left\{ \begin{array}{c} 1 \Re v > 0 \\ 0 \Re v = 0 \\ -1 \Re
> v < 0 \end{array}\right.

So, this is exactly Numeric.sign that was used above.

> Details are given in the reference (previous e-mail). 

At the moment, I don't have access to given references, could you send 
their pdf files off the list to me: pearu at cens.ioc.ee

> Anyway, I think scipy should have a generalized sign function as well.
> 
> A suitable test case is the following matrix
> 
> array([[ 29.2, -24.2,  69.5,  49.8,   7. ],
>        [ -9.2,   5.2, -18. , -16.8,  -2. ],
>        [-10. ,   6. , -20. , -18. ,  -2. ],
>        [ -9.6,   9.6, -25.5, -15.4,  -2. ],
>        [  9.8,  -4.8,  18. ,  18.2,   2. ]])

What would be the correct result for signm(<given matrix>)?
signm gives:

>>> signm(a)
array([[ 20.728,  -6.576,  29.592,  32.88 ,  -6.576],
       [ -5.808,   2.936,  -8.712,  -9.68 ,   1.936],
       [ -6.24 ,   2.08 ,  -8.36 , -10.4  ,   2.08 ],
       [ -7.344,   2.448, -11.016, -11.24 ,   2.448],
       [  6.192,  -2.064,   9.288,  10.32 ,  -1.064]])

Is this correct?

> Any suggestion for the implementation of a generalized matrix sign
> function ?

See above.

Pearu




More information about the SciPy-User mailing list