~mht/cra

7e22ace5d13b0676f74d0a76f8a7f59d331cb074 — Martin Hafskjold Thoresen 9 months ago 4e75bbb
Issue #4: Add `adds_required_by_dim` as output.
1 files changed, 10 insertions(+), 4 deletions(-)

M src/log.rs
M src/log.rs => src/log.rs +10 -4
@@ 47,6 47,9 @@ pub struct Reduction {
pub struct Aggregate {
    /// Simplex IDs of all additions.
    adds: Vec<(usize, usize)>,

	/// The number of adds required to reduce a simplex, by dimension.
    adds_required_by_dim: HashMap<isize, f64>,
    /// The average number of additions required to reduce a simplex, by dimension.
    avg_adds_required: HashMap<isize, f64>,



@@ 82,14 85,16 @@ impl Reduction {
            }
        }

        let mut avg_adds_required = HashMap::new();
		let mut adds_required_by_dim = HashMap::new();
        let mut count = HashMap::new();
        for r in self.reductions.iter() {
            *avg_adds_required.entry(r.dim).or_insert(0.0) += r.adds.len() as f64;
            *adds_required_by_dim.entry(r.dim).or_insert(0.0) += r.adds.len() as f64;
            *count.entry(r.dim).or_insert(0) += 1;
        }
        for (k, &c) in count.iter() {
            *avg_adds_required.get_mut(k).unwrap() /= c as f64;

        let mut avg_adds_required = HashMap::new();
        for (&k, &c) in count.iter() {
            avg_adds_required.insert(k, adds_required_by_dim.get(&k).unwrap() / c as f64);
        }




@@ 148,6 153,7 @@ impl Reduction {

        Aggregate {
            adds,
            adds_required_by_dim,
            avg_adds_required,
            add_size_by_dim,
            avg_add_size_by_dim,