Added functionality to matrix class