Completed definition of matrix types.
Converted macro to function.
Added some tests of the matrix functionality and squashed some bugs.
Merge branch 'master' into travis-ci