diff --git a/fractal_dimension/circle_counting_new/data/square_pyramid.txt b/fractal_dimension/circle_counting_new/data/square_pyramid.txt index c7ff3d2..ea914dd 100644 --- a/fractal_dimension/circle_counting_new/data/square_pyramid.txt +++ b/fractal_dimension/circle_counting_new/data/square_pyramid.txt @@ -1,4 +1,9 @@ -{{{1., 0., 0., 0., 0.}, {0., 1., 0., 0., 0.}, {4., 3., 0., -1., 3.}, {4., 2., 0., -1., 4.}, {0., 0., 0., 0., 1.}}, {{1., 0., 0., 0., 0.}, {0., 1., 0., 0., 0.}, {0., 0., 1., 0., 0.}, {4., 3., 3., 0., -1.}, {4., 4., 2., 0., -1.}}, {{1., 0., 0., 0., 0.}, {4., -1., 4., 2., 0.}, {0., 0., 1., 0., 0.}, {0., 0., 0., 1., 0.}, {4., -1., 3., 3., 0.}}, {{1., 0., 0., 0., 0.}, {4., 0., -1., 3., 3.}, {4., 0., -1., 4., 2.}, {0., 0., 0., 1., 0.}, {0., 0., 0., 0., 1.}}, {{-1., 1., 0., 1., 0.}, {0., 1., 0., 0., 0.}, {0., 1., 0., 1., -1.}, {0., 0., 0., 1., 0.}, {0., 0., 0., 0., 1.}}} +{{{1., 0., 0., 0., 0.}, {0., 1., 0., 0., 0.}, {4., 3., 0., -1., 3.}, {4., 2., 0., -1., 4.}, {0., 0., 0., + 0., 1.}}, {{1., 0., 0., 0., 0.}, {0., 1., 0., 0., 0.}, {0., 0., 1., 0., 0.}, {4., 3., 3., 0., -1.}, {4. +, 4., 2., 0., -1.}}, {{1., 0., 0., 0., 0.}, {4., -1., 4., 2., 0.}, {0., 0., 1., 0., 0.}, {0., 0., 0., 1. +, 0.}, {4., -1., 3., 3., 0.}}, {{1., 0., 0., 0., 0.}, {4., 0., -1., 3., 3.}, {4., 0., -1., 4., 2.}, {0., + 0., 0., 1., 0.}, {0., 0., 0., 0., 1.}}, {{-1., 1., 0., 1., 0.}, {0., 1., 0., 0., 0.}, {0., 1., 0., 1., +-1.}, {0., 0., 0., 1., 0.}, {0., 0., 0., 0., 1.}}} {-1, 2, 2, 4, 4} diff --git a/fractal_dimension/circle_counting_new/data/tetrahedron.txt b/fractal_dimension/circle_counting_new/data/tetrahedron.txt index f85ffa4..6df4421 100644 --- a/fractal_dimension/circle_counting_new/data/tetrahedron.txt +++ b/fractal_dimension/circle_counting_new/data/tetrahedron.txt @@ -25,6 +25,6 @@ } } -{-6, 11, 14, 23} +{-6, 11, 14, 15} {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}} diff --git a/fractal_dimension/circle_counting_new/src/lib.rs b/fractal_dimension/circle_counting_new/src/lib.rs index 802a7a2..243b679 100644 --- a/fractal_dimension/circle_counting_new/src/lib.rs +++ b/fractal_dimension/circle_counting_new/src/lib.rs @@ -13,7 +13,7 @@ pub fn fractal_dimension( orthogonal_generators: Vec>, ) -> Result { let mut totals = vec![root.len(); n]; - let mut current = vec![(root, std::usize::MAX)]; + let mut current = vec![(root, std::usize::MAX, false)]; let mut next = vec![]; let mut nodes: u64 = 1; @@ -25,7 +25,7 @@ pub fn fractal_dimension( loop { next.clear(); - for (tuple, previous_generator) in ¤t { + for (tuple, previous_generator, tuple_too_big) in ¤t { let mut add_children = false; let mut children = vec![]; for (i, generator) in generators.iter().enumerate() { @@ -41,10 +41,7 @@ pub fn fractal_dimension( } if i != *previous_generator { let new_tuple = generator * tuple; - if new_tuple.iter().sum::() <= tuple.iter().sum() { - continue; - } - let mut add = false; + let mut too_big = true; for (j, curvature) in new_tuple.iter().enumerate() { let mut skip = false; for vertex in &faces[i] { @@ -58,20 +55,16 @@ pub fn fractal_dimension( } for (k, max) in xs.iter().enumerate() { if curvature <= max { - add = true; + add_children = true; + too_big = false; totals[k] += 1; } } } - if add { - add_children = true; - children.push((new_tuple, i)); - } else { - children.push((new_tuple, i)); - } + children.push((new_tuple, i, too_big)); } } - if add_children { + if add_children || !tuple_too_big { nodes += 1; for child in children { next.push(child); @@ -105,7 +98,7 @@ pub fn fractal_dimension( println!( "\nnumber of circles fewer than each of those sample points:\n{:?}", totals - ); + ); println!("\nTotal number of nodes:\t{}", nodes); } diff --git a/fractal_dimension/circle_counting_new/src/parser.rs b/fractal_dimension/circle_counting_new/src/parser.rs index 1f12858..cc62415 100644 --- a/fractal_dimension/circle_counting_new/src/parser.rs +++ b/fractal_dimension/circle_counting_new/src/parser.rs @@ -258,7 +258,7 @@ pub fn read_file(filename: &str) -> Result { for pair in &orthogonal_generators { if pair.len() != 2 { - eprintln!("{}\nGot:\t{:?}", Red.paint(format!("Can only have at most two mutually orthogonal generators for now!")), pair); + eprintln!("{}\nGot:\t{:?}", Red.paint("Can only have at most two mutually orthogonal generators for now!".to_string()), pair); std::process::exit(-1); } }