use gf2::*;
use std::io::{
self,
Write,
};
use utilities_rs::{
Pretty,
Stopwatch,
};
fn main() {
type Word = usize;
type Mat = BitMatrix<Word>;
let n_trials: usize = 1_000;
let n_tick = (n_trials / 20).max(1);
let n: usize = 100;
print!("Running {} trials for random {} x {} bit-matrices ", n_trials.pretty(), n.pretty(), n.pretty());
io::stdout().flush().ok();
let sw = Stopwatch::new();
for trial in 0..n_trials {
if trial % n_tick == 0 {
print!(".");
io::stdout().flush().ok();
}
let m: Mat = Mat::random(n, n);
let p = m.characteristic_polynomial();
assert!(p.eval_matrix(&m).is_zero(), "Oops! p(M) != 0 for trial {}", trial.pretty());
}
println!(" done.");
println!("Characteristic polynomial loop time: {}.", sw);
}