diff --git a/src/monomial.jl b/src/monomial.jl index ffa1365..a181c3d 100644 --- a/src/monomial.jl +++ b/src/monomial.jl @@ -64,6 +64,10 @@ function Base.getindex(basis::SubBasis{B,M}, value::Polynomial{B,M}) where {B,M} return mono end +function explicit_basis_covering(::FullBasis{B}, target::SubBasis{B}) where {B} + return SubBasis{B}(target.monomials) +end + const MonomialIndexedBasis{B,M} = Union{SubBasis{B,M},FullBasis{B,M}} MP.monomial_type(::Type{<:SubBasis{B,M}}) where {B,M} = M @@ -295,6 +299,14 @@ function explicit_basis_covering( return SubBasis{B}(target.monomials) end +# To break ambiguity +function explicit_basis_covering( + ::FullBasis{B}, + target::SubBasis{B}, +) where {B<:AbstractMonomial} + return SubBasis{B}(target.monomials) +end + function Base.adjoint(p::Polynomial{B}) where {B<:AbstractMonomialIndexed} return Polynomial{B}(adjoint(p.monomial)) end diff --git a/test/runtests.jl b/test/runtests.jl index c276f31..9c7f370 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -56,6 +56,10 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree) full_basis, MB.SubBasis{ScaledMonomial}(monomials(x, 0:degree)), ), + explicit_basis_covering( + full_basis, + MB.SubBasis{B}(monomials(x, 0:degree)), + ), ] _test_basis(basis) @test basis isa MB.explicit_basis_type(typeof(full_basis))