73#define POSITION_TRACE (std::string(__FILE__) + ":" + std::to_string(__LINE__))
83template <
class T,
class Compare = Aleph::less<T>>
84inline const T *
median(
const T &a,
const T &b,
const T &c,
const Compare &
cmp = Compare())
129 const char ret = i < 10 ? i +
'0' : i - 10 +
'A';
144 const int ret = c <
'A' ? c -
'0' : c -
'A' + 10;
162#define DERIVATE_ITERATOR(container_name, base_it_name, it_name) \
163 struct it_name : public base_it_name \
169 it_name(container_name &c) : base_it_name(c) \
174 it_name(const it_name &it) : base_it_name(it) \
179 it_name &operator = (const it_name &it) \
181 return base_it_name::operator = (it); \
230 return x && !(x & (x - 1UL));
243 unsigned long ret = 1;
264 std::unique_ptr<
char,
void (*)(
void *)>
res{abi::__cxa_demangle(name,
nullptr,
nullptr, &status),
266 return (status == 0) ?
res.get() : name;
274#define CLASSNAME_TO_STRING(class_ptr) ::Aleph::demangle(typeid(*class_ptr).name())
282 std::cerr << msg <<
'\n';
293 return (
stat(name.c_str(), &buffer) == 0);
302inline std::string
Rvector(
const std::string &name,
const C &c)
304 std::ostringstream s;
305 s << name <<
" <- c(";
307 for (
auto it = c.get_it(); it.has_curr(); it.next())
309 auto &v = it.get_curr();
330 std::ostringstream s;
331 s << c.get_first() <<
" <- c(";
333 for (
auto it = c.get_it(1); it.has_curr(); it.next())
335 auto &v = it.get_curr();
366 return y1 + (y2 -
y1) * (x - x1) / (x2 - x1);
390 return y1 - (y2 -
y1) * (x1 - x) / (x2 - x1);
396inline double pow2(
const double x)
404inline double pow3(
const double x)
430 return y2 + (y2 -
y1) * (x - x2) / (x2 - x1);
441 constexpr double lim = std::numeric_limits<double>::max();
442 return std::nextafter(val,
lim);
452 constexpr double lim = std::numeric_limits<double>::min();
453 return std::nextafter(val,
lim);
465 const double d = v1 - v2;
466 return (d < 0.0 ? -d : d) <= e;
479 std::ofstream
tmp(file_name);
480 tmp <<
"#!/usr/bin/Rscript" <<
'\n'
484 <<
"message(\"Press Return To Continue\")" <<
'\n'
485 <<
"invisible(readLines(\"stdin\", n=1))" <<
'\n';
486 const std::string
cmd =
"Rscript " + file_name;
503 if constexpr (std::numeric_limits<double>::is_iec559 &&
sizeof(
double) ==
sizeof(std::uint64_t))
506 std::uint64_t bits = 0;
507 std::memcpy(&bits, &n,
sizeof(bits));
509 constexpr std::uint64_t
exp_mask = 0x7ff0000000000000ULL;
510 constexpr std::uint64_t
frac_mask = 0x000fffffffffffffULL;
524 if (
not std::isfinite(n))
527 const int status = std::fpclassify(n);
Standard functor implementations and comparison objects.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_frac_function > > frac(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_exp_function > > exp(const __gmp_expr< T, U > &expr)
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
size_t l_index(const size_t i)
Map a binary heap index to the index of its left child.
double next_value(const double val)
Return the next representable floating-point value to val
unsigned long next_power_of_2(unsigned long x)
In x is not exact power of 2, it returns the next power of 2.
void error_msg(const std::string &msg)
Display message and abort program execution.
const T * median(const T &a, const T &b, const T &c, const Compare &cmp=Compare())
Return a pointer to the median value among three elements.
and
Check uniqueness with explicit hash + equality functors.
constexpr bool are_near(const double v1, const double v2, const double e) noexcept
Return true if v1 is within absolute distance e of v2.
double extrapolate_right(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear extrapolation.
std::decay_t< typename HeadC::Item_Type > T
size_t u_index(const size_t &i)
Map a binary heap index to the index of its parent.
double interpolate(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear interpolation.
double prev_value(const double val)
Return the next representable floating-point value of val towards the smallest positive normal number...
bool is_even(const long n)
Return true if n is even.
double pow2(const double x)
Return x^2.
char nibble_to_char(const int i)
Convert a 4-bit nibble stored in an int to its hex character.
bool exists_file(const std::string &name)
Return true if it exists a file of name
bool resize_process_stack(size_t new_size)
Resize the process stack to new_size.
int char_to_nibble(const char c)
Convert a hex character in 0..9A..F to its 4-bit nibble value.
std::string 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
bool is_normal_number(const double n)
Return true if a floating-point number is normal or zero.
std::string demangle(const char *name)
Given a linker symbol name generated by a c++ compiler, this functions decodes it into a user level n...
double extrapolate_left(const double x1, const double x2, const double y1, const double y2, const double x)
Basic linear extrapolation.
double pow3(const double x)
Return x^3.
bool 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...
void 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)