Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
manopt/manopt/tools/lyapunov_symmetric_eig.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (32 sloc)
1.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function X = lyapunov_symmetric_eig(V, lambda, C, tol) | |
% Solves AX + XA = C when A = A', as a pseudo-inverse, given eig(A). | |
% | |
% function X = lyapunov_symmetric_eig(V, lambda, C) | |
% function X = lyapunov_symmetric_eig(V, lambda, C, tol) | |
% | |
% Same as lyapunov_symmetric(A, C, [tol]), where A is symmetric, its | |
% eigenvalue decomposition [V, lambda] = eig(A, 'vector') is provided as | |
% input directly, and C is a single matrix of the same size as A. | |
% | |
% See also: lyapunov_symmetric sylvester lyap sylvester_nocheck | |
% This file is part of Manopt: www.manopt.org. | |
% Original author: Nicolas Boumal, Aug. 31, 2018. | |
% Contributors: | |
% Change log: | |
% AX + XA = C is equivalent to DY + YD = M with | |
% Y = V'XV, M = V'CV and D = diag(lambda). | |
M = V'*C*V; | |
% W(i, j) = lambda(i) + lambda(j) | |
W = bsxfun(@plus, lambda, lambda'); | |
% Normally, the solution Y is simply this: | |
Y = M ./ W; | |
% But this may involve divisions by (almost) 0 in certain places. | |
% Thus, we go for a pseudo-inverse. | |
absW = abs(W); | |
if ~exist('tol', 'var') || isempty(tol) | |
tol = numel(C)*eps(max(absW(:))); % similar to pinv tolerance | |
end | |
Y(absW <= tol) = 0; | |
% Undo the change of variable | |
X = V*Y*V'; | |
end |