Copied from the R package "golazo" with kind permission by Piotr Zwiernik piotr.zwiernik@utoronto.ca.
This function outputs the Z matrix, that is, the unique ultrametric matrix dominating S.
This matrix is used to construct a starting point in the GOLAZO algorithm when L=0 but U has strictly positive (off-diagonal entries).