~mht/cra

02a047d21d1336e16ff370a9a62e0657b7f65cd5 — Martin Hafskjold Thoresen 5 months ago 498e74e
Update README a little more
3 files changed, 46 insertions(+), 7 deletions(-)

M Cargo.toml
M README.md
M src/persistence.rs
M Cargo.toml => Cargo.toml +1 -1
@@ 1,6 1,6 @@
[package]
name = "cra"
version = "0.1.0"
version = "0.2.0"
authors = ["Martin Hafskjold Thoresen <git@mht.wtf>"]
description = """
CRA implements the matrix reduction algorithm to compute persistence in a complex.

M README.md => README.md +43 -4
@@ 35,15 35,15 @@ end
Run with `--help` to get information on the arguments the program takes.

```
cargo run -q -- -help
$ cargo run -q -- -help
```

or 

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




@@ 73,3 73,42 @@ j   faces             adds          reduced
```


### Statistics

By running CRA with `--stats=<filename>` (set filename to `-` to write to `stdout`), you get a bunch of statistics in `json`.
This can be piped into `jq` to format, or filter out things, like so:

```
$ cra --boundary data/tet.boundary --stats=- | jq
```

Alternatively, you can save it in a file and run `jq` afterwards:

```
$ cra --boundary data/tet.bondary --stats=tet.json
$ jq '.histogram_add_cost_by_dim' tet.json
{
  "1": {
    "2": 3,
    "4": 3
  },
  "0": {
    "1": 3
  },
  "2": {
    "7": 1,
    "6": 1,
    "3": 1
  }
}
```

Use `jq 'keys'` to list the keys. You probably also want to run `jq` with `-S`, which sorts the keys.

### Example

You want to show the average sizes of the two simplices added together, by dimension:

```
cra --boundary data/tet.boundary --stats=- | jq -S '.avg_add_size_by_dim'
```

M src/persistence.rs => src/persistence.rs +2 -2
@@ 136,8 136,8 @@ pub fn reduce(p: &Persistence, variant: Variant) -> Reduction {
            let low = *current_reduced.faces.last().unwrap();
            if let Some(ref other) = reduced_with_low[low] {
                additions.push((current_reduced.j, other.j));
                simplex_reduce(&mut current_reduced, other);
                simplex_log.add(log::Add::regular(&current_reduced, other));
                simplex_reduce(&mut current_reduced, other);
            } else {
                place_index = Some(low);
                pairings.push((low, simplex.j));


@@ 157,8 157,8 @@ pub fn reduce(p: &Persistence, variant: Variant) -> Reduction {
                let cand_i = current_reduced.faces[n - 1 - safe_simplices];
                if let Some(ref cand) = reduced_with_low[cand_i] {
                    additions.push((current_reduced.j, cand.j));
                    simplex_reduce(&mut current_reduced, cand);
                    simplex_log.add(log::Add::exhaustive(&current_reduced, cand));
                    simplex_reduce(&mut current_reduced, cand);
                    n = current_reduced.faces.len();
                } else {
                    safe_simplices += 1;