Mercurial > forge
changeset 64:f6c423926e8c octave-forge
generalized eigenvalues
author | stahel |
---|---|
date | Fri, 30 Nov 2001 21:58:19 +0000 |
parents | d28a1d3cf299 |
children | 478988f52187 |
files | main/linear-algebra/eiggen.m |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/linear-algebra/eiggen.m Fri Nov 30 21:58:19 2001 +0000 @@ -0,0 +1,24 @@ +function [vec,val] = eiggen(A,B) +% function eiggen(A,B) +% find eigenvalues and vectors of a generalized problem, i.e. +% solve A*v=lambda*B*v for the eigenvalues lambda and eigenvectors v +% As a consequence we have A*vec=B*vec*diag(val) +% +% val = eiggen(A,B) returns the eigenvalues +% [vec,val] = eiggen(A,B) returns eigenvectors and eigenvalues +% +% A n*n Matrix +% B a symmetric positive definite n*n matrix +% val vector containing the n eigenvalues +% vec n*n matrix, the columns represent the eigenvectors + +% the algorithm uses the Cholesky decomposition B=R'*R and then +% computes the eigenvalues and vectors of inv(R')*A*inv(R) + +R=chol(B); +Ri=inv(R); +[vec,val]=eig(Ri'*A*Ri); +vec=Ri*vec; +val=diag(val); +if nargout<2 vec=val;endif +endfunction