use crate::sse::fast_ops::FastOpsTemplate;
use crate::sse::qmc_ising::{IsingManager, QMCIsingGraph};
use crate::sse::*;
use rand::Rng;
pub trait DebugOps: OpContainer {
fn count_diagonal_and_off(&self) -> (usize, usize) {
let cutoff = self.get_cutoff();
let mut diag = 0;
let mut offdiag = 0;
for p in 0..cutoff {
let op = self.get_pth(p);
if let Some(op) = op {
if op.is_diagonal() {
diag += 1;
} else {
offdiag += 1;
}
}
}
debug_assert_eq!(diag + offdiag, self.get_n());
(diag, offdiag)
}
fn count_constant_ops(&self) -> usize {
let cutoff = self.get_cutoff();
let mut constant = 0;
for p in 0..cutoff {
let op = self.get_pth(p);
if let Some(op) = op {
if op.is_constant() {
constant += 1;
}
}
}
constant
}
}
pub trait QMCDebug {
type M: DebugOps;
fn get_debug_manager(&self) -> &Self::M;
fn count_diagonal_and_off(&self) -> (usize, usize) {
self.get_debug_manager().count_diagonal_and_off()
}
fn count_constant_ops(&self) -> usize {
self.get_debug_manager().count_constant_ops()
}
}
impl<O: Op> DebugOps for FastOpsTemplate<O> {}
impl<R, M> QMCDebug for QMCIsingGraph<R, M>
where
R: Rng,
M: IsingManager + DebugOps,
{
type M = M;
fn get_debug_manager(&self) -> &Self::M {
self.get_manager_ref()
}
}