modified templates to include code for caching/recalling matrix inversion