matrix triangulation