#Functions for creating a Matrix and caching it