This commit is contained in:
William Ball 2021-07-20 14:42:01 -04:00
parent 749ea72cfe
commit cc906992cd
4 changed files with 16 additions and 18 deletions

View file

@ -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}

View file

@ -25,6 +25,6 @@
}
}
{-6, 11, 14, 23}
{-6, 11, 14, 15}
{{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}

View file

@ -13,7 +13,7 @@ pub fn fractal_dimension(
orthogonal_generators: Vec<Vec<usize>>,
) -> Result<f64, linregress::Error> {
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 &current {
for (tuple, previous_generator, tuple_too_big) in &current {
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::<f64>() <= 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);
}

View file

@ -258,7 +258,7 @@ pub fn read_file(filename: &str) -> Result<Data, String> {
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);
}
}