我正在尝试使用多维数组([2][2])进行简单的矩阵乘法.我对此有点新意见,而我却无法找到它我做错了什么.我非常感谢能告诉我它是什么的任何帮助.我宁愿不使用库或类似的东西,我主要是这样做以了解它是如何工作的.非常感谢你提前.
我在主方法中声明我的arays如下:
Double[][] A={{4.00,3.00},{2.00,1.00}};
Double[][] B={{-0.500,1.500},{1.000,-2.0000}};
Run Code Online (Sandbox Code Playgroud)
A*B应该返回单位矩阵.它没有.
public static Double[][] multiplicar(Double[][] A, Double[][] B){
//the method runs and returns a matrix of the correct dimensions
//(I actually changed the .length function to a specific value to eliminate
//it as a possible issue), but not the correct values
Double[][] C= new Double[2][2];
int i,j;
////I fill the matrix with zeroes, if I don't do this it gives me an error
for(i=0;i<2;i++) {
for(j=0;j<2;j++){
C[i][j]=0.00000;
}
}
///this is where …Run Code Online (Sandbox Code Playgroud) java arrays matrix multidimensional-array matrix-multiplication