Skip to content

Commit

Permalink
fixup! feat: support array variables in linear_expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Oct 23, 2024
1 parent a1bdba1 commit 7394ab2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/linear_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ a, b, islinear = Symbolics.linear_expansion(D(x) - x, x)

@testset "linear_expansion with array variables" begin
@variables x[1:2] y[1:2] z(..)
@test !linear_expansion(z(x) + x[1], x[1])[3]
@test !linear_expansion(z(x[1]) + x[1], x[1])[3]
a, b, islin = linear_expansion(z(x[2]) + x[1], x[1])
@test !Symbolics.linear_expansion(z(x) + x[1], x[1])[3]
@test !Symbolics.linear_expansion(z(x[1]) + x[1], x[1])[3]
a, b, islin = Symbolics.linear_expansion(z(x[2]) + x[1], x[1])
@test islin && isequal(a, 1) && isequal(b, z(x[2]))
a, b, islin = linear_expansion((x + x)[1], x[1])
a, b, islin = Symbolics.linear_expansion((x + x)[1], x[1])
@test islin && isequal(a, 2) && isequal(b, 0)
a, b, islin = linear_expansion(y[1], x[1])
a, b, islin = Symbolics.linear_expansion(y[1], x[1])
@test islin && isequal(a, 0) && isequal(b, y[1])
@test !linear_expansion(z([x...]), x[1])[3]
@test !linear_expansion(z(collect(unwrap(x))), x[1])[3]
@test !linear_expansion(z([x, 2x]), x[1])[3]
@test !Symbolics.linear_expansion(z([x...]), x[1])[3]
@test !Symbolics.linear_expansion(z(collect(unwrap(x))), x[1])[3]
@test !Symbolics.linear_expansion(z([x, 2x]), x[1])[3]
end

0 comments on commit 7394ab2

Please sign in to comment.