Added code to cache Matrix

Mostly just a copy/paste of the vector one replacing mean with solve