If all pairs of documents are compared to find their similarities, the results can be recorded in a matrix. Note that the diagonal is all 1's and that only a (e.g., lower) triangle is needed to capture the unique pairs, due to symmetry.