Modify several functions in vector and matrix classes