forked from glen/dyna3

At the end of the realization routine, use the computed Hessian to find the tangent space of the solution variety, and return it alongside the realization. Since altering the constraints can change the tangent space without changing the solution, we compute the tangent space even when the guess passed to the realization routine is already a solution.
25 lines
No EOL
1,011 B
Rust
25 lines
No EOL
1,011 B
Rust
use dyna3::engine::{Q, irisawa::realize_irisawa_hexlet};
|
|
|
|
fn main() {
|
|
const SCALED_TOL: f64 = 1.0e-12;
|
|
let (config, _, success, history) = realize_irisawa_hexlet(SCALED_TOL);
|
|
print!("\nCompleted Gram matrix:{}", config.tr_mul(&*Q) * &config);
|
|
if success {
|
|
println!("Target accuracy achieved!");
|
|
} else {
|
|
println!("Failed to reach target accuracy");
|
|
}
|
|
println!("Steps: {}", history.scaled_loss.len() - 1);
|
|
println!("Loss: {}", history.scaled_loss.last().unwrap());
|
|
if success {
|
|
println!("\nChain diameters:");
|
|
println!(" {} sun (given)", 1.0 / config[(3, 3)]);
|
|
for k in 4..9 {
|
|
println!(" {} sun", 1.0 / config[(3, k)]);
|
|
}
|
|
}
|
|
println!("\nStep │ Loss\n─────┼────────────────────────────────");
|
|
for (step, scaled_loss) in history.scaled_loss.into_iter().enumerate() {
|
|
println!("{:<4} │ {}", step, scaled_loss);
|
|
}
|
|
} |