Mercurial > matrix-functions
view mftoolbox/rootpm_sign.m @ 7:e0817ccb2834 draft
Add square root matrix function file, rename atom at funm_files, modify old toolbox to run it inside GNU Octave.
added funm_files/fun_atom.m
added sqrtm2.m
added toolbox/gecp.m
toolbox/see.m: comment wrong call to subplot
toolbox/tmtdemo.m: add a cast to double, as eig does not admit bool matrix input
removed funm_files/funm_atom.m
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Tue, 26 May 2015 18:14:54 +0200 |
parents | 8f23314345f4 |
children |
line wrap: on
line source
function X = rootpm_sign(A,p) %ROOTPM_SIGN Matrix Pth root via matrix sign function. % X = ROOTPM_SIGN(A,P) computes the principal Pth root X % of the matrix A using the matrix sign function and a block % companion matrix approach. if p == 1, X = A; return, end n = length(A); podd = rem(p,2); Y = A; if podd p = 2*p; % Compensate by squaring at end. else while mod(p,4) == 0 Y = sqrtm(Y); p = round(p/2); end end if p == 2 X = sqrtm(Y); return end % Form C, the block companion matrix. C = zeros(p*n); C(end-n+1:end, 1:n) = Y; C = C + diag(ones(n*(p-1),1),n); S = signm(C); X = S(n+1:2*n,1:n); % Scale factor. c = 0; for l = 1:floor(p/4) c = c+cos(2*pi*l/p); end c = c*4+2; c = c/p; X = X/c; if podd X = X*X; end