有人可以請幫我創建一個數組的數組。我有一個矩陣計算器,我想創建一個數組的數組('小')。我該怎麼做? functiions create2Darray和calculateDet正在確定,所以現在them.Would問題是對help.I真的很感激需要這些數組的數組(主要基質的未成年人)來計算他們的決定因素和計算逆矩陣 下面是HTML:Javascript如何創建一個數組數組
<div id = "table4">
<div class = "calcHeader">Macierz odwrotna [3x3]</div>
<form id = "row1"><!--first row-->
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
</form>
<form id = "row2"><!--second row-->
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
</form>
<form id = "row3"><!--third row-->
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
<input type = "text" class = "det3"/>
</form>
<div class = "count" onclick="invertMat('det3')"><a href = "#">Wylicz</a></div>
</div>
的Javascript
function invertMat(matrixClass) {
var matrix = create2Darray(matrixClass);
var det = calculateDet(matrix);
//alert(det);
var invMat = new Array();
for (var i = 0; i < matrix.length; i++) {
invMat[i] = new Array();
for (var j = 0; j < matrix.length; j++) {
invMat[i][j] = 0;
}
}
if (matrix.length == 2) {
invMat[0][0] = 1/det * matrix[1][1];
invMat[1][0] = 1/det * (-matrix[1][0]);
invMat[0][1] = 1/det * (-matrix[0][1]);
invMat[1][1] = 1/det * matrix[0][0];
alert(invMat);
} else if (matrix.length == 3) {
//var smaller = new Array();//creating an empty array for a matrix minor
for (var i = 0; i < matrix.length; i++) {
var smaller = new Array(matrix.length - 1);
for (h = 0; h < smaller.length; h++) {
smaller[h] = new Array(matrix.length - 1);
}
for (a = 1; a < matrix.length; a++) {
for (b = 0; b < matrix.length; b++) {
if (b < i) {
smaller[a - 1][b] = matrix[a][b];
} else if (b > i) {
smaller[a - 1][b - 1] = matrix[a][b];
}
}
}
}
}
}