Multiplying matrices
May 12th, 2004
Here is a function I created to multiply two matrices:
Actionscript:
-
function multiplyMatrices(matrixA, matrixB){
-
//this function takes two matricies (order of 8 ) in the form
-
//of two-dimesional arrays and multiplies them.
-
var sum = 0
-
var tempArray = new Array();
-
for (var i=1; i<=8; i++){
-
tempArray[i] = new Array();
-
for (var j=1; j<=8; j++){
-
sum = 0;
-
for (var k = 1; k<=8; k++){
-
sum += matrixA[k][j] * matrixB[i][k];
-
}
-
tempArray[i][j] = sum;
-
}
-
}
-
return tempArray;
-
}
Categories: Uncategorized
