-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unconjugated dot product dotu
#27677
base: master
Are you sure you want to change the base?
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). |
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
x
andy
as 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),dotu
is 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