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

inconsistent behaviour of * and \ for non-square matrices: #85

Closed
Jutho opened this issue Feb 25, 2014 · 5 comments
Closed

inconsistent behaviour of * and \ for non-square matrices: #85

Jutho opened this issue Feb 25, 2014 · 5 comments

Comments

@Jutho
Copy link
Contributor

Jutho commented Feb 25, 2014

I did not want to add this issue to the Number/Matrix issue, as it is of a different nature and might get lost in the long discussion going on over there.

Consider the following:
vec=rand(10)
mat=reshape(vec,(10,1))

None of this should work: vec * vec, mat_mat, vec_mat mat_vec
(at least not from an algebraic point of view, I am not so familiar with the broadcasting rules but in relation to the other discussion I would favour to explicitly require the use of ._ for broadcasting)
The first (vector vector multiplication) gives a no method error
The second (matrix matrix multiplication) gives a dimension mismatch error
The third (vector matrix multiplication) gives a dimension mismatch
The fourth, however, computes something. It took me a second before realising what was computed exactly, but it seems to be mat * vec[1]. I don't think this falls under the scope of broadcasting.

Even knowing that A\B is generalised to non-square matrices A if B has the same number of columns as A (in the least square sense), the following should still not exist: vec' \ vec and vec \ vec'
Yet, vec' \ vec = vec' \ mat produces a vector of length 10
(I do not immediately see what is calculated)
vec \ vec' = mat \ vec' produces:
** On entry to DORMQR parameter number 10 had an illegal value
ERROR: ArgumentError("invalid argument JuliaLang/julia#10 to LAPACK call")

@JHonaker
Copy link

JHonaker commented Mar 1, 2014

This is interesting. I think this problems stems from a difference between a 10-element array and a 10x1 array. After a short testing session, it seems if you use mat*vec'' (which casts vec as a 10x1 array instead of a 10-element array), you get a dimension mismatch error. I'm fairly new to Julia, but what exactly is the different between a 10-element and a 10x1 array? Conceptually nothing, but what files should I/we be investigating for this?

@andreasnoack
Copy link
Member

I missed this issue, but I have submitted a fix in #85.

@JohnnyAppleDev The easiest way to find the relevant place in the source is to put the macro @which before the function call, e.g. @which mat*vec

@andreasnoack
Copy link
Member

Fixed by #85

@JHonaker
Copy link

JHonaker commented Mar 1, 2014

@andreasnoackjensen Thanks for the tip and the fix.

@Jutho
Copy link
Contributor Author

Jutho commented Mar 2, 2014

Thanks indeed

@KristofferC KristofferC transferred this issue from JuliaLang/julia Nov 26, 2024
This issue was closed.
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

3 participants