Spelling of sum(x*y for (x,y) in zip(xs, ys)), e.g. linear combinations

Is there a good canonical spelling for taking a linear combination, e.g.

combo(xs, ys) = sum(x*y for (x,y) in zip(xs, ys))
basis = [[1,0], [1,1]]
weights = [0.5, 0.5]

julia> combo(basis, weights)
2-element Array{Float64,1}:
 1.0
 0.5

It’s not a LinearAlgebra.dot-product, since that is supposed to return a scalar. It’s isomorphic to a matrix-vector product, yes, but what should the spelling of the operation on basis and weights be to avoid reshaping the basis elements into vectors?

I don’t know what a canonical spelling is, but this is what comes into my mind seeing the code:

julia> sum(basis.*weights)
2-element Array{Float64,1}:
 1.0
 0.5

is doing the same operation.
An element wise multiplication is called a

  • Hadamard product or
  • Schur product or
  • entrywise product

The sum operation doesn’t have a name except for the sum of the elements.

1 Like

Ah, I see, its not the same operation…
Now it is, edited above from sum.() to sum()

One solution (in the context that motivated my question) from @tkoolen:

https://github.com/JuliaRobotics/EnhancedGJK.jl/pull/16/files#diff-f82f70eb0ea9380dfa58b95933dd050eL99

It works on e.g. basis elements which are matrices.

julia> transpose([10, 20]) * [[1 0; 0 1], [0 1; 0 0]]
2×2 Array{Int64,2}:
 10  20
  0  10