[PYTHON MATRIX-SIG] Bug in LinearAlgebra

tim@lassi.ece.uiuc.edu tim@lassi.ece.uiuc.edu
Tue, 15 Oct 1996 16:33:10 -0500


James Crotinger <jac@gandalf.llnl.gov> writes:
>
>tim@lassi.ece.uiuc.edu writes:
> > ================
> >  1.  0.  0.
> >  0.  1.  0.
> >  0.  0.  1.
> > 
> >  1.  1.  1.    # These are not the eigenvalues, where is -1.
>
>Singular values are, by definition, positive. The nonzero singular
>values are the positive square root of the eigenvalues of A' * A
>(where ' denotes transpose).

Ooops! OK, then LinearAlgebra.determinant is indeed wrong. Well I
'fixed' it by using LinearAlgebra.eigenvalues instead, only to uncover
a problem with multiply.reduce. Check this out:

c = Numeric.array([1.-1j, 1+1j,1])
print c
print
print c[0]*c[1]*c[2]
print
print Numeric.product(c)
print
print Numeric.multiply.reduce(c)
================
 (1.-1.j)  (1.+1.j)  (1.+0.j)

(2+0j)

(2+1j)

(2+1j)

This is not right!


Here's the fixed (but not really tested) version of determinant:

def determinate(a):
    _assertRank2(a)
    _assertSquareness(a)
    ev = eigenvalues(a)
    return Numeric.product(ev)


-- 
	-tim

+--------------------------------------------------------------------+
| Tim Hochberg               Ultrahigh Speed Digital Electronics Lab |
| tim@lassi.ece.uiuc.edu              University of Illinois         |
| http://dogbert.ece.uiuc.edu/~tim         (217) 333-6014            |
+--------------------------------------------------------------------+

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================