General ActionScript 2 Matrix Multiplication code
Posted on Friday, June 25th, 2010 at 8:59 pm by Hans Wichman
Just a tidbit of code, for a general matrix multiplication:
var result:Array = new Array ();
for (var y:Number = 0; y < mAHeight; y++) {
for (var x:Number = 0; x < mBWidth; x++) {
result[x+mAHeight*y] = 0;
for (var e:Number = 0; e < mAWidth; e++) {
result[x+mAHeight*y] += mA[(y * mAWidth) + e]*mB[x + (e * mBWidth)];
}
}
}
Although if you need real performance you will probably unroll the 3 loops.