Skip to content

Commit 76f3c9e

Browse files
authored
Add LinearAlgebra.dot(Vector{Poly}, Vector{Poly}) (#425)
See issue #424
1 parent 2e7f123 commit 76f3c9e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/polynomials/standard-basis.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ function ⊗(P::Type{<:StandardBasisPolynomial}, p::Dict{Int,T}, q::Dict{Int,S})
143143
c
144144
end
145145

146+
## Define a dot product on vectors of polynomials, where polynomials are treated as
147+
## as the scalar types -- the dot is the sum of pairwise products. Might change in
148+
## the future if this causes confusion with the "vector" interpretation of polys.
149+
LinearAlgebra.dot(xv::AbstractArray{T}, yv::AbstractArray{T}) where {T <: StandardBasisPolynomial} = sum(conj(x)*y for (x,y) = zip(xv, yv))
150+
146151
## ---
147152
function fromroots(P::Type{<:StandardBasisPolynomial}, r::AbstractVector{T}; var::SymbolLike = Var(:x)) where {T <: Number}
148153
n = length(r)

0 commit comments

Comments
 (0)