sjkaliski/numbers.js — pull request #57 by revivek (2012-12-17 01:39:53+00:00)
Title: Matrix

I started work on a Matrix object that makes manipulation easier. I also make a SquareMatrix that inherits from Matrix which implements a determinant() method. This means that checking for square-ness is unnecessary, and allows for square-matrix-only methods.

We can create matrices as so:

new Matrix(3,3); // initializes a 3 x 3 matrix, zero initialized.
new Matrix(3,3,1); // initializes a 3 x 3 matrix, initialized with 1
new SquareMatrix(2); // initializes a 2 x 2 matrix, zero initialized

var a = new Matrix(2, 3).fill([3,2,1],[2,6,2]);
var b = new Matrix(2, 3).fill([1,1,2],[2,5,3]);
var c = a.add(b);
c.print();
=> 4 3 3
2 11 5

I'm working on integration, and may need some guidance (testing, etc.), but I wanted to share this now so no work gets duplicated.