created class to store mx and its inverse and a function to use this class