/***********************************************************************//** * @brief Print integral information * * @param[in] chatter Chattiness (defaults to NORMAL). * @return String containing integral information. ***************************************************************************/ std::string GIntegral::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GIntegral ==="); // Append information result.append("\n"+gammalib::parformat("Relative precision")); result.append(gammalib::str(eps())); result.append("\n"+gammalib::parformat("Max. number of iterations")); result.append(gammalib::str(max_iter())); if (silent()) { result.append("\n"+gammalib::parformat("Warnings")+"suppressed"); } else { result.append("\n"+gammalib::parformat("Warnings")); result.append("in standard output"); } } // endif: chatter was not silent // Return result return result; }
void DynDSAddRem::Check(int first_node) { stack<int> to_check; to_check.push(first_node); double threshold = 2.0 * beta_ * (1.0 + epsilon_); int max_iter_num = max_iter(graph_.num_nodes(), epsilon_); while (!to_check.empty()) { int node = to_check.top(); to_check.pop(); int curr_deg = orientation_.in_degree(node); if (static_cast<double>(curr_deg) < threshold) { continue; } if (level_map_[node] >= max_iter_num) { // TODO (true) is necesasry in theory to bound complexity but in practive false is faster. //Construct(true /* use add-only graph*/); Construct(false); return; } int edges_to_reverse = ceil(curr_deg - threshold); vector<int> in_neighbors; orientation_.in_neighbors(node, &in_neighbors); for (vector<int>::iterator it = in_neighbors.begin(); it != in_neighbors.end(); ++it) { int in_neighbor = *it; if (level_map_[in_neighbor] == level_map_[node]) { orientation_.remove_edge(in_neighbor, node); orientation_.add_edge(node, in_neighbor); --edges_to_reverse; to_check.push(in_neighbor); if (edges_to_reverse == 0) { break; } } } ++level_map_[node]; to_check.push(node); } }
bool ConvNet::test_once(int test_x_index) { layers[0]->input_ = test_x_[test_x_index]; int i = 0; for (auto layer : layers) { layer->forward(); if (layer->next != nullptr) { layer->next->input_ = layer->output_; } this->layers_output[i] = &(layer->output_); i++; } int predicted = (int) max_iter(layers.back()->output_); bool is_right = test_y_[test_x_index] == predicted; std::pair<size_t, bool> p1(predicted, is_right); this->saved_output.push_back(p1); return (int) is_right; }
/***********************************************************************//** * @brief Print integral information ***************************************************************************/ std::string GIntegral::print(void) const { // Initialise result string std::string result; // Append header result.append("=== GIntegral ==="); // Append information result.append("\n"+parformat("Relative precision")+str(eps())); result.append("\n"+parformat("Max. number of iterations")+str(max_iter())); if (silent()) { result.append("\n"+parformat("Warnings")+"suppressed"); } else { result.append("\n"+parformat("Warnings")+"in standard output"); } // Return result return result; }
constexpr const char *max_element(const char *a, const char *b) { return (a+1 >= b) ? a : max_iter(a, max_element(a+1, b)); }