Skip to content

Commit

Permalink
Test linear equation system with vector variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Oct 3, 2024
1 parent 9182a7d commit 11c335a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,17 @@ end
prob = @test_nowarn NonlinearProblem(sys, nothing)
@test_nowarn solve(prob)
end

@testset "System of linear equations with vector variable" begin
# 1st example in https://en.wikipedia.org/w/index.php?title=System_of_linear_equations&oldid=1247697953
@variables x[1:3]
A = [3 2 -1
2 -2 4
-1 1/2 -1]
b = [1, -2, 0]
@named sys = NonlinearSystem(A * x ~ b, [xs], [])
sys = structural_simplify(sys)
prob = NonlinearProblem(sys, unknowns(sys) .=> 0.0)
sol = solve(prob)
@test all(sol[x] .≈ A \ b)
end
1 change: 1 addition & 0 deletions test/reduction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ A = reshape(1:(N^2), N, N)
eqs = xs ~ A * xs
@named sys′ = NonlinearSystem(eqs, [xs], [])
sys = structural_simplify(sys′)
@test length(equations(sys)) == 3 && length(observed(sys)) == 2

# issue 958
@parameters k₁ k₂ k₋₁ E₀
Expand Down

0 comments on commit 11c335a

Please sign in to comment.