See JuliaLang/julia issue #31105.
Last active
February 19, 2019 23:23
-
-
Save briochemc/b9233abf00b5c879eee2d6631a19c710 to your computer and use it in GitHub Desktop.
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
using LinearAlgebra, SparseArrays, SuiteSparse, BenchmarkTools, MAT | |
M = matread("test_matrix.mat")["M"] ; | |
x = matread("test_matrix.mat")["x"] ; | |
Mf = factorize(M) ; | |
@btime Mf = factorize(M) ; | |
@btime M \ x ; | |
@btime Mf \ x ; | |
@btime Mf \ [x 2x 3x 4x] ; |
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
n = 20000; | |
M = sprand(n, n, 20/n) + speye(n); | |
x = rand(n, 1); | |
tic; Mf = linfactor(M); toc; | |
tic; M \ x; toc; | |
tic; linfactor(Mf, x); toc; | |
tic; linfactor(Mf, [x 2*x 3*x 4*x]); toc; | |
save test_matrix.mat M x | |
# Error check | |
sol = linfactor(Mf, x) ; | |
norm(x) | |
norm(x - M * sol) / norm(x) | |
norm(x - M * sol) |
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
# Error check | |
using LinearAlgebra, SparseArrays, SuiteSparse, BenchmarkTools, MAT | |
M = matread("test_matrix.mat")["M"] ; | |
x = matread("test_matrix.mat")["x"] ; | |
Mf = factorize(M) ; | |
sol1 = Mf \ x ; | |
sol2 = M \ x ; | |
norm(x) | |
norm(x - M * sol1) / norm(x) | |
norm(x - M * sol1) | |
norm(x - M * sol2) / norm(x) | |
norm(x - M * sol2) |
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
load test_matrix.mat M x | |
Mf = linfactor(M) ; | |
sol1 = linfactor(Mf, x) ; | |
sol2 = M \ x ; | |
norm(x) | |
norm(x - M * sol1) / norm(x) | |
norm(x - M * sol1) | |
norm(x - M * sol2) / norm(x) | |
norm(x - M * sol2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment