diff --git a/Project.toml b/Project.toml index 0c8be85..0b35af3 100644 --- a/Project.toml +++ b/Project.toml @@ -9,6 +9,9 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [compat] julia = "1" +[extensions] +VectorInterfaceMultivariatePolynomialsExt = "MultivariatePolynomials" + [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -16,3 +19,6 @@ TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a" [targets] test = ["Test", "TestExtras", "Aqua"] + +[weakdeps] +MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3" \ No newline at end of file diff --git a/ext/VectorInterfaceMultivariatePolynomialsExt.jl b/ext/VectorInterfaceMultivariatePolynomialsExt.jl new file mode 100644 index 0000000..a5b6156 --- /dev/null +++ b/ext/VectorInterfaceMultivariatePolynomialsExt.jl @@ -0,0 +1,18 @@ +module VectorInterfaceMultivariatePolynomialsExt + +import VectorInterface +using MultivariatePolynomials + +# union of all abstract types that can be crudely supported? +const PolyTypes = Union{<:AbstractPolynomialLike, <:AbstractTermLike, <:AbstractMonomialLike} + +# not clear if this is really the true `scalartype` we want +VectorInterface.scalartype(T::Type{<:PolyTypes}) = T + +function VectorInterface.add!!(w::PolyTypes, v::PolyTypes, α::Number, β::Number) + return w * β + v * α +end + +VectorInterface.scale!!(v::PolyTypes, α::Number) = v * α + +end \ No newline at end of file