Streamline Gram matrix setup for Irisawa hexlet

This commit is contained in:
Aaron Fenyes 2024-11-09 00:19:09 -08:00
parent 27f88455fb
commit 3a0f3a8d1c

View File

@ -337,36 +337,33 @@ mod tests {
// //
#[test] #[test]
fn irisawa_hexlet_test() { fn irisawa_hexlet_test() {
let gram = PartialMatrix({ let gram = {
let mut entries = Vec::<MatrixEntry>::new(); let mut gram_to_be = PartialMatrix::new();
for s in 0..9 { for s in 0..9 {
// each sphere is represented by a spacelike vector // each sphere is represented by a spacelike vector
entries.push(MatrixEntry { index: (s, s), value: 1.0 }); gram_to_be.push_sym(s, s, 1.0);
// the circumscribing sphere is tangent to all of the other // the circumscribing sphere is tangent to all of the other
// spheres, with matching orientation // spheres, with matching orientation
if s > 0 { if s > 0 {
entries.push(MatrixEntry { index: (0, s), value: 1.0 }); gram_to_be.push_sym(0, s, 1.0);
entries.push(MatrixEntry { index: (s, 0), value: 1.0 });
} }
if s > 2 { if s > 2 {
// each chain sphere is tangent to the "sun" and "moon" // each chain sphere is tangent to the "sun" and "moon"
// spheres, with opposing orientation // spheres, with opposing orientation
for n in 1..3 { for n in 1..3 {
entries.push(MatrixEntry { index: (s, n), value: -1.0 }); gram_to_be.push_sym(s, n, -1.0);
entries.push(MatrixEntry { index: (n, s), value: -1.0 });
} }
// each chain sphere is tangent to the next chain sphere, // each chain sphere is tangent to the next chain sphere,
// with opposing orientation // with opposing orientation
let s_next = 3 + (s-2) % 6; let s_next = 3 + (s-2) % 6;
entries.push(MatrixEntry { index: (s, s_next), value: -1.0 }); gram_to_be.push_sym(s, s_next, -1.0);
entries.push(MatrixEntry { index: (s_next, s), value: -1.0 });
} }
} }
entries gram_to_be
}); };
let guess = DMatrix::from_columns( let guess = DMatrix::from_columns(
[ [
sphere(0.0, 0.0, 0.0, 15.0), sphere(0.0, 0.0, 0.0, 15.0),