Shared triangular-distance-matrix arithmetic, used by both CSV and Ripser -- the two families of format that store a distance matrix as a flat list of triangular entries rather than a dense grid. Kept as one implementation rather than two so the "which row has how many entries, in what order" convention can't silently drift apart between the two call sites.
flat holds, for i = 1 until n, the i entries d(i,0),...,d(i,i-1), rows concatenated in order -- both Ripser's own LOWER_DISTANCE_MATRIX/DISTANCE_MATRIX text formats and CSV.readLowerTriangularDistanceMatrix use this exact convention. Expanded here into a full symmetric n x n matrix with zero diagonal.
flat holds, for i = 1 until n, the i entries d(i,0),...,d(i,i-1), rows concatenated in order -- both Ripser's own LOWER_DISTANCE_MATRIX/DISTANCE_MATRIX text formats and CSV.readLowerTriangularDistanceMatrix use this exact convention. Expanded here into a full symmetric n x n matrix with zero diagonal.