-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
dot(x::Adjoint, y::AbstractVector) gives inconsistent answer #641
Comments
If this is the way to go, then it should be the same for transpose? LinearAlgebra.dot(x::Transpose{<:Any,<:AbstractVector}, y::AbstractVector) = parent(x)*y |
But also I'm not sure that this is the way to go... I think we currently have (roughly) Although it does mean all inputs are treated as vectors e.g. julia> A = [1 2; 3 4];
julia> b = [1 2 3 4];
julia> dot(A, b)
29 |
Rather than special casing |
The current design seems to date from: JuliaLang/julia#27401, and there was a later comment about adjoint there which seems like it might be the same thing JuliaLang/julia#27401 (comment). |
I don't follow this sorry, In any case, I guess its true, as the docs for |
Ah, interesting point! I hadn't considered that the LinearAlgebra wrapper types could/should act differently than an array with the same dimensionality (e.g. an |
See #549 and JuliaLang/julia#28666 |
Sure, move on, nothing to see there ;-) (I just misread your definition.) |
Thanks @fredrikekre, yea, looks like if JuliaLang/julia#28666 is merged that would cause |
I wanted to get some feedback before maybe submitting a simple PR. I was quite surprised that
dot
of anAdjoint
and aVector
gives the same answer as if I had never done the adjoint:I haven't been able to find any discussion explicitly about this, having gone through the many threads about adjoints. Mathematically I think it doesn't make sense and breaks some of the nice mathematical consistency of the existing system. My guess is that its just an unintended consequence of how generic this function is:
https://github.com/JuliaLang/julia/blob/f6049d6d25d720bc90d82aadae6be98bc948ef24/stdlib/LinearAlgebra/src/generic.jl#L785
I would propose special-casing the dot product with the following definition:
which means that
dot(adjoint(v),v)
would be equivalent tov*v
, which for Base vectors is undefined (although users would be free to define this operations for their own customAbstractVectors
, and I believe everything remains consistent in that case).Let me know if there's any comments on this and if I should go ahead and make the PR.
The text was updated successfully, but these errors were encountered: