~mht/cra

ref: 933b27350404d77d37a8f2b73e9ae8bc2139e4a5 cra/cra/README.md -rw-r--r-- 2.0 KiB
933b2735 — Martin Hafskjold Thoresen Fix warnings and remove some dead code 1 year, 8 days ago

#CRA

This program implements the matrix reduction algorithm for computing the persistence of a complex, in two variants: regular and exhaustive.

#Notes on the algorithm

The implementation of the algorithms is not really aligned all that well with the common descriptions of it, namely as a matrix reduction algorithm. Instead, we think of the algorithm as working with sets, which corresponds to the boundary of simplices, or matrix columns in the traditional description. Modulo 2 addition of matrix columns becomes symmetric difference of the sets.

Here's pseudocode that reflects how the algorithms are implemented.

reduced = [0; length(simplices)]
for s in simplices
	if s is empty
		continue
	end
	m = max(s)
	if reduced[m] is empty
		reduced[m] = simplex
		continue
	else
		s = symdiff(s, reduced[m])
	end
end

#Usage

Run with --help to get information on the arguments the program takes.

cargo run -q -- -help

or

# this once:
cargo build --release
./target/release/cra --help

This will run with debug output, which right now prints a comma separated table of which simplices are added to which. To display this nicely in the terminal, you can pipe it to column as follows (only tested on Linux):

cargo run -- --boundary data/tet.boundary -d | column -ts';'
j   faces             adds          reduced
0   []                []            [0]
0   [0]               []            [0]
1   [0]               [0]           []
2   [0]               [0]           []
3   [0]               [0]           []
5   [1, 2]            []            [1, 2]
6   [1, 3]            []            [1, 3]
7   [1, 4]            []            [1, 4]
8   [2, 3]            [6, 5]        []
9   [2, 4]            [7, 5]        []
10  [3, 4]            [7, 6]        []
11  [5, 6, 8]         []            [5, 6, 8]
12  [5, 7, 9]         []            [5, 7, 9]
13  [6, 7, 10]        []            [6, 7, 10]
14  [8, 9, 10]        [13, 12, 11]  []
15  [11, 12, 13, 14]  []            [11, 12, 13, 14]