use quizx::circuit::*;
use quizx::extract::*;
use quizx::simplify::*;
use quizx::tensor::*;
use quizx::vec_graph::*;
use std::fs;
use std::time::Instant;
fn main() -> Result<(), Box<dyn std::error::Error>> {
for e in fs::read_dir("circuits/small")? {
if let Some(f) = e?.path().to_str() {
let time = Instant::now();
println!("{}", f);
let c = Circuit::from_file(f)
.unwrap_or_else(|e| panic!("circuit failed to parse: {}. {}", f, e));
println!("...done reading in {:.2?}", time.elapsed());
println!("Simplifying circuit...");
let time = Instant::now();
let mut g: Graph = c.to_graph();
full_simp(&mut g);
println!("Done simplifying in {:.2?}", time.elapsed());
println!("Extracting circuit...");
let time = Instant::now();
let result = g
.extractor()
.gflow()
.extract();
match result {
Ok(c1) => {
println!("Done in {:.2?}", time.elapsed());
println!("extracted ok");
if c1.num_qubits() > 5 {
println!("Circuit too big, not comparing tensors.");
continue;
}
println!("Comparing tensors...");
let time = Instant::now();
if !TensorF::scalar_compare(&c, &c1) {
println!("Tensors differ!");
} else {
println!("Checked successfully in {:.2?}", time.elapsed());
}
}
Err(ExtractError(msg, _c, _g)) => {
println!("extract failed: {}", msg);
}
}
}
}
Ok(())
}