added a function to matrix2
added functions to matrix3