% code for generalized eigenvalues mu and eigenvectors V for the matrix % pair A^*A, B^*B. [V,D] = eig(B'*B); D = diag(D); i = find(D > 1e-14*max(D)); V = V(:,i) .* repmat(1./sqrt(D(i)).', [size(B,2) 1]); F = V'*A'*A*V; [W mu] = eig((F+F')/2); % projects out numerical Nul(B) mu = diag(mu); V = V*W;