full matrix formulation