i have a problem with my code.pls help me

ccy97
ccy97 used Ask the Experts™
on
i faced some problem in my matrices program.have anyone help me up.i really do appreciate him.thanks

public class matriceImpl
    extends
      java.rmi.server.UnicastRemoteObject
    implements matrice {
    public matriceImpl()
        throws java.rmi.RemoteException {
        super();
    }
  static int [][] mult(int [][] A,int [][] B) throws java.rmi.RemoteException
      {
      int d1 = A.length;
      int d2 = A[0].length;
      int [][] C= new int [d1][d2];
      for (int i=0;i<d1;i++ );
          for (int j=0;j<d2;j++ );
               for (int k=0;k<A.length;k++ );
      C[i][j]=A[i][k]*B[k][j];
      return C;
 }
 public static int [][] add(int [][] A,int [][] B) throws java.rmi.RemoteException
      {
     int d1 = A.length;
      int d2 = A[0].length;
      int [][] C= new int [d1][d2];
      for (int i=0;i<d1;i++ );
          for (int j=0;j<d2;j++ );
     C[i][j]=A[i][j]+B[i][j];
      return C;
 }
  public static int [][] prod(int [][] A,int [][] B) throws java.rmi.RemoteException
       {
     int d1 = A.length;
      int d2 = A[0].length;
      int [][] C= new int [d1][d2];
      for (int i=0;i<d1;i++ );
          for (int j=0;j<d2;j++ );
     C[i][j]=A[i][j]*B[i][j];
      return C;
 }
}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ovi

Commented:
You forgot to tell about the problem ...
Commented:
Use "{" : you'll see that "C[i][j]=A[i][k]*B[k][j];" isn't in any loop...

It could be better like this :

for (int i=0;i<d1;i++ ) {
  for (int j=0;j<d2;j++ ){
   C[i][j]=A[i][j]*B[i][j];
  }
}
Commented:
also check on this.

>> int d2 = A[0].length;

As far as I remember, if you multiply x*y with a y*z matrix, u will have a result of x*z matrix..

if that is the case, it should be

 int d2 = B[0].length;
for mult and prod

and I don't think you've got the formula correct either..

vemul
ccy97:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between seguret and vemul

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial