Utilizing multidimensional arrays, I'm attempting to create a straightforward matrix multiplication approach ([2][2]). Being rather new at this, I'm unable to identify my mistakes. Please let me know what it is if you can; I'd really appreciate it. Since I'm basically doing this to learn how it works, I'd prefer not to use libraries or anything similar.
My variable declaration is as follows:
Double[][] A={{4.00,3.00},{2.00,1.00}};
Double[][] B={{-0.500,1.500},{1.000,-2.0000}};
A*B should return the identity matrix. But it won't work. This is the code:
public static Double[][] multiplicar(Double[][] A, Double[][] B){
Double[][] C= new Double[2][2];
int i,j;
for(i=0;i<2;i++) {
for(j=0;j<2;j++){
C[i][j]=0.00000;
}
}
for(i=0;i<2;i++){
for(j=0;j<2;j++)
C[i][j]+=(A[i][j]*B[j][i]);
}
return C;
}