implemented Matrix class