-
-
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 vecdot, in analogy with vecnorm #11067
Conversation
d02fb58
to
9acf3d9
Compare
+1 We made |
I think that for the dot product of eg two matrices, I would really like a function that checks that the dimensions match also. That should also allow a more efficient implementation for matrices without fast linear indexing. Should that be a different function though? |
@toivoh Note that for e.g. |
Iterating over any abstract array already uses the most efficient form of indexing available by default. For Is there any overhead involved in asking: applicable(length, x) && applicable(length, y) && assert(length(x) == length(y)) ? |
Hmm, while we get julia> a = 0x00:0xff
0x00:0xff
julia> sum(a)
32640 we have julia> dot(a,a)
0x80 Since a dot product is a reduction, it would be nice to include the same widening we use for our reductions. |
If I understood the discussion in this PR and the related Issue correctly, then care was taken not to allow |
I think that is a good idea. |
As discussed in #11064, if we have a
vecnorm
function (computing the Euclidean norm of any iterable container, equivalent tonorm(vec(x))
), we should really also have avecdot
(computing the Euclidean dot product of any iterable container, equivalent todot(vec(x),vec(y))
).(If, as @jiahao argued in #7990, we renamed
vecnorm
tonormfro
, then for consistency we should usedotfro
here. I don't care too much either way as long as we are consistent, but I would point out that if you're worried about the inherent ambiguity of the terms "norm" and "dot product", that would argue against havingnorm
anddot
functions at all.)