-
-
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
row-vector/column-vector products should act like dot products #2936
Comments
This has been discussed a few times, I think. At least in #2472. Actually |
At the very least, a column-vector of length 1 should act like a 1×1 matrix for multiplication purposes. e.g. |
I think that it might make sense to demote a length one vector to a scalar |
This works now, right? |
Yes: julia> x = rand(3)
3-element Array{Float64,1}:
0.61878
0.178213
0.0933086
julia> y = rand(3)
3-element Array{Float64,1}:
0.954149
0.0926293
0.336523
julia> (x*x')*y
3-element Array{Float64,1}:
0.394978
0.113756
0.0595605
julia> x*(x'*y)
3-element Array{Float64,1}:
0.394978
0.113756
0.0595605 |
If
x
andy
are vectors of the same length, then(x*x')*y
works butx*(x'*y)
does not (it givesERROR: no method *(Array{Float64,1},Array{Float64,1})
). The latter can only be accomplished withx*dot(x,y)
.This is surprising and, I think, undesirable:
*
should be associative (neglecting floating-point roundoff errors, of course).Another way of putting it is that
x'*y
, or any product of a row vector and a column vector, should return a scalar, not a vector of length 1. (And it should probably just call the BLASdot
.)The text was updated successfully, but these errors were encountered: