Skip to content

Commit 83c72e2

Browse files
authored
Add operate_to! with polynomial (#45)
* Add operate_to! with APL * Add tests * Fix format
1 parent a3888b3 commit 83c72e2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/arithmetic.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ function MA.operate!(op::Union{typeof(+),typeof(-),typeof(*)}, p::_APL, q::_AE)
8080
return MA.operate!(op, p, MP.polynomial(q))
8181
end
8282

83+
function MA.operate_to!(
84+
res::MP.AbstractPolynomial,
85+
op::typeof(*),
86+
p::_AE,
87+
q::_APL,
88+
)
89+
return MA.operate_to!(res, op, MP.polynomial(p), q)
90+
end
91+
92+
function MA.operate_to!(
93+
res::MP.AbstractPolynomial,
94+
op::typeof(*),
95+
p::_APL,
96+
q::_AE,
97+
)
98+
return MA.operate_to!(res, op, p, MP.polynomial(q))
99+
end
100+
83101
# These are not implemented yet for arbitrary bases so we
84102
# fall back to polynomials
85103

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
116116
@test const_alg_el(x[1] => x[2], x[2] => x[1]) == const_mono
117117
@test differentiate(const_alg_el, x) == differentiate(const_mono, x)
118118
@test differentiate(const_alg_el, x, 2) == differentiate(const_mono, x, 2)
119+
@test MA.operate_to!(polynomial(const_mono), *, const_alg_el, const_mono) ==
120+
const_mono
121+
@test MA.operate_to!(polynomial(const_mono), *, const_mono, const_alg_el) ==
122+
const_mono
123+
@test dot([const_alg_el], [const_mono]) == const_mono
124+
@test dot([const_mono], [const_alg_el]) == const_mono
119125
end
120126

121127
function univ_orthogonal_test(

0 commit comments

Comments
 (0)