Skip to content

Instantly share code, notes, and snippets.

@briochemc
Created February 15, 2019 05:51
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 briochemc/5d3a046613428528be10307df04fb947 to your computer and use it in GitHub Desktop.
Save briochemc/5d3a046613428528be10307df04fb947 to your computer and use it in GitHub Desktop.
Benchmarking backslash in Julia with Float64, ComplexF64, and Dual128 (via DualMatrixTools.jl)
using LinearAlgebra, SparseArrays, SuiteSparse
using DualNumbers, DualMatrixTools
using BenchmarkTools
n = 1000 ;
y = rand(n) ;
A = sprand(n, n, 20/n) ;
i, j, v = findnz(A) ;
v2 = rand(length(v)) ;
complex_A = sparse(i, j, v .+ im .* v2 .* 1e-50) ;
dual_A = sparse(i, j, v .+ ε .* v2) ;
Af = factorize(A) ;
complex_Af = factorize(complex_A) ;
dual_Af = factorize(dual_A) ;
# factorization benchmark
@btime $A \ $y ;
@btime factorize($A) ;
@btime $Af \ $y ;
# complex version
@btime $complex_A \ $y ;
@btime factorize($complex_A) ;
@btime $complex_Af \ $y ;
# dual version
@btime $dual_A \ $y ;
@btime factorize($dual_A) ;
@btime $dual_Af \ $y ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment