Made ess function public and added support for matrix inputs.