Skip to content

Instantly share code, notes, and snippets.

@kgourgou
Forked from higham/funm_randomized
Created April 20, 2017 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgourgou/13e076f5f0d59696670436464fba0e9e to your computer and use it in GitHub Desktop.
Save kgourgou/13e076f5f0d59696670436464fba0e9e to your computer and use it in GitHub Desktop.
function F = funm_randomized(A,fun)
%FUNM_RANDOMIZED Evaluate general matrix function using
% randomized approximate diagonalization method of Davies (2007).
tol = 8*eps(A(1,1)); % Tolerance for single or double precision A.
E = randn(size(A));
[V,D] = eig(A + (tol*norm(A,'fro')/norm(E,'fro'))*E);
F = V*diag(fun(diag(D)))/V;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment