Skip to content
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

Vector-Matrix product again #18136

Closed
goszlanyi opened this issue Aug 19, 2016 · 2 comments
Closed

Vector-Matrix product again #18136

goszlanyi opened this issue Aug 19, 2016 · 2 comments

Comments

@goszlanyi
Copy link

goszlanyi commented Aug 19, 2016

While waiting for JuliaLang/LinearAlgebra.jl#360 , I have found a suspicious method.

line 92 of matmul.jl is:
(*)(A::AbstractVector, B::AbstractMatrix) = reshape(A,length(A),1)*B

I think that this line is the reason why v*mx multiplication does not work at all.
The error message is the following:

julia> ones(3)*ones(3,3)
ERROR: DimensionMismatch("A has dimensions (3,1) but B has dimensions (3,3)")
 in gemm_wrapper!(::Array{Float64,2}, ::Char, ::Char, ::Array{Float64,2}, ::Array{Float64,2}) at .\linalg\matmul.jl:308
 in *(::Array{Float64,1}, ::Array{Float64,2}) at .\linalg\matmul.jl:86

If I redefine the method of line 92 in my workspace as:

import Base.*
(*)(A::AbstractVector, B::AbstractMatrix) = reshape(A,1,length(A))*B

then v*mx works and returns a 1xn matrix.

@andreasnoack @StefanKarpinski
Note, that this is not the same issue as JuliaLang/LinearAlgebra.jl#360.
Here I report something that should already work,
while there I would like the result to be a real 1-dimensional vector.

@andreasnoack
Copy link
Member

This is the method that lets you compute x*x'. As mentioned the vector discussion is JuliaLang/LinearAlgebra.jl#42 so I'll close here.

@goszlanyi
Copy link
Author

goszlanyi commented Aug 19, 2016

This is the method that lets you compute x*x'.

Thank you. Then this is even more serious than I have originally thought.
Based on the (*)(A::AbstractVector, B::AbstractMatrix) signature
we can only have a single method, which is only good for either v*v' or v*mx.

The second usage is perfectly valid mathematics,
but only if it also returns a 1-dimensional vector.

I will try to summarize, and as you have suggested, move it to JuliaLang/LinearAlgebra.jl#42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants