added matrix maximum entropy code