fixes
This commit is contained in:
parent
749ea72cfe
commit
cc906992cd
4 changed files with 16 additions and 18 deletions
|
|
@ -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}
|
{-1, 2, 2, 4, 4}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{-6, 11, 14, 23}
|
{-6, 11, 14, 15}
|
||||||
|
|
||||||
{{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}
|
{{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub fn fractal_dimension(
|
||||||
orthogonal_generators: Vec<Vec<usize>>,
|
orthogonal_generators: Vec<Vec<usize>>,
|
||||||
) -> Result<f64, linregress::Error> {
|
) -> Result<f64, linregress::Error> {
|
||||||
let mut totals = vec![root.len(); n];
|
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 next = vec![];
|
||||||
let mut nodes: u64 = 1;
|
let mut nodes: u64 = 1;
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub fn fractal_dimension(
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
next.clear();
|
next.clear();
|
||||||
for (tuple, previous_generator) in ¤t {
|
for (tuple, previous_generator, tuple_too_big) in ¤t {
|
||||||
let mut add_children = false;
|
let mut add_children = false;
|
||||||
let mut children = vec![];
|
let mut children = vec![];
|
||||||
for (i, generator) in generators.iter().enumerate() {
|
for (i, generator) in generators.iter().enumerate() {
|
||||||
|
|
@ -41,10 +41,7 @@ pub fn fractal_dimension(
|
||||||
}
|
}
|
||||||
if i != *previous_generator {
|
if i != *previous_generator {
|
||||||
let new_tuple = generator * tuple;
|
let new_tuple = generator * tuple;
|
||||||
if new_tuple.iter().sum::<f64>() <= tuple.iter().sum() {
|
let mut too_big = true;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let mut add = false;
|
|
||||||
for (j, curvature) in new_tuple.iter().enumerate() {
|
for (j, curvature) in new_tuple.iter().enumerate() {
|
||||||
let mut skip = false;
|
let mut skip = false;
|
||||||
for vertex in &faces[i] {
|
for vertex in &faces[i] {
|
||||||
|
|
@ -58,20 +55,16 @@ pub fn fractal_dimension(
|
||||||
}
|
}
|
||||||
for (k, max) in xs.iter().enumerate() {
|
for (k, max) in xs.iter().enumerate() {
|
||||||
if curvature <= max {
|
if curvature <= max {
|
||||||
add = true;
|
add_children = true;
|
||||||
|
too_big = false;
|
||||||
totals[k] += 1;
|
totals[k] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if add {
|
children.push((new_tuple, i, too_big));
|
||||||
add_children = true;
|
|
||||||
children.push((new_tuple, i));
|
|
||||||
} else {
|
|
||||||
children.push((new_tuple, i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if add_children {
|
if add_children || !tuple_too_big {
|
||||||
nodes += 1;
|
nodes += 1;
|
||||||
for child in children {
|
for child in children {
|
||||||
next.push(child);
|
next.push(child);
|
||||||
|
|
@ -105,7 +98,7 @@ pub fn fractal_dimension(
|
||||||
println!(
|
println!(
|
||||||
"\nnumber of circles fewer than each of those sample points:\n{:?}",
|
"\nnumber of circles fewer than each of those sample points:\n{:?}",
|
||||||
totals
|
totals
|
||||||
);
|
);
|
||||||
println!("\nTotal number of nodes:\t{}", nodes);
|
println!("\nTotal number of nodes:\t{}", nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ pub fn read_file(filename: &str) -> Result<Data, String> {
|
||||||
|
|
||||||
for pair in &orthogonal_generators {
|
for pair in &orthogonal_generators {
|
||||||
if pair.len() != 2 {
|
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);
|
std::process::exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue