From 3a0f3a8d1c4db74b950324787bf2d1e25a7711c9 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Sat, 9 Nov 2024 00:19:09 -0800 Subject: [PATCH] Streamline Gram matrix setup for Irisawa hexlet --- app-proto/src/engine.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app-proto/src/engine.rs b/app-proto/src/engine.rs index c5f0a8e..7e6e5ba 100644 --- a/app-proto/src/engine.rs +++ b/app-proto/src/engine.rs @@ -337,36 +337,33 @@ mod tests { // #[test] fn irisawa_hexlet_test() { - let gram = PartialMatrix({ - let mut entries = Vec::::new(); + let gram = { + let mut gram_to_be = PartialMatrix::new(); for s in 0..9 { // 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 // spheres, with matching orientation if s > 0 { - entries.push(MatrixEntry { index: (0, s), value: 1.0 }); - entries.push(MatrixEntry { index: (s, 0), value: 1.0 }); + gram_to_be.push_sym(0, s, 1.0); } if s > 2 { // each chain sphere is tangent to the "sun" and "moon" // spheres, with opposing orientation for n in 1..3 { - entries.push(MatrixEntry { index: (s, n), value: -1.0 }); - entries.push(MatrixEntry { index: (n, s), value: -1.0 }); + gram_to_be.push_sym(s, n, -1.0); } // each chain sphere is tangent to the next chain sphere, // with opposing orientation let s_next = 3 + (s-2) % 6; - entries.push(MatrixEntry { index: (s, s_next), value: -1.0 }); - entries.push(MatrixEntry { index: (s_next, s), value: -1.0 }); + gram_to_be.push_sym(s, s_next, -1.0); } } - entries - }); + gram_to_be + }; let guess = DMatrix::from_columns( [ sphere(0.0, 0.0, 0.0, 15.0),