Functions facilitating creation of special matrix which can cache their inverse