diff --git a/app-proto/src/engine.rs b/app-proto/src/engine.rs index 7e6e5ba..3d4ef8c 100644 --- a/app-proto/src/engine.rs +++ b/app-proto/src/engine.rs @@ -335,8 +335,7 @@ mod tests { // "Japan's 'Wasan' Mathematical Tradition", by Abe Haruki // https://www.nippon.com/en/japan-topics/c12801/ // - #[test] - fn irisawa_hexlet_test() { + fn realize_irisawa_hexlet(scaled_tol: f64) -> (DMatrix, bool, DescentHistory) { let gram = { let mut gram_to_be = PartialMatrix::new(); for s in 0..9 { @@ -364,6 +363,7 @@ mod tests { } gram_to_be }; + let guess = DMatrix::from_columns( [ sphere(0.0, 0.0, 0.0, 15.0), @@ -378,17 +378,31 @@ mod tests { ) ).collect::>().as_slice() ); + + // the frozen entries fix the radii of the circumscribing sphere, the + // "sun" and "moon" spheres, and one of the chain spheres let frozen: [(usize, usize); 4] = array::from_fn(|k| (3, k)); - const SCALED_TOL: f64 = 1.0e-12; - let (config, success, history) = realize_gram( + + realize_gram( &gram, guess, &frozen, - SCALED_TOL, 0.5, 0.9, 1.1, 200, 110 - ); + scaled_tol, 0.5, 0.9, 1.1, 200, 110 + ) + } + + #[test] + fn irisawa_hexlet_test() { + // solve Irisawa's problem + const SCALED_TOL: f64 = 1.0e-12; + let (config, success, history) = realize_irisawa_hexlet(SCALED_TOL); + + // check against Irisawa's solution let entry_tol = SCALED_TOL.sqrt(); let solution_diams = [30.0, 10.0, 6.0, 5.0, 15.0, 10.0, 3.75, 2.5, 2.0 + 8.0/11.0]; for (k, diam) in solution_diams.into_iter().enumerate() { assert!((config[(3, k)] - 1.0 / diam).abs() < entry_tol); } + + // print info print!("\nCompleted Gram matrix:{}", config.tr_mul(&*Q) * &config); if success { println!("Target accuracy achieved!");