Completing assignment 2 - implementation of cached solve for matrix