Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 27, 2023
1 parent 9fbc583 commit 718557e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
group: 'LinearSolveHYPRE'
- version: '1'
group: 'LinearSolvePardiso'
- version: '1'
group: 'LinearSolveBandedMatrices'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "IterativeSolvers", "InteractiveUtils", "JET", "KrylovKit", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "Enzyme", "FiniteDiff"]
test = ["Test", "IterativeSolvers", "InteractiveUtils", "JET", "KrylovKit", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "Enzyme", "FiniteDiff", "BandedMatrices"]
38 changes: 38 additions & 0 deletions test/banded.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using BandedMatrices, LinearAlgebra, LinearSolve, Test

# Square Case
n = 8
A = BandedMatrix(Matrix(I, n, n), (2, 2))
b = ones(n)
A1 = A / 1;
b1 = rand(n);
x1 = zero(b);
A2 = A / 2;
b2 = rand(n);
x2 = zero(b);

sol1 = solve(LinearProblem(A1, b1; u0 = x1))
@test sol1.u A1 \ b1
sol2 = solve(LinearProblem(A2, b2; u0 = x2))
@test sol2.u A2 \ b2

# Square Symmetric
A1s = Symmetric(A1)
A2s = Symmetric(A2)

sol1s = solve(LinearProblem(A1s, b1; u0 = x1))
@test sol1s.u A1s \ b1
sol2s = solve(LinearProblem(A2s, b2; u0 = x2))
@test sol2s.u A2s \ b2

# Underdetermined
A = BandedMatrix(rand(8, 10), (2, 2))
b = rand(8)

@test_throws ErrorException solve(LinearProblem(A, b)).u

# Overdetermined
A = BandedMatrix(ones(10, 8), (2, 0))
b = rand(10)

@test_nowarn solve(LinearProblem(A, b))
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if GROUP == "All" || GROUP == "Core"
@time @safetestset "Default Alg Tests" include("default_algs.jl")
VERSION >= v"1.9" && @time @safetestset "Enzyme Derivative Rules" include("enzyme.jl")
@time @safetestset "Traits" include("traits.jl")
VERSION >= v"1.9" && @time @safetestset "BandedMatrices" include("banded.jl")
end

if GROUP == "LinearSolveCUDA"
Expand Down

0 comments on commit 718557e

Please sign in to comment.