created the caching matrix functions