# i have a problem with my code.pls help me

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® is a registered trademark of EXPERTS EXCHANGE®

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

Commented:
ccy97:
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

Venabili
EE Cleanup Volunteer

Do more with