4 Replies - 7081 Views - Last Post: 14 March 2008 - 09:48 PM Rate Topic: -----

#1 dspivey5257  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-March 08

Another question about multiplying two-dimensional arrays(matrices)

Post icon  Posted 13 March 2008 - 07:42 PM

I have a question concerning multiplying two-dimensional 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

Is This A Good Question/Topic? 0
  • +

Replies To: Another question about multiplying two-dimensional arrays(matrices)

#2 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Another question about multiplying two-dimensional 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! :)
Was This Post Helpful? 0
  • +
  • -

#3 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Another question about multiplying two-dimensional arrays(matrices)

Posted 14 March 2008 - 03:37 AM

View Postletthecolorsrumble, on 14 Mar, 2008 - 04:38 AM, said:

You might be already familiar with this link ->
http://en.wikipedia...._multiplication

:^:
Was This Post Helpful? 0
  • +
  • -

#4 .Maleficus.  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 129
  • Joined: 07-March 08

Re: Another question about multiplying two-dimensional 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.
Was This Post Helpful? 0
  • +
  • -

#5 dspivey5257  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-March 08

Re: Another question about multiplying two-dimensional 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1