matrix<double> impurity_trace::check_one_block_matrix_linear(node top, int b, bool print) { node p = tree.max(top); matrix<double> M = make_unit_matrix<double>(get_block_dim(b)); auto _ = arrays::range(); foreach_reverse(tree, top, [&](node n) { // multiply by the exponential unless it is the first call, i.e. first operator n==p if (n != p) { auto dtau = double(n->key - p->key); // M <- exp * M auto dim = first_dim(M); // same as get_block_dim(b1); for (int i = 0; i < dim; ++i) M(i, _) *= std::exp(-dtau * get_block_eigenval(b, i)); // M <- Op * M } // multiply by operator matrix unless it is delete_flag if (!n->delete_flag) { int bp = this->get_op_block_map(n, b); if (bp == -1) TRIQS_RUNTIME_ERROR << " Nasty error "; M = get_op_block_matrix(n, b) * M; b = bp; } p = n; }); return M; }
bool ktx_texture::operator==(const ktx_texture &rhs) const { if (this == &rhs) return true; // This is not super deep because I want to avoid poking around into internal state (such as the header) #define CMP(x) \ if (x != rhs.x) \ return false; CMP(get_ogl_internal_fmt()); CMP(get_width()); CMP(get_height()); CMP(get_depth()); CMP(get_num_mips()); CMP(get_array_size()); CMP(get_num_faces()); CMP(is_compressed()); CMP(get_block_dim()); // The image fmt/type shouldn't matter with compressed textures. if (!is_compressed()) { CMP(get_ogl_fmt()); CMP(get_ogl_type()); } CMP(get_total_images()); CMP(get_opposite_endianness()); // Do an order insensitive key/value comparison. dynamic_string_array lhs_keys; get_keys(lhs_keys); dynamic_string_array rhs_keys; rhs.get_keys(rhs_keys); if (lhs_keys.size() != rhs_keys.size()) return false; lhs_keys.sort(dynamic_string_less_than_case_sensitive()); rhs_keys.sort(dynamic_string_less_than_case_sensitive()); for (uint32_t i = 0; i < lhs_keys.size(); i++) if (lhs_keys[i].compare(rhs_keys[i], true) != 0) return false; for (uint32_t i = 0; i < lhs_keys.size(); i++) { uint8_vec lhs_data, rhs_data; if (!get_key_value_data(lhs_keys[i].get_ptr(), lhs_data)) return false; if (!get_key_value_data(lhs_keys[i].get_ptr(), rhs_data)) return false; if (lhs_data != rhs_data) return false; } // Compare images. for (uint32_t l = 0; l < get_num_mips(); l++) { for (uint32_t a = 0; a < get_array_size(); a++) { for (uint32_t f = 0; f < get_num_faces(); f++) { for (uint32_t z = 0; z < get_depth(); z++) { const uint8_vec &lhs_img = get_image_data(l, a, f, z); const uint8_vec &rhs_img = rhs.get_image_data(l, a, f, z); if (lhs_img != rhs_img) return false; } } } } #undef CMP return true; }