Results 1 to 5 of 5
Thread: NonSquare Matrix Multiplication
 01222012, 05:44 PM #1Member
 Join Date
 Jan 2012
 Location
 India
 Posts
 34
 Rep Power
 0
NonSquare 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; 01222012 at 06:07 PM. Reason: To give enough description
 01222012, 05:49 PM #2Member
 Join Date
 Jan 2012
 Location
 India
 Posts
 34
 Rep Power
 0
Re: NonSquare 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.
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; 01222012 at 07:47 PM. Reason: to present the code.

Re: NonSquare 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: NonSquare 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.
 01222012, 07:32 PM #5
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,395
 Blog Entries
 7
 Rep Power
 25
Re: NonSquare 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,
JosBuild a wall around Donald Trump; I'll pay for it.
Similar Threads

int array multiplication
By sternhagenr in forum New To JavaReplies: 10Last Post: 08202011, 01:41 AM 
need help with multiplication
By dakid2 in forum New To JavaReplies: 10Last Post: 03082011, 04:41 AM 
Implement a multithreaded matrix multiplication program.
By redasu in forum Threads and SynchronizationReplies: 0Last Post: 11172010, 10:00 AM 
Multiplication table
By rjones215 in forum New To JavaReplies: 3Last Post: 10192009, 04:34 PM 
Help with Multiplication
By phil028 in forum New To JavaReplies: 1Last Post: 12062007, 08:39 PM
Bookmarks