save matrix