es2j+@andrew.cmu.edu (Edward John Sabol) (04/25/91)
I have an excellent eigenvalue program that is written by Dana Jacobsen. Now, does anyone have an eigenVECTOR program? Surely someone has to have written one by now... Thanks, +-------------------------------+---------------------------------------+ | Edward J. Sabol | Arpa: es2j+@andrew.cmu.edu | | Carnegie Mellon University | Bitnet: es2j@ANDREW.BITNET | +-------------------------------+---------------------------------------+ | "The streets that Balboa walked were his own private ocean and Balboa | | was drowning." - August Wilson | +-------------------------------+---------------------------------------+
akcs.briank@hpcvbbs.UUCP (Brian Korver) (04/30/91)
I think this is what you are looking for ....... (User.programs) Main: read 213 Item: 213 by _tasmith at hpcvbbs.UUCP Author: [Ted A Smith] Subj: Eigenvalue/Eigenvector decomposition Keyw: eigenvalues eigenvectors functions of a matrix Date: Wed Feb 06 1991 22:09 Lines: 28 Here is a quick and dirty eigenvalue/eigenvector decomposition for real symetric matricies. I used the Jacobi method. The termination test is a hack (I just test to see if the eigenvector matrix has changed in a given pass!) I don't have any idea if there is a possibility of non-termination. Eigen takes a real symetric matrix in level 1 and returns the matrix of eigenvectors in level 2 and the eigenvalues are along the diagonal of the matrix in level 1. (The offdiagonal values should be small in relation to the diagonal values.) EClr can be used to 0 the offdiagonal values. EFun takes a real symetric matrix (M) in level 2 and a function of 1 real arg (F) in level 1 and returns F(M) in level 1. For example in analogy with 'SIN(x)^2+COS(x)^2==1': [[ 1 2 3 ] [ 2 4 5 ] [ 3 5 6 ]] DUP \<< SIN \>> EFun DUP * OVER \<< COS \>> EFun DUP * + [[ .999999999981 9.89E-12 -1.881E-11 ] [ 1.188E-11 .999999999959 -3.3E-12 ] [ -1.801E-11 -2.3E-12 .999999999962 ]] ---------- Resp: 1 of 1 by _tasmith at hpcvbbs.UUCP Author: [Ted A Smith] Date: Wed Feb 06 1991 22:11 Lines: 1 ASCII downloadable eigenvalue decomposition routines Type attach to view and queue attached files.
akcs.briank@hpcvbbs.UUCP (Brian Korver) (04/30/91)
Ooops. Here are the files.
%%HP: T(3)A(D)F(.);
DIR
Eigen
\<< DUP IDN SWAP
DUP SIZE 1 GET \-> d
\<<
DO OVER
SWAP 1 d 1 -
FOR i i 1 + d
FOR j
DUP { j j } GET OVER { i i } GET -
OVER { i j } GET 3 PICK { j i } GET +
IF DUP
THEN
/
IF DUP
THEN
DUP SIGN SWAP ABS DUP SQ 1 + \v/ + /
ELSE
DROP 1
END
DUP SQ 1 + \v/ INV SWAP OVER * DUP NEG 4 PICK IDN
{ j i } ROT PUT { i j } ROT PUT { i i }
3 PICK PUT { j j } ROT PUT
ROT OVER * OVER TRN 4 ROLL * ROT *
ELSE
DROP2
END
NEXT
NEXT
UNTIL
ROT 3 PICK SAME
END 1 d
FOR i 1 d
FOR j
IF i j SAME NOT
THEN
{ i j } 0 PUT
END
NEXT
NEXT
\>>
\>>
EFun
\<< \-> f
\<< Eigen 1 OVER SIZE 1 GET
FOR i
{ i i } DUP2 GET f EVAL PUT
NEXT
OVER TRN * *
\>>
\>>
EClr
\<< DUP SIZE 1 GET \-> d
\<< 1 d
FOR i 1 d
FOR j
IF i j SAME NOT
THEN
{ i j } 0 PUT
END
NEXT
NEXT
\>>
\>>
END
Here is a quick and dirty eigenvalue/eigenvector decomposition for
real symetric matricies.
I used the Jacobi method.
The termination test is a hack (I just test to see if the
eigenvector matrix has changed in a given pass!) I don't
have any idea if there is a possibility of non-termination.
Eigen takes a real symetric matrix in level 1 and returns
the matrix of eigenvectors in level 2 and the eigenvalues
are along the diagonal of the matrix in level 1. (The
offdiagonal values should be small in relation to the
diagonal values.)
EClr can be used to 0 the offdiagonal values.
EFun takes a real symetric matrix (M) in level 2 and a function
of 1 real arg (F) in level 1 and returns F(M) in level 1.
For example in analogy with 'SIN(x)^2+COS(x)^2==1':
[[ 1 2 3 ] [ 2 4 5 ] [ 3 5 6 ]]
DUP \<< SIN \>> EFun DUP *
OVER \<< COS \>> EFun DUP * +
[[ .999999999981 9.89E-12 -1.881E-11 ]
[ 1.188E-11 .999999999959 -3.3E-12 ]
[ -1.801E-11 -2.3E-12 .999999999962 ]]