MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
GeneralHelper.hpp File Reference
#include "CustomExceptions.hpp"
#include "Definitions.hpp"
#include <chrono>
#include <cmath>
#include <concepts>
#include <cstddef>
#include <filesystem>
#include <limits>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  cda_rail

Functions

template<std::floating_point T>
bool cda_rail::approx_equal (T const a, T const b, T const factor=10)
 Determines if two floating-point values are approximately equal using a machine-epsilon-scaled tolerance.
void cda_rail::round_small_numbers_to_zero_inplace (double &val, double const tol=EPS)
 Sets a value to zero if its absolute magnitude is less than a tolerance threshold.
double cda_rail::round_to_given_tolerance (double const value, double const tolerance)
 Rounds a value to the nearest multiple of a given tolerance.
std::vector< cda_rail::index_vector > cda_rail::subsets_of_size_k_indices (size_t n, size_t k)
 Generates all subsets of size k of the index set {0, 1, ..., n - 1}.
std::vector< std::pair< size_t, size_t > > cda_rail::subsets_of_size_2_indices (size_t n)
 Generates all unordered index pairs from {0, 1, ..., n - 1}.
void cda_rail::initialize_plog (bool debug_input, bool overwrite_severity=false)
 Initializes the global plog console logger and adjusts its severity.
bool cda_rail::is_directory_and_create (const std::filesystem::path &p)
 Ensures that a filesystem path exists as a directory.
double cda_rail::relu (double val)
 Returns the positive part of a scalar.
template<typename Clock, typename Duration1, typename Duration2>
double cda_rail::get_time_difference_in_seconds (std::chrono::time_point< Clock, Duration1 > const &start, std::chrono::time_point< Clock, Duration2 > const &end)
double cda_rail::get_last_time_step_before (double t, double dt, bool t_inclusive)
 return last time step before t
double cda_rail::get_first_time_step_after (double t, double dt, bool t_inclusive)
 return first time step after t
size_t cda_rail::get_last_time_index_before (double t, double dt, bool t_inclusive)
 return the index of the last time step before t
size_t cda_rail::get_first_time_index_after (double t, double dt, bool t_inclusive)
 return the index of the first time step after t