Skip to content

Commit

Permalink
Fixes for differentation and substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jul 5, 2024
1 parent 117bbd5 commit 4a4fa29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ end
function MP.substitute(
s::MP.AbstractSubstitutionType,
p::_AE,
args::MP.AbstractSubstitution...,
args::MP.Substitutions,
)
return MP.substitute(s, MP.polynomial(p), args...)
return MP.substitute(s, MP.polynomial(p), args)
end

function MP.subs(p::_AE, args::MP.AbstractSubstitution...)
return MP.substitute(MP.Subs(), p, args...)
return MP.substitute(MP.Subs(), p, args)
end

function (p::_AE)(args::MP.AbstractSubstitution...)
return MP.substitute(MP.Eval(), p, args...)
return MP.substitute(MP.Eval(), p, args)
end

function (p::_AE)(x::NTuple{N,<:Number}) where {N}
Expand All @@ -109,6 +109,6 @@ end

(p::_AE)(x::Number...) = (MP.polynomial(p))(x...)

function MP.differentiate(p::_AE, args...)
return MP.differentiate(MP.polynomial(p), args...)
function MP.differentiate(p::_AE, x)
return MP.differentiate(MP.polynomial(p), x)
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
@test const_alg_el(ones(length(x))...) == const_mono
@test const_alg_el(tuple(ones(length(x))...)) == const_mono
@test subs(const_alg_el, x => ones(length(x))) == const_mono
@test const_alg_el(x[1] => x[2], x[2] => x[1]) == const_mono
@test differentiate(const_alg_el, x) == differentiate(const_mono, x)
@test differentiate(const_alg_el, x, 2) == differentiate(const_mono, x, 2)
end

function univ_orthogonal_test(
Expand Down

0 comments on commit 4a4fa29

Please sign in to comment.