Last active
July 18, 2016 14:27
-
-
Save gramian/66fdf1a68ca51893d81f2c1da4a4ff4f to your computer and use it in GitHub Desktop.
Approximate matrix inverse of quadratic complexity ( A⁻¹ ≈ D⁻¹ - D⁻¹ E D⁻¹ )
This file contains hidden or 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 = ainv(m) | |
% ainv - approximate inverse | |
% by Christian Himpe 2016 | |
% released under BSD 2-Clause License ( opensource.org/licenses/BSD-2-Clause ) | |
d = diag(m); | |
d(d~=0) = 1.0./d(d~=0); | |
n = numel(d); | |
x = bsxfun(@times,m,-d); | |
x = bsxfun(@times,x,d'); | |
x(1:n+1:end) = d; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment