Reduces number of database queries made by triangularisation

Triangularisation references Person when in fact the inner loop does not depend on Person and instead refers solely to the SparseArray.

This commit modifies the triangularisation to only depend on the SpareArray.