Skip to content

Commit

Permalink
More substitution (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Jul 3, 2024
1 parent 0cc7d89 commit 3ae8ad3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ function (p::_AE)(args::MP.AbstractSubstitution...)
return MP.substitute(MP.Eval(), p, args...)
end

function (p::_AE)(x::NTuple{N,<:Number}) where {N}
return (MP.polynomial(p))(x)
end

function (p::_AE)(x::AbstractVector{<:Number})
return (MP.polynomial(p))(x)
end

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

function MP.differentiate(p::_AE, args...)
return MP.differentiate(MP.polynomial(p), args...)
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
@test typeof(MB.algebra_element(sum(x))) ==
MA.promote_operation(MB.algebra_element, typeof(sum(x)))
@test const_alg_el(x => ones(length(x))) == const_mono
@test const_alg_el(ones(length(x))) == const_mono
@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 differentiate(const_alg_el, x) == differentiate(const_mono, x)
end
Expand Down

0 comments on commit 3ae8ad3

Please sign in to comment.