Results 1 to 5 of 5
Thread: Non-Square Matrix Multiplication
- 01-22-2012, 04:44 PM #1
Member
- Join Date
- Jan 2012
- Location
- India
- Posts
- 34
- Rep Power
- 0
Non-Square Matrix Multiplication
I titled this new thread as you see above because this kind of problems train us to handle the arrays effectively. I think, Giving solutions to these problems definitely feast our knowledge. As a beginger, its one of the interesting topic to begin with.
Last edited by j_arif123; 01-22-2012 at 05:07 PM. Reason: To give enough description
- 01-22-2012, 04:49 PM #2
Member
- Join Date
- Jan 2012
- Location
- India
- Posts
- 34
- Rep Power
- 0
Re: Non-Square Matrix Multiplication
For example , Lets take two matrices A(3,4) and B(4,2) . if we solve this , the resultant matrix will be R(3,2). This problem comes under Arrays Exercise . we use two dimenional
arrays to create a matrix.
i could not solve it . Thanks in advance.Java Code:/* Exercise 5.14 Write a program to find the product of two matrices A(3,4) and B(4,2) page : 71 */ class Matrix { public static void main(String args[]) { int i,j,k; int r[][] = new int[3][2]; int a[][] = { {1,2,3,4}, {5,6,7,8}, {9,1,2,3} }; int b[][] ={ {1,2}, {3,4}, {5,6}, {7,8} }; // In this case , i dont know to handle these loops. for(i=0;i<2;i++) { for(j=0;j<3;j++) { for(k=0;k<4;i++) { r[j][i] += ( a[j][k] * b[k][i]); } } } for(i=0;i<3;i++) { for(j=0;j<2;j++) { System.out.println(r[i][j]+"\t"); } System.out.print("\n"); } } }Last edited by j_arif123; 01-22-2012 at 06:47 PM. Reason: to present the code.
-
Re: Non-Square Matrix Multiplication
Your current question is unanswerable since you don't tell us enough. You need to show us your attempt and then ask a specific question.
-
Re: Non-Square Matrix Multiplication
Regarding your edited original post: no one here is interested in "giving a solution" since this will cheat you out of a valuable learning exercise, but on the other hand we will be more than happy to try to explain any points of confusion or help fix any errors in your code. But again, first you will need to ask a specific question and/or show us your code and your errors.
- 01-22-2012, 06:32 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
Re: Non-Square Matrix Multiplication
Matrix multiplication is taking the dot product of a row of matrix A and a column of matrix B (for each element of the product matrix). Also, two dimensional arrays in Java are just one dimensional arrays with one dimensional arrays as their elements. These two notions should be enough to implement it all ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
int array multiplication
By sternhagenr in forum New To JavaReplies: 10Last Post: 08-20-2011, 01:41 AM -
need help with multiplication
By dakid2 in forum New To JavaReplies: 10Last Post: 03-08-2011, 03:41 AM -
Implement a multi-threaded matrix multiplication program.
By redasu in forum Threads and SynchronizationReplies: 0Last Post: 11-17-2010, 09:00 AM -
Multiplication table
By rjones215 in forum New To JavaReplies: 3Last Post: 10-19-2009, 04:34 PM -
Help with Multiplication
By phil028 in forum New To JavaReplies: 1Last Post: 12-06-2007, 07:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks