|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
General utility functions and helpers. More...
#include <sys/stat.h>#include <cstdlib>#include <cassert>#include <cmath>#include <cstdint>#include <cstring>#include <memory>#include <limits>#include <cxxabi.h>#include <string>#include <sstream>#include <iostream>#include <fstream>#include <typeinfo>#include <algorithm>#include <ahFunction.H>Go to the source code of this file.
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Macros | |
| #define | POSITION_TRACE (std::string(__FILE__) + ":" + std::to_string(__LINE__)) |
String literal with the current source position (file:line). | |
| #define | DERIVATE_ITERATOR(container_name, base_it_name, it_name) |
| Define a derived iterator type from an existing iterator base. | |
| #define | CLASSNAME_TO_STRING(class_ptr) ::Aleph::demangle(typeid(*class_ptr).name()) |
| Given a pointer, it returns the class name. | |
Functions | |
| template<class T , class Compare = Aleph::less<T>> | |
| const T * | Aleph::median (const T &a, const T &b, const T &c, const Compare &cmp=Compare()) |
| Return a pointer to the median value among three elements. | |
| bool | Aleph::is_even (const long n) |
Return true if n is even. | |
| bool | Aleph::is_odd (const long n) |
Return true if n is odd. | |
| char | Aleph::nibble_to_char (const int i) |
Convert a 4-bit nibble stored in an int to its hex character. | |
| int | Aleph::char_to_nibble (const char c) |
Convert a hex character in 0..9A..F to its 4-bit nibble value. | |
| bool | Aleph::resize_process_stack (size_t new_size) |
Resize the process stack to new_size. | |
| size_t | Aleph::u_index (const size_t &i) |
| Map a binary heap index to the index of its parent. | |
| size_t | Aleph::l_index (const size_t i) |
| Map a binary heap index to the index of its left child. | |
| bool | Aleph::is_power_of_2 (unsigned long x) |
| Taken from http://stackoverflow.com/questions/3638431/determine-if-an-int-is-a-power-of-2-or-not-in-a-single-line. | |
| unsigned long | Aleph::next_power_of_2 (unsigned long x) |
| In x is not exact power of 2, it returns the next power of 2. | |
| std::string | Aleph::demangle (const char *name) |
| Given a linker symbol name generated by a c++ compiler, this functions decodes it into a user level name. | |
| void | Aleph::error_msg (const std::string &msg) |
| Display message and abort program execution. | |
| bool | Aleph::exists_file (const std::string &name) |
Return true if it exists a file of name | |
| template<class C > | |
| std::string | Aleph::Rvector (const std::string &name, const C &c) |
Return a string with R specification of a vector with name and data stored in container c | |
| template<class C > | |
| std::string | Aleph::Rvector (const C &c) |
Return a string with an R assignment for a container interpreted as [name, value1, value2, ...]. | |
| double | Aleph::interpolate (const double x1, const double x2, const double y1, const double y2, const double x) |
| Basic linear interpolation. | |
| double | Aleph::extrapolate_left (const double x1, const double x2, const double y1, const double y2, const double x) |
| Basic linear extrapolation. | |
| double | Aleph::pow2 (const double x) |
| Return x^2. | |
| double | Aleph::pow3 (const double x) |
| Return x^3. | |
| double | Aleph::extrapolate_right (const double x1, const double x2, const double y1, const double y2, const double x) |
| Basic linear extrapolation. | |
| double | Aleph::next_value (const double val) |
Return the next representable floating-point value to val | |
| double | Aleph::prev_value (const double val) |
Return the next representable floating-point value of val towards the smallest positive normal number. | |
| constexpr bool | Aleph::are_near (const double v1, const double v2, const double e) noexcept |
Return true if v1 is within absolute distance e of v2. | |
| void | Aleph::execute_R_script (const std::string &scr, const std::string &file_name="tmp.R") |
| Generate and execute a R script from a string (containing the script) | |
| bool | Aleph::is_normal_number (const double n) |
Return true if a floating-point number is normal or zero. | |
General utility functions and helpers.
This file provides miscellaneous utility functions including bit manipulation, memory utilities, file operations, string formatting, type name demangling, and various mathematical helpers used throughout Aleph-w.
Definition in file ahUtils.H.
| #define CLASSNAME_TO_STRING | ( | class_ptr | ) | ::Aleph::demangle(typeid(*class_ptr).name()) |
| #define DERIVATE_ITERATOR | ( | container_name, | |
| base_it_name, | |||
| it_name | |||
| ) |
Define a derived iterator type from an existing iterator base.
This macro is used throughout the library to create a thin derived iterator type that forwards constructors and copy assignment.
| container_name | Container type name. |
| base_it_name | Base iterator type name. |
| it_name | New iterator type name. |