Move some convenience functions into Matrix class