Home > Uncategorized > Multiplying matrices

Multiplying matrices

May 12th, 2004 Randy

Here is a function I created to multiply two matrices:

Actionscript:
  1. function multiplyMatrices(matrixA, matrixB){
  2.    //this function takes two matricies (order of 8 ) in the form
  3.    //of two-dimesional arrays and multiplies them.
  4.    var sum = 0
  5.    var tempArray = new Array();
  6.    for (var i=1; i<=8; i++){
  7.       tempArray[i] = new Array();
  8.       for (var j=1; j<=8; j++){
  9.          sum = 0;
  10.          for (var k = 1; k<=8; k++){
  11.             sum +=  matrixA[k][j] * matrixB[i][k];
  12.          }
  13.          tempArray[i][j] = sum;
  14.       }
  15.    }
  16.    return tempArray;
  17. }

Categories: Uncategorized Tags:
Comments are closed.