I need help with matrix....please!!!

Reply

Join Date: Sep 2004
Posts: 2
Reputation: rush88 is an unknown quantity at this point 
Solved Threads: 0
rush88 rush88 is offline Offline
Newbie Poster

I need help with matrix....please!!!

 
0
  #1
Sep 16th, 2004
I got this far....but its not giving me the required output....can you give me some directions....here are my codes....thanks....please refer to my pdf file for the question.
//import java.lang.*;
import java.math.*;
import java.io.*;
class MatMulti extends Thread
{
static int in1[][];
static int in2[][];
static int out[][];
static int n=2;
int row;
MatMulti(int i)
{
row=i;
this.start();
}
public void run()
{
int i,j;
for(i=0;i<n;i++)
{
out[row]=0;
for(j=0;j<n;j++)
out[row]=out[row]+in1[row][j]*in2[j];
}
}
public static void main(String args[])
{
int i,j;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the order of Matrix A : ");
try
{
n=Integer.parseInt(br.readLine());
}catch(Exception e){}
in1=new int[n][n];
in2=new int[n][n];
out=new int[n][n];
System.out.println("Enter the First Matrix : ");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
try
{
in1[j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
System.out.println("Enter the Second Matrix : ");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
try
{
in2[j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
MatMulti mat[]=new MatMulti[n];
for(i=0;i<n;i++)
mat=new MatMulti(i);
try
{
for(i=0;i<n;i++)
mat.join();
}catch(Exception e){}
System.out.println("OUTPUT :");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
System.out.println(out[j]);
}
}
Attached Files
File Type: pdf assignment2.pdf (32.5 KB, 16 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: I need help with matrix....please!!!

 
0
  #2
Sep 17th, 2004
Tell us what it is you think you need to do with this code, and try to solve it yourself. you should just put the small snippet of code that shows how you would like to solve the problem, then we can help you.

Also, put your code within [ CODE ] [ / CODE ] tags. Otherwise it is hard to help you.


Ed
In a world without walls or fences,
What use are Windows and Gates.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 2
Reputation: rush88 is an unknown quantity at this point 
Solved Threads: 0
rush88 rush88 is offline Offline
Newbie Poster

Re: I need help with matrix....please!!!

 
0
  #3
Sep 17th, 2004
Originally Posted by cosi
Tell us what it is you think you need to do with this code, and try to solve it yourself. you should just put the small snippet of code that shows how you would like to solve the problem, then we can help you.

Also, put your code within [ CODE ] [ / CODE ] tags. Otherwise it is hard to help you.


Ed
hello ED!!
If you refer to my pdf file.....thats the out put i want
firstly the size of matrix...then input first matrix by user using dialog box and so on......but the output is displayed on command prompt
eg:
Matrix A:
1.0 2.0 3.0
4.0 5.0 6.0

Matrix B:
7.0 8.0 9.0
0.0 9.0 8.0
7.0 6.0 5.0

Product of Matrix A and B
28.0 44.0 40.0
70.0 113.0 106.0

thanks
Rashil
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: I need help with matrix....please!!!

 
0
  #4
Sep 18th, 2004
I don't want to solve your homework for you. Start thinking about how you will solve it and post your ideas/code snippets/pseudocode here. Then people will help you.


Ed
In a world without walls or fences,
What use are Windows and Gates.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC