converted some of the matrix functions to coffeescript