Skip to content

Commit

Permalink
Added BackslashSolver
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Sep 10, 2019
1 parent d9468c5 commit 8e3a9b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Algebra/LinearSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export numerical_setup
export numerical_setup!
export test_linear_solver
export LUSolver
export BackslashSolver

abstract type LinearSolver end

Expand Down Expand Up @@ -80,4 +81,26 @@ function solve!(
x .= y
end

"""
Wrapper of the backslash solver available in julia
This is typically faster than LU for a single solve
"""
struct BackslashSolver <: LinearSolver end

struct BackslashSymbolicSetup <: SymbolicSetup end

struct BackslashNumericalSetup <: NumericalSetup end

symbolic_setup(::BackslashSolver,mat::AbstractMatrix) = BackslashSymbolicSetup()

numerical_setup(::BackslashSymbolicSetup,mat::AbstractMatrix) = BackslashNumericalSetup()

function numerical_setup!(ns::BackslashNumericalSetup, mat::AbstractMatrix)
end

function solve!(
x::AbstractVector,ns::BackslashNumericalSetup,A::AbstractMatrix,b::AbstractVector)
copyto!(x, A\b)
end

end
9 changes: 9 additions & 0 deletions test/AlgebraTests/LinearSolversTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ b = A*x

test_linear_solver(ls,A,b,x)

n = 10
A = Laplacian(n,n,1,1)
x = rand(n^2)
b = A*x

ls = BackslashSolver()

test_linear_solver(ls,A,b,x)

end # module LinearSolversTests

0 comments on commit 8e3a9b7

Please sign in to comment.