solve matrix