Factor out the realization of the Irisawa hexlet
This commit is contained in:
parent
3a0f3a8d1c
commit
4094301318
@ -335,8 +335,7 @@ mod tests {
|
|||||||
// "Japan's 'Wasan' Mathematical Tradition", by Abe Haruki
|
// "Japan's 'Wasan' Mathematical Tradition", by Abe Haruki
|
||||||
// https://www.nippon.com/en/japan-topics/c12801/
|
// https://www.nippon.com/en/japan-topics/c12801/
|
||||||
//
|
//
|
||||||
#[test]
|
fn realize_irisawa_hexlet(scaled_tol: f64) -> (DMatrix<f64>, bool, DescentHistory) {
|
||||||
fn irisawa_hexlet_test() {
|
|
||||||
let gram = {
|
let gram = {
|
||||||
let mut gram_to_be = PartialMatrix::new();
|
let mut gram_to_be = PartialMatrix::new();
|
||||||
for s in 0..9 {
|
for s in 0..9 {
|
||||||
@ -364,6 +363,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
gram_to_be
|
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),
|
||||||
@ -378,17 +378,31 @@ mod tests {
|
|||||||
)
|
)
|
||||||
).collect::<Vec<_>>().as_slice()
|
).collect::<Vec<_>>().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));
|
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,
|
&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 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];
|
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() {
|
for (k, diam) in solution_diams.into_iter().enumerate() {
|
||||||
assert!((config[(3, k)] - 1.0 / diam).abs() < entry_tol);
|
assert!((config[(3, k)] - 1.0 / diam).abs() < entry_tol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print info
|
||||||
print!("\nCompleted Gram matrix:{}", config.tr_mul(&*Q) * &config);
|
print!("\nCompleted Gram matrix:{}", config.tr_mul(&*Q) * &config);
|
||||||
if success {
|
if success {
|
||||||
println!("Target accuracy achieved!");
|
println!("Target accuracy achieved!");
|
||||||
|
Loading…
Reference in New Issue
Block a user