Archived

This topic is now archived and is closed to further replies.

Matrices: Multiplication.

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm learning about matrix multiplication as follows. To multiply matrices, the number of columns (the up and down things) in the first matrix need to be equal to the number of rows (the left and right things) in the second matrix. Is this true? If this is true, doesn't this mean that the first matrix always has to be "smaller" (dimension wise) than the second one? (2x2 matrix)x(2x3 matrix) is possible. (3x2 matrix)x(2x3 matrix) is not possible? EDIT: Also, the above (2nd) example means that matrix multiplication is not commutative. But I read that matrix multiplication is associative. How is this possbile?
Charles Hwang -aka Tazel [MonkeyHumor My Site|E-mail|NeXe|NeHe|SDL] [Google|Dev-C++|GDArticles|C++.com|MSDN] [edited by - charles hwang on November 29, 2003 4:27:56 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Charles Hwang
(3x2 matrix)x(2x3 matrix) is not possible?

Why would it not be possible? The number of columns of the first matrix is the same as the number of rows of the second.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes, in general we have that

(axb)(bxc) = (axc)

And from that it follows

((axb)(bxc)) (cxd) = (axc) (cxd) = (axd)
(axb) ((bxc)(cxd)) = (axb) (bxd) = (axd)

So, at least dimensionwise multiplication is associative.

Share this post


Link to post
Share on other sites
I thought that it was the rows of the first matrix need to be equal to the columns of the second matrix, and the resulting matrix will have the number of rows of the first matrix and the number of columns of the second matrix.

I haven''t used matrices in quite a while, not since 10th grade (I don''t even use them in game programming very often to be honest).

Share this post


Link to post
Share on other sites
Jx: Column major or row major is just how they are laid out in computer memory, it does not affect how they are multiplied.

To you multiply a (a x b) matrix with a (c x d) matrix, b must be equal to c, and the result will be a (a x d) matrix.

Share this post


Link to post
Share on other sites
I was right about the resulting matrix having the number of rows of the first matrix and the number of columns from the second matrix, and you were right about the fact that in order for the multiplication to be possible the number of columns from the first matrix must be equal to the number of rows of the second matix.

whew

Share this post


Link to post
Share on other sites
    /a11  a12\   
A = |a21 a22|
\a31 a32/

B = /b11 b12 b13\
\b21 b22 b23/

/(a11b11 + a12b21) (a11b12 + a12b22) (a11b13 + a12b23)\
C = A * B = |(a21b11 + a22b21) (a21b12 + a22b22) (a21b13 + a22b23)|
\(a31b11 + a32b21) (a31b12 + a32b22) (a31b13 + a32b23)/


[edited by - Useless Hacker on November 29, 2003 5:44:14 PM]

Share this post


Link to post
Share on other sites
This is kinda of an extreme here but so, according to everything in this thread, the following matrix multiplication is possible?

(Assume x,y,z and a,b,c,d,e,f are all different real numbers)

[x y z]
[x y z]
[x y z] [a b c d e f]
[x y z] x [a b c d e f]
[x y z] [a b c d e f]
[x y z]
[x y z]

7x3 3x6
|___are equal__|

And the resulting matrix would be a 7x6 matrix?


Charles Hwang -aka Tazel
[MonkeyHumor My Site|E-mail|NeXe|NeHe|SDL]
[Google|Dev-C++|GDArticles|C++.com|MSDN]


[edited by - charles hwang on November 29, 2003 6:43:03 PM]

Share this post


Link to post
Share on other sites