Add unconjugated dot product dotu#27677
Conversation
|
Sorry to play the devil's advocate, but is this really useful? The cases where it's needed it's not really a dot product (ie in your example, n and σ belong to different spaces), nor even a duality pairing, but simply a sum of containers. Also when reading (much more useful as complex numbers are concerned, and trickier to implement efficiently - especially now that |
|
Conceptually and computationally, |
Thanks for your comments! I've chosen the name Another possibility might be to have a function |
|
My thoughts: I think BLAS is generally really bad at naming operations clearly, so I wouldn’t look there for inspiration ;) I don’t quite think of this as a kind of inner product and it seems we’ve recently settled on Also, given the operation is basically a As an aside, it would be great if |
|
Thanks for your comments. I've opened this PR to provide an opportunity to discuss such a function - sometimes it is easier to discuss some existing implementation and possible extensions/variations. Due to some comments in JuliaLang/LinearAlgebra.jl#496 and #8300, there might be some interest in a function such as
|
That would be lovely! 👍 |
|
I came across this issue yesterday in the context of JuliaStats/StatsBase.jl#534 and JuliaStats/StatsBase.jl#518. The problem there is that for things like a weighted sum, the recursion in |
|
@StefanKarpinski Now that |
I would argue against that - currently, mapreduce enjoys the benefit of increased precision due to pairwise summation. After all that went into that (#199, #4039, ...) it would be sad to give that up again. There's also not necessarily a performance benefit - if one has to use 64-bit instead of 32-bit floats to make the sum stable, one may lose more performance than gained (depending on the application). |
|
We have moved the LinearAlgebra stdlib to an external repo: https://github.com/JuliaLang/LinearAlgebra.jl @ranocha If you think that this PR is still relevant, please open a new PR on the LinearAlgebra.jl repo. |
This came up in JuliaLang/LinearAlgebra.jl#496 and #8300. Sometimes, it is useful to have an unconjugated dot product, computing the sum of the elementwise product of two vectors
xandyas indotu(x, y) = sum(x .* y). As suggested in #27401 (comment), I've added this function in a new PR.Contrary to
dot(cf. #27401),dotuis not defined recursively. Thus, the unconjugated dot product of a vector of matrices and a vector of scalars can be computed, which is often used for Pauli matrices as in