Skip to content

Commit 3ae8ad3

Browse files
authored
More substitution (#40)
1 parent 0cc7d89 commit 3ae8ad3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/arithmetic.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ function (p::_AE)(args::MP.AbstractSubstitution...)
9999
return MP.substitute(MP.Eval(), p, args...)
100100
end
101101

102+
function (p::_AE)(x::NTuple{N,<:Number}) where {N}
103+
return (MP.polynomial(p))(x)
104+
end
105+
106+
function (p::_AE)(x::AbstractVector{<:Number})
107+
return (MP.polynomial(p))(x)
108+
end
109+
110+
(p::_AE)(x::Number...) = (MP.polynomial(p))(x...)
111+
102112
function MP.differentiate(p::_AE, args...)
103113
return MP.differentiate(MP.polynomial(p), args...)
104114
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
102102
@test typeof(MB.algebra_element(sum(x))) ==
103103
MA.promote_operation(MB.algebra_element, typeof(sum(x)))
104104
@test const_alg_el(x => ones(length(x))) == const_mono
105+
@test const_alg_el(ones(length(x))) == const_mono
106+
@test const_alg_el(ones(length(x))...) == const_mono
107+
@test const_alg_el(tuple(ones(length(x))...)) == const_mono
105108
@test subs(const_alg_el, x => ones(length(x))) == const_mono
106109
@test differentiate(const_alg_el, x) == differentiate(const_mono, x)
107110
end

0 commit comments

Comments
 (0)