I have a question concerning multiplying twodimensional arrays having different dimensions. Lets say you have the two following matrices:
int[][] matrix1 = new int[6][4];
 int[][] matrix2 = new int[4][5];

 They would look like below:

 matrix 1:
 0 1 2 3
 0
 1
 2
 3
 4
 5


 matrix 2
 0 1 2 3 4
 0
 1
 2
 3
I understand that the number of columns in matrix one must match the number of rows in matrix 2 in order to multiply them. My question is on matrix one when you get to row 4 you won't have matches in matrix 2 and when you get to column 5 in matrix 2 you won't have matches in matrix 1. How do you multiply them when there are not matches? Does it take zero and multiply it by the match? I'm so confused, all my instructors says is that columns must match rows and I can't find the answer so I don't know how to begin to try to do the code. So right now all I would like to know is how does the multiplication work when the dimensions are different in the 2 arrays that are being multiplied. Any help that can be given will be greatly appreciated.
Thanks,
Dorothy
4 Replies  7451 Views  Last Post: 14 March 2008  09:48 PM
#1
Another question about multiplying twodimensional arrays(matrices)
Posted 13 March 2008  07:42 PM
Replies To: Another question about multiplying twodimensional arrays(matrices)
#2
Re: Another question about multiplying twodimensional arrays(matrices)
Posted 13 March 2008  08:38 PM
You have to store the values of the product of 2 Matrices into another matrix. So if you understand matrix multiplication on paper, I think you will have less trouble programming it.
You might be already familiar with this link >
http://en.wikipedia...._multiplication
For starters you could perform a product of 2x2 Matrices; and then understand from there on.
Hope this helps. More questions? Keep posting!
You might be already familiar with this link >
http://en.wikipedia...._multiplication
For starters you could perform a product of 2x2 Matrices; and then understand from there on.
Hope this helps. More questions? Keep posting!
#3
Re: Another question about multiplying twodimensional arrays(matrices)
Posted 14 March 2008  03:37 AM
letthecolorsrumble, on 14 Mar, 2008  04:38 AM, said:
You might be already familiar with this link >
http://en.wikipedia...._multiplication
http://en.wikipedia...._multiplication
#4
Re: Another question about multiplying twodimensional arrays(matrices)
Posted 14 March 2008  04:39 AM
In short, you can multiply a [6][4] by a [4][5], and the third ANSWER matrix will be a [6][5]. The two outer dimensions are taken and used to make the resulting matrix.
#5
Re: Another question about multiplying twodimensional arrays(matrices)
Posted 14 March 2008  09:48 PM
Thanks for your help. It's been almost 20 years since I have been in college so alot of the math has changed. I had to look up what matrices was and teach myself how they did work in math and with your help I was able to figure out how they work. I now have the code working. Thanks again for all your help.
Dorothy
Dorothy
Page 1 of 1