% Function to calculate the dominant eigenvalue and eigenvectors.
%
% Input:
%    A = the projection matrix (n by n matrix)
%
% Output:
%    lambda = dominant eigenvalue (scalar)
%    w = dominant right eigenvector (n by 1 vector)
%    v = dominant left eigenvector (n by 1 vector)
%

function [lambda, w, v] = domeig(A)

[W,d] = eig(A);
d = diag(d);
imax = find(d==max(d));
lambda = d(imax); % dominant eigenvalue
w = W(:,imax); % right eigenvector
V = conj(inv(W));
v = real(V(imax,:)).'; % left eigenvector

end