View gist:4c71f4a296fdcde552b0f6363e4ea1b4
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
(use-package hydra | |
:config | |
(global-set-key (kbd "C-x m") 'hydra-major/body) | |
(global-set-key (kbd "<f3>") 'hydra-bib-etc/body) | |
(global-set-key (kbd "C-<f3>") 'hydra-dired/body) | |
) | |
(defhydra hydra-major (:color blue :columns 4) | |
"major-mode" | |
("b" bibtex-mode "bibtex") |
View complex_step_example.m
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
% Complex step example. Requires Symbolic Math Toolbox. | |
format long | |
syms x; f = atan(x)/(1+exp(-x^2)) | |
% Derivative at $a = 2$: | |
a = 2; fd = double(subs( diff(f), a)) | |
% Convert symbolic function to MATLAB function. | |
f = matlabFunction(f); |
View complex_step.m
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 fd = complex_step(f,x,h) | |
%COMPLEX_STEP Complex step approximation to derivative. | |
% fd = COMPLEX_STEP(f,x,h) computes the complex step approximation | |
% fd to the derivative of f at x, using step h (default 1e-100). | |
if nargin < 3, h = 1e-100; end | |
fd = imag( f(x + sqrt(-1)*h) )/h; |
View ncm_compare.m
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
%NCM_COMPARE | |
% M-file to carry out experiment in "Explicit Solutions to Correlation | |
% Matrix Completion Problems, with an Application to Risk Management and | |
% Insurance" by Dan I. Georgescu, Nicholas J. Higham and Gareth W. Peters. | |
C = [% | |
1 0.25 0.6 0.55 0.65 0 0.4 0.6 0.2 0.3 | |
0.25 1 0 0 0 0 NaN NaN NaN NaN | |
0.6 0 1 0.75 0.75 0 NaN NaN NaN NaN | |
0.55 0 0.75 1 0.5 0 NaN NaN NaN NaN |
View edelman.m
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 A = edelman | |
%EDELMAN Alan Edelman's matrix for which det is computed as the wrong integer. | |
% A = EDELMAN is a 27-by-27 matrix of 1s and -1s for which the | |
% MATLAB det function returns an odd integer, though the exact | |
% determinant is an even integer. | |
A = [% | |
1 1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 | |
1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 | |
-1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 |
View rel_err_formula.m
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
%REL_ERR_FORMULA Compare two formulas for relative error. | |
n = 500; | |
a = 3; | |
x = a*ones(n,1,'single'); | |
y = zeros(size(x)); | |
d = eps(single(a)); | |
for i=1:n | |
i-n/2 |
View funm_randomized
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 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; |