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
| using ForwardDiff, StaticArrays | |
| function jacobi(f, x) | |
| x_real = @SArray [real(x), imag(x)] | |
| function f_real(v) | |
| z = complex(v[1], v[2]) | |
| result = f(z) | |
| return @SArray [real(result), imag(result)] | |
| end | |
| J = ForwardDiff.jacobian(f_real, x_real) |
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
| using LinearAlgebra | |
| "Compute Givens rotation parameters to zero out b" | |
| function givens_rotation(a, b) | |
| T = promote_type(typeof(a), typeof(b)) | |
| if iszero(b) | |
| return one(T), zero(T) | |
| elseif abs(b) > abs(a) | |
| t = a / b | |
| s = 1 / sqrt(1 + t^2) |
OlderNewer