use la_stack::prelude::*;
fn main() {
let perturbation = f64::from_bits(0x3CD0_0000_0000_0000); let m = Matrix::<3>::from_rows([
[1.0 + perturbation, 2.0, 3.0],
[4.0, 5.0, 6.0],
[7.0, 8.0, 9.0],
]);
let sign = m.det_sign_exact().unwrap();
let det_f64 = m.det(DEFAULT_PIVOT_TOL).unwrap();
println!("Near-singular 3×3 matrix (perturbation = 2^-50 ≈ {perturbation:.2e}):");
for r in 0..3 {
print!(" [");
for c in 0..3 {
if c > 0 {
print!(", ");
}
print!("{:22.18}", m.get(r, c).unwrap());
}
println!("]");
}
println!();
println!("f64 det() = {det_f64:+.6e}");
println!("det_sign_exact() = {sign}");
println!();
println!("The exact sign is −1 (negative), matching the analytical result.");
}