From 3ae8ad35d1c682ddc1bcbc7980df8ef33be768e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 3 Jul 2024 16:03:44 +0200 Subject: [PATCH] More substitution (#40) --- src/arithmetic.jl | 10 ++++++++++ test/runtests.jl | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/arithmetic.jl b/src/arithmetic.jl index e806d82..46e7134 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 763c2c0..067c35f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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