Matrix Multiplication

I have 2 matrices that I need to multiply.

One is x by x, and the other is x by y.

I know it will need for loops but I can't figure it out.

they are stored as arrays:
a[x][x]
b[x][y]

Thanks everyone.
Do you know how to do it by hand?

Doing it by loops is exactly the same thing.

You'll need exactly three loops:
one for the rows of the resulting matrix,
one for the columns of the resulting matrix, and
one for the matrix Acolumns / matrix Brows.

Here are a couple of links to help you out:
http://en.wikipedia.org/wiki/Matrix_multiplication#Matrix_product (technical)
http://people.hofstra.edu/stefan_waner/realworld/tutorialsf1/frames3_2.html (tutorial)

Oh, BTW, your matrices need only share one dimension, such that they are stored as arrays:

A[m][p]
B[p][n]


Good luck!
Yes I do know how to do it by hand, and I know they only need share one dimension, but for they scope of my project, they will.

Thanks.

I was just confused as to how many loops I'd need, thanks a lot.

Its just tough getting the computer to do it sometimes. :)
Heh, heh, heh...

Programming the computer is just an exercise in programming your own mind.

Good programmers are the ones who learn how to translate what goes on in their head into making the computer do it...

:-)
Exactly, I got it to work, thank god.

It makes my brain hurt sometimes, but I love it.

I think its so cool that you can make the computer do exactly what you want it to.
Topic archived. No new replies allowed.