I'm trying send 2 matrix names to matrix multiplication function (matrisCarp) which in server but getting this error : The method setMatris2(Matris1Stub.ArrayOfint[]) in the type Matris1Stub.MatrisCarp is not applicable for the arguments (int[][])
This is my server codes :
public class matris1 {
public String sum(Integer a, Integer b) {
return a + " + " + b + " = " + (a + b);
}
public static int[][] matrisCarp(int[][] matris1, int[][] matris2 , int n){
int i,j,k;
int[][] yeniMatris= new int[n][n];
for(i=0; i<n; ++i)
for(j=0; j<n; ++j)
for(k=0; k<n; ++k)
yeniMatris[i][k] += matris1[i][j] * matris2[j][k];
return yeniMatris;
}
}
This is my client codes :
public class matrisClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
int matrisdegeri=0;
JFrame jfrm=new JFrame("Matris Programý");
jfrm.setSize(1000,1000);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JLabel jlab=new JLabel("Matris boyutunu giriniz:");
matrisdegeri =Integer.parseInt(JOptionPane.showInputDialog(jlab));
int[][] randomMatrix1= RandomArray(matrisdegeri);
int[][] randomMatrix2= RandomArray(matrisdegeri);
String sonuc="Birinci Matris: "+Arrays.deepToString(randomMatrix1)+" \n "
+ " Ýkinci Matris: "+Arrays.deepToString(randomMatrix2);
JLabel jlab2=new JLabel(sonuc);
panel.add(jlab2);
jfrm.add(panel);
jfrm.setVisible(true);
DosyayaEkle(sonuc);
***try{
Matris1Stub stub = new Matris1Stub();
MatrisCarp mc = new MatrisCarp();
mc.setMatris1(randomMatrix1);
mc.setMatris2(randomMatrix2);
mc.setN(matrisdegeri);
MatrisCarpResponse res = stub.matrisCarp(mc);
System.out.println(res.get_return());
}***
catch(AxisFault e){
e.printStackTrace();
}
catch(RemoteException e){
e.printStackTrace();
}
}
private static int[][] RandomArray(int n) {
int[][] randomMatrix = new int [n][n];
Random rand = new Random();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
Integer r = rand.nextInt(100)+1;
randomMatrix[i][j] = Math.abs(r);
}
}
return randomMatrix;
}
}
I've had problems in axis and axis 2 swnding lists of lists and such.
You don't need the matrix to be n-dimensional. Just send one big one-dimensional array and the dimensions after peopcessing. In your case ad width and heigth and send all the ints as a one big row in order.
Another way: bytearray them and encode in base64