added setInverse and get Inverse functions, and also solved caching