22#include "impurity_trace.hpp"
23using namespace triqs_cthyb;
27void impurity_trace::check_cache_integrity([[maybe_unused]]
bool print) {
28#ifdef TRACE_CHECK_CACHE
29 static int check_counter = 0;
31 if (check_counter % 10 == 0) {
32 if (print) std::cout <<
" ---- Cache integrity check ---- " << std::endl;
33 if (print) std::cout <<
" check_counter = config number = " << check_counter << std::endl;
34 if (print) tree.graphviz(std::ofstream(
"tree_cache_check"));
35 foreach_subtree_first(tree, [&](node y) { this->check_cache_integrity_one_node(y, print); });
36 if (print) std::cout <<
" ---- Cache integrity completed ---- " << std::endl;
43int impurity_trace::check_one_block_table_linear(node n,
int b,
bool print) {
46 foreach_reverse(tree, n, [&](node y) {
49 B = (y->delete_flag ? B : this->get_op_block_map(y, B));
51 std::cout <<
"linear computation : " << y->key <<
" " << y->op.dagger <<
" " << y->op.linear_index <<
" | " << BB <<
" -> " << B << std::endl;
58matrix_t impurity_trace::check_one_block_matrix_linear(node top,
int b) {
60 node p = tree.max(top);
61 matrix_t M = nda::eye<h_scalar_t>(get_block_dim(b));
62 auto _ = arrays::range::all;
64 foreach_reverse(tree, top, [&](node n) {
67 auto dtau = double(n->key - p->key);
69 auto dim = M.shape()[0];
70 for (
int i = 0; i < dim; ++i) M(i, _) *= std::exp(-dtau * get_block_eigenval(b, i));
74 if (!n->delete_flag) {
75 int bp = this->get_op_block_map(n, b);
76 if (bp == -1) TRIQS_RUNTIME_ERROR <<
" Nasty error ";
77 M = get_op_block_matrix(n, b) * M;
87void impurity_trace::check_cache_integrity_one_node(node n,
bool print) {
88 if (n ==
nullptr)
return;
89 if (print) std::cout <<
" ... checking cache integrity for node " << n->key << std::endl;
93 for (
int b = 0; b < n_blocks; ++b) {
94 auto check = check_one_block_table_linear(n, b,
false);
95 if (ca.block_table[b] != check) {
96 std::cout <<
" Inconsistent block table for block " << b <<
" : cache = " << ca.block_table[b] <<
" while it should be " << check
98 check_one_block_table_linear(n, b,
true);
99 TRIQS_RUNTIME_ERROR <<
" FATAL ";