Add trace() method to MatrixLib.