From 22a93bee28f2ace712cc292cb7447851a4bf6fe6 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Mon, 11 Nov 2024 15:34:51 -0800 Subject: [PATCH] Confirm that frozen entries are frozen exactly --- app-proto/src/engine.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app-proto/src/engine.rs b/app-proto/src/engine.rs index ca05646..1c53ac8 100644 --- a/app-proto/src/engine.rs +++ b/app-proto/src/engine.rs @@ -414,6 +414,40 @@ mod tests { } } + // at the frozen indices, the optimization steps should have exact zeros, + // and the realized configuration should match the initial guess + #[test] + fn frozen_entry_test() { + let gram = { + let mut gram_to_be = PartialMatrix::new(); + for j in 0..2 { + for k in j..2 { + gram_to_be.push_sym(j, k, if (j, k) == (1, 1) { 1.0 } else { 0.0 }); + } + } + gram_to_be + }; + let guess = DMatrix::from_columns(&[ + point(0.0, 0.0, 2.0), + sphere(0.0, 0.0, 0.0, 1.0) + ]); + let frozen = [(3, 0), (3, 1)]; + println!(); + let (config, success, history) = realize_gram( + &gram, guess.clone(), &frozen, + 1.0e-12, 0.5, 0.9, 1.1, 200, 110 + ); + assert_eq!(success, true); + for base_step in history.base_step.into_iter() { + for index in frozen { + assert_eq!(base_step[index], 0.0); + } + } + for index in frozen { + assert_eq!(config[index], guess[index]); + } + } + // --- process inspection examples --- // these tests are meant for human inspection, not automated use. run them