Namespaces | |
details | |
Classes | |
class | ArrowOperatorProxy |
Proxy class to hold an element accessible via arrow operator. More... | |
class | AsynchronousReader |
Read bytes from an InputSource into a char buffer . More... | |
class | BadOptionalAccess |
Optional access error for empty values. More... | |
class | BaseInputSource |
Abstract base class for reading byte data from input sources. More... | |
class | BaseOutputTarget |
Abstract base class for writing data to an output target. More... | |
class | Bitvector |
struct | BitvectorHash |
Helper structure that yields the hash of a given Bitvector. More... | |
struct | BitvectorXhash |
Helper structer that yields the x_hash of a given Bitvector. More... | |
class | BlockingConcurrentQueue |
class | BmpWriter |
Write Bitmap image files. More... | |
class | CharLookup |
Simple lookup table providing a value lookup for each ASCII char (0-127). More... | |
class | Color |
class | ColorMap |
Store a list of colors and offer them as a map for values in range [ 0.0, 1.0 ] . More... | |
class | ColorNormalization |
Base class for color normalization. More... | |
class | ColorNormalizationBoundary |
Color normalization that maps to discrete intervals. More... | |
class | ColorNormalizationDiverging |
Color normalization for a diverging scale. More... | |
class | ColorNormalizationLinear |
Default Color normalization, using a sequential linear scaling in the range [ min, max ] . More... | |
class | ColorNormalizationLogarithmic |
Color normalization for a logarithmic scale. More... | |
class | CompensatedSum |
Compensated summation algorithmm, such as Kahan, Neumaier, and Klein summation. More... | |
class | ConcurrentQueue |
struct | ConcurrentQueueDefaultTraits |
struct | ConsumerToken |
class | CsvInputIterator |
class | CsvReader |
Read Comma/Character Separated Values (CSV) data and other delimiter-separated formats. More... | |
class | Dataframe |
class | DataframeReader |
class | DereferenceIterator |
Iterator class that exposes elements in a container of pointers. More... | |
class | Deserializer |
struct | EmptyGenericInputStreamData |
Empty helper data struct to serve as a dummy for GenericInputStream. More... | |
struct | EmptyIntervalData |
Empty class used as default for Interval data. More... | |
class | EuclideanKmeans |
class | Exception |
Base class for genesis exceptions. More... | |
class | ExistingFileError |
Exception class that is thrown if trying to write to an existing file. More... | |
class | FileInputSource |
Input source for reading byte data from a file. More... | |
class | FileOutputTarget |
Output target for writing data to a file. More... | |
class | FilterIterator |
Iterator class that allows to filter an underlying iterator by skipping elements that do not satisfy a given predicate. More... | |
class | FunctionCache |
Simple cache, for example for function return values. More... | |
class | GenericInputStream |
Type erasure for iterators, using std::function to eliminate the underlying input type. More... | |
class | GeoCoordinate |
Geographical coordinates in degrees. More... | |
struct | GlmControl |
struct | GlmExtras |
struct | GlmFactor |
struct | GlmFamily |
struct | GlmFreedom |
Internal helper structure for GLMs to calcualte the residual degrees of freedom. More... | |
struct | GlmLink |
struct | GlmOutput |
class | GzipBlockOStream |
Output stream that writes blocks of gzip-compressed data to an underlying wrapped stream, using parallel compression. More... | |
class | GzipBlockOutputTarget |
Output target for writing byte data to a gzip-compressed target in blocks of gzip data. More... | |
class | GzipError |
Exception class thrown by failed gzip/zlib operations. More... | |
class | GzipIFStream |
Input file stream that offers on-the-fly gzip-decompression if needed. More... | |
class | GzipInputSource |
Input source for reading byte data from a gzip/zlib-compressed source. More... | |
class | GzipIStream |
Input stream that offers on-the-fly gzip-decompression if needed. More... | |
class | GzipOFStream |
Out file stream that offers on-the-fly gzip-compression. More... | |
class | GzipOStream |
Output stream that offers on-the-fly gzip-compression. More... | |
class | GzipOutputTarget |
Output target for writing byte data to a gzip/zlib-compressed target. More... | |
struct | hash |
struct | hash< std::tuple< TT... > > |
struct | HeatmapParameters |
class | Histogram |
Histogram class for accumulating and summarizing data. More... | |
class | HistogramAccumulator |
Histogram helper class that collects data and builds a fitting Histogram. More... | |
struct | InfoCompiler |
struct | InfoHardware |
class | InputBuffer |
class | InputStream |
Stream interface for reading data from an InputSource, that keeps track of line and column counters. More... | |
struct | Interval |
Type to store an interval (range) between two numbers, as used in the IntervalTree. More... | |
struct | IntervalClosed |
Helper type to define a closed [] Interval. More... | |
struct | IntervalLeftOpen |
Helper type to define a left open (] Interval. More... | |
struct | IntervalOpen |
Helper type to define an open () Interval. More... | |
struct | IntervalRightOpen |
Helper type to define a right open [) Interval. More... | |
class | IntervalTree |
Interval tree that enables storing and querying intervals, each containing some data. More... | |
class | IntervalTreeIterator |
Iterate the Intervals stored in an IntervalTree. More... | |
class | IntervalTreeNode |
Node in an IntervalTree. More... | |
class | IOError |
Exception class for general input/output errors. More... | |
class | IteratorDeletions |
Take a TwobitVector sequence and iterate over all possible deletions of its values. More... | |
class | IteratorInsertions |
class | IteratorSubstitutions |
class | JsonDocument |
Store a Json value of any kind. More... | |
class | JsonIterator |
Template for a random access iterator for the JsonDocument class. More... | |
class | JsonReader |
Read Json data into a JsonDocument. More... | |
class | JsonWriter |
Write Json data from a JsonDocument. More... | |
struct | KahanSummation |
Tag for tag dispatching the algorithm in CompensatedSum. See there for details. More... | |
struct | KleinSummation |
Tag for tag dispatching the algorithm in CompensatedSum. See there for details. More... | |
class | Kmeans |
struct | KmeansClusteringInfo |
Helper POD that stores the variances and number of data points of each centroid, as well as the distances from all data points to their assigned centroids. More... | |
class | LightweightSemaphore |
struct | LinearFunction |
Data structer to keep the two parameters of a linear function: its slope, and its intercept. More... | |
class | Logging |
Logging class with easy and fast usage. More... | |
struct | LoggingDetails |
POD stuct containing the settings for which information is included with each logging message. More... | |
class | LoggingScopeLevel |
Class that sets the Logging Level to a value von construction and set it back on destruction. This is used by the log scope level macro. More... | |
class | Matrix |
class | MatrixCol |
View into a Matrix column. More... | |
class | MatrixReader |
class | MatrixRow |
View into a Matrix row. More... | |
class | MatrixSimpleReader |
class | MatrixWriter |
class | MD5 |
Calculate MD5 hashes for strings and files. More... | |
struct | MeanStddevPair |
Store a mean and a standard deviation value. More... | |
struct | MinMaxPair |
Store a pair of min and max values. More... | |
class | Moments |
Compute running mean and variance for an input. More... | |
class | MruCache |
Most Recently Used Cache. More... | |
class | MultiFuture |
Helper class to facilitate waiting for and/or getting the results of multiple futures at once. More... | |
struct | NaturalGreater |
Functor class to compare to strings with natural "human" sorting, see compare_natural(). More... | |
struct | NaturalLess |
Functor class to compare to strings with natural "human" sorting, see compare_natural(). More... | |
struct | NeumaierSummation |
Tag for tag dispatching the algorithm in CompensatedSum. See there for details. More... | |
class | NexusBlock |
class | NexusDocument |
class | NexusTaxa |
class | NexusTrees |
class | NexusWriter |
struct | nullopt_t |
Type for nullopt. More... | |
class | Optional |
Simplistic optional: requires T to be default constructible, copyable. More... | |
class | Options |
Simple Options class for application-wide configuration and settings. More... | |
struct | PcaData |
Helper stucture that collects the output of principal_component_analysis(). More... | |
class | ProactiveFuture |
Wrapper around std::future that implements (pro-)active waiting, i.e., work stealing. More... | |
struct | ProducerToken |
struct | Quartiles |
Store the values of quartiles: q0 == min , q1 == 25% , q2 == 50% , q3 == 75% , q4 == max . More... | |
class | Range |
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops. More... | |
class | RangeMinimumQuery |
Class that allows to efficiently find the index of the minimum element within an interval of an array of integer values. More... | |
class | ResourceLogger |
class | SequentialOutputBuffer |
Buffer structure for output to be produced in a well-defined sequential order. More... | |
class | Serializer |
class | SHA1 |
Calculate SHA1 hashes for strings and files. More... | |
class | SHA256 |
Calculate SHA256 hashes for strings and files. More... | |
class | StreamInputSource |
Input source for reading byte data from an istream. More... | |
class | StreamOutputTarget |
Output target for writing data to a stream. More... | |
class | StrictFStream |
Stream that defines a strict wrapper around std::fstream. More... | |
struct | StrictFStreamHolder |
Helper class template for managing the construction order between stream classes. More... | |
class | StrictIFStream |
Stream that defines a strict wrapper around std::ifstream. More... | |
class | StrictOFStream |
Stream that defines a strict wrapper around std::ofstream. More... | |
class | StringInputSource |
Input source for reading byte data from a string. More... | |
class | StringOutputTarget |
Output target for writing data to a string. More... | |
class | Style |
Simple text style class for colorized and bold output to a terminal. More... | |
struct | SvgAxisSettings |
struct | SvgBox |
struct | SvgCircle |
struct | SvgColorBarSettings |
class | SvgDefinitions |
class | SvgDocument |
struct | SvgDrawingOptions |
struct | SvgEllipse |
struct | SvgFill |
struct | SvgFont |
struct | SvgGradientLinear |
struct | SvgGradientStop |
struct | SvgGroup |
struct | SvgImage |
struct | SvgLine |
struct | SvgMargin |
struct | SvgMatrixSettings |
class | SvgObject |
struct | SvgPath |
struct | SvgPoint |
struct | SvgPolygon |
struct | SvgPolyline |
struct | SvgRect |
struct | SvgSize |
struct | SvgStroke |
struct | SvgText |
struct | SvgTransform |
struct | SvgUse |
class | SynchronousReader |
Read bytes from an InputSource into a char buffer . More... | |
class | Table |
struct | TableLayout |
class | ThreadCriticalSection |
Helper class to define a critical section. More... | |
class | ThreadPool |
Thread pool for distributed work. More... | |
class | ThreadsafeQueue |
Thread-safe queue. More... | |
struct | Tickmarks |
Helper class to find "nice" tickmark intervals for creating scales and axes. More... | |
class | TransformIterator |
Iterator class that allows to transform an underlying iterator by applying a function to each element before dereferencing. More... | |
struct | TridiagonalDecompositionData |
Helper structure used for the eigenvalue decomposition in reduce_to_tridiagonal_matrix() and tridiagonal_ql_algorithm(). See there for details. More... | |
class | TwobitVector |
class | XmlComment |
class | XmlDocument |
class | XmlElement |
class | XmlMarkup |
class | XmlValue |
class | XmlWriter |
Write Xml data. More... | |
Functions | |
template<typename T > | |
constexpr T | abs_diff (T const &lhs, T const &rhs) |
Calculate the absolute differenence between two values. More... | |
template<typename InputStream > | |
void | affirm_char_or_throw (InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone) |
Lexing function that checks whether the current char from the stream equals the provided one. More... | |
template<typename InputStream > | |
void | affirm_char_or_throw (InputStream &source, std::function< bool(char)> criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone) |
Lexing function that checks whether the current char from the stream fulfills the provided criterion. More... | |
template<class ForwardIterator > | |
double | aitchison_norm (ForwardIterator first, ForwardIterator last) |
Calculate the Aitchison norm of a range of positive numbers. More... | |
double | aitchison_norm (std::vector< double > const &vec) |
Calculate the Aitchison norm of a std::vector of double elements. More... | |
bool | almost_equal_relative (double lhs, double rhs, double max_rel_diff=std::numeric_limits< double >::epsilon()) |
Check whether two doubles are almost equal, using a relative epsilon to compare them. More... | |
template<class ForwardIterator > | |
double | arithmetic_mean (ForwardIterator first, ForwardIterator last) |
Calculate the arithmetic mean of a range of numbers. More... | |
double | arithmetic_mean (std::vector< double > const &vec) |
Calculate the arithmetic mean of a std::vector of double elements. More... | |
template<typename T > | |
void | ascending (T &f, T &s) |
Sort two values in ascending order, inplace. More... | |
template<class T > | |
T | base64_decode_ (std::string const &input) |
std::string | base64_decode_string (std::string const &input) |
std::vector< std::uint8_t > | base64_decode_uint8 (std::string const &input) |
std::string | base64_encode (std::string const &input, size_t line_length) |
std::string | base64_encode (std::vector< std::uint8_t > const &input, size_t line_length) |
template<class T > | |
std::string | base64_encode_ (T const &input, size_t line_length) |
template<class ForwardIt , class T , class Compare = std::less<T>> | |
ForwardIt | binary_find (ForwardIt first, ForwardIt last, const T &value, Compare comp={}) |
Binary search on a sorted/partitioned range, returns an iterator to the element if found. More... | |
double | binomial_coefficient (size_t n, size_t k) |
Compute the binomial coefficient, that is n choose k , for two integer numbers, for large numbers. More... | |
void | binomial_coefficient_check_n_k_ (size_t n, size_t k) |
Local helper function to check that n and k are valid for a binomial coefficient. More... | |
size_t | binomial_coefficient_int (size_t n, size_t k) |
Compute the binomial coefficient, that is n choose k , for two integer numbers. More... | |
double | binomial_distribution (size_t k, size_t n, double p) |
Compute the probability mass function for a binomial distribution. More... | |
std::string | bitstring (TwobitVector const &vec) |
Return a string with a bit-representation of a TwobitVector. More... | |
std::string | bitstring (TwobitVector::WordType const &vec) |
Return a string with a bit-representation of a TwobitVector::WordType. More... | |
Bitvector | bitwise_and (Bitvector const &lhs, Bitvector const &rhs, bool use_larger=false) |
Take the bitwise and of two Bitvectors of potentially different size. More... | |
Bitvector | bitwise_or (Bitvector const &lhs, Bitvector const &rhs, bool use_larger=false) |
Take the bitwise or of two Bitvectors of potentially different size. More... | |
Bitvector | bitwise_xor (Bitvector const &lhs, Bitvector const &rhs, bool use_larger=false) |
Take the bitwise xor of two Bitvectors of potentially different size. More... | |
static void | build_path_base_swap_ (std::string &path, const std::string &newbase) |
constexpr bool | char_match_ci (char c1, char c2) noexcept |
Return whether two chars are the same, case insensitive, and ASCII-only. More... | |
std::string | char_to_hex (char c, bool full=true) |
Return the name and hex representation of a char . More... | |
std::string | char_to_hex (unsigned char c, bool full=true) |
Return the name and hex representation of a char , given as an unsigned char . More... | |
static std::string | chdir_getcwd_ (std::string const &dir) |
static void | check_mode_ (std::string const &filename, std::ios_base::openmode mode) |
static void | check_open_ (std::ios *s_p, std::string const &filename, std::ios_base::openmode mode) |
static void | check_peek_ (std::istream *is_p, std::string const &filename, std::ios_base::openmode mode) |
double | circumference (double radius) |
template<class ForwardIterator > | |
void | closure (ForwardIterator first, ForwardIterator last) |
Calculate the closure of a range of numbers. More... | |
void | closure (std::vector< double > &vec) |
Calculate the closure of a std::vector of double elements. More... | |
double | coefficient_of_variation (MeanStddevPair const &ms) |
Calculate the index of dispersion. More... | |
std::vector< double > | coefficient_of_variation (std::vector< MeanStddevPair > const &ms) |
Calculate the index of dispersion. More... | |
Color | color_from_bytes (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Create a Color given three or four values in the range [ 0, 255 ] for each of the components red, green and blue, and optionally alpha. More... | |
Color | color_from_hex (std::string const &hex_color, std::string const &prefix="#") |
Create a Color given a hex color string in the format "#003366[ff]". More... | |
Color | color_from_name (std::string const &name) |
Return the color represented by the given name, which is (currently) a shortcut for color_from_name_web() and color_from_name_xkcd(). More... | |
Color | color_from_name_lego (std::string const &name) |
Retrieve a named LEGO color by name. More... | |
Color | color_from_name_web (std::string const &name) |
Retrieve a named web color by name. More... | |
Color | color_from_name_xkcd (std::string const &name) |
Retrieve a named xkcd color by name. More... | |
std::vector< Color > const & | color_list_accent () |
Color palette accent . More... | |
std::vector< Color > const & | color_list_blues () |
Color palette blues . More... | |
std::vector< Color > const & | color_list_brbg () |
Color palette brbg . More... | |
std::vector< Color > const & | color_list_bugn () |
Color palette bugn . More... | |
std::vector< Color > const & | color_list_bupu () |
Color palette bupu . More... | |
std::vector< Color > const & | color_list_bupubk () |
Color Palette bupubk . More... | |
std::vector< Color > const & | color_list_dark2 () |
Color palette dark2 . More... | |
std::vector< Color > const & | color_list_diverging (ColorListDiverging palette) |
std::vector< Color > const & | color_list_diverging (std::string const &palette) |
std::vector< std::string > | color_list_diverging_names () |
std::vector< Color > const & | color_list_gnbu () |
Color palette gnbu . More... | |
std::vector< Color > const & | color_list_greens () |
Color palette greens . More... | |
std::vector< Color > const & | color_list_greys () |
Color palette greys . More... | |
std::vector< Color > const & | color_list_heat () |
Color palette heat . More... | |
std::vector< Color > const & | color_list_inferno () |
Color palette inferno . More... | |
std::vector< Color > const & | color_list_magma () |
Color palette magma . More... | |
std::vector< Color > const & | color_list_misc (ColorListMisc palette) |
std::vector< Color > const & | color_list_misc (std::string const &palette) |
std::vector< std::string > | color_list_misc_names () |
std::vector< Color > const & | color_list_nextstrain () |
Color palette from the the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov. More... | |
std::vector< Color > | color_list_nextstrain (size_t n) |
Color palette from the the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov. More... | |
std::vector< Color > const & | color_list_oranges () |
Color palette oranges . More... | |
std::vector< Color > const & | color_list_orrd () |
Color palette orrd . More... | |
std::vector< Color > const & | color_list_paired () |
Color palette paired . More... | |
std::vector< Color > const & | color_list_pastel1 () |
Color palette pastel1 . More... | |
std::vector< Color > const & | color_list_pastel2 () |
Color palette pastel2 . More... | |
std::vector< Color > const & | color_list_piyg () |
Color palette piyg . More... | |
std::vector< Color > const & | color_list_plasma () |
Color palette plasma . More... | |
std::vector< Color > const & | color_list_prgn () |
Color palette prgn . More... | |
std::vector< Color > const & | color_list_pubu () |
Color palette pubu . More... | |
std::vector< Color > const & | color_list_pubugn () |
Color palette pubugn . More... | |
std::vector< Color > const & | color_list_puor () |
Color palette puor . More... | |
std::vector< Color > const & | color_list_purd () |
Color palette purd . More... | |
std::vector< Color > const & | color_list_purples () |
Color palette purples . More... | |
std::vector< Color > const & | color_list_qualitative (ColorListQualitative palette) |
std::vector< Color > const & | color_list_qualitative (std::string const &palette) |
std::vector< std::string > | color_list_qualitative_names () |
std::vector< Color > const & | color_list_rdbu () |
Color palette rdbu . More... | |
std::vector< Color > const & | color_list_rdgy () |
Color palette rdgy . More... | |
std::vector< Color > const & | color_list_rdpu () |
Color palette rdpu . More... | |
std::vector< Color > const & | color_list_rdylbu () |
Color palette rdylbu . More... | |
std::vector< Color > const & | color_list_rdylgn () |
Color palette rdylgn . More... | |
std::vector< Color > const & | color_list_reds () |
Color palette reds . More... | |
std::vector< Color > const & | color_list_sequential (ColorListSequential palette) |
std::vector< Color > const & | color_list_sequential (std::string const &palette) |
std::vector< std::string > | color_list_sequential_names () |
std::vector< Color > const & | color_list_set1 () |
Color palette set1 . More... | |
std::vector< Color > const & | color_list_set2 () |
Color palette set2 . More... | |
std::vector< Color > const & | color_list_set3 () |
Color palette set3 . More... | |
std::vector< Color > const & | color_list_spectral () |
Color palette spectral . More... | |
std::vector< Color > const & | color_list_viridis () |
Color palette viridis . More... | |
std::vector< Color > const & | color_list_ylgn () |
Color palette ylgn . More... | |
std::vector< Color > const & | color_list_ylgnbu () |
Color palette ylgnbu . More... | |
std::vector< Color > const & | color_list_ylorbr () |
Color palette ylorbr . More... | |
std::vector< Color > const & | color_list_ylorrd () |
Color palette ylorrd . More... | |
std::vector< Color > | color_palette_lego () |
std::vector< Color > | color_palette_web () |
std::vector< Color > | color_palette_xkcd () |
std::map< double, Color > | color_stops (ColorMap const &map, ColorNormalization const &norm) |
std::map< double, Color > | color_stops (ColorMap const &map, ColorNormalizationBoundary const &norm) |
std::map< double, Color > | color_stops (ColorMap const &map, ColorNormalizationDiverging const &norm) |
std::map< double, Color > | color_stops (ColorMap const &map, ColorNormalizationLinear const &norm) |
std::map< double, Color > | color_stops (ColorMap const &map, ColorNormalizationLogarithmic const &norm) |
std::map< double, std::string > | color_tickmarks (ColorNormalization const &norm, size_t num_ticks) |
std::map< double, std::string > | color_tickmarks (ColorNormalizationBoundary const &norm, size_t num_ticks) |
std::map< double, std::string > | color_tickmarks (ColorNormalizationDiverging const &norm, size_t num_ticks) |
std::map< double, std::string > | color_tickmarks (ColorNormalizationLinear const &norm, size_t num_ticks) |
std::map< double, std::string > | color_tickmarks (ColorNormalizationLogarithmic const &norm, size_t num_ticks) |
std::string | color_to_hex (Color const &c, std::string const &prefix="#", bool uppercase=false, bool with_alpha=false) |
Return a hex string representation of a Color in the format "#003366[ff]". More... | |
constexpr std::size_t | combine_hashes (std::size_t h1, std::size_t h2) |
Combine two hash values. More... | |
constexpr std::size_t | combine_hashes_32 (std::size_t h1, std::size_t h2) |
constexpr std::size_t | combine_hashes_64 (std::size_t h1, std::size_t h2) |
int | compare_natural (std::string const &lhs, std::string const &rhs) |
Compare two strings with natural human sorting, that is "A1", "A2", "A100", instead of the standard sort by ASCII value "A1", "A100", "A2". More... | |
template<typename T , typename U > | |
constexpr int | compare_threeway (T lhs, U rhs) |
Three-way comparison (spaceship operator) for C++ <20. More... | |
template<class C , class T > | |
bool | contains (const C &v, const T &x) |
Returns whether a container object has a certain element. More... | |
bool | contains_ci (std::vector< std::string > const &haystack, std::string const &needle) |
Return whether a vector of strings contains a given string, case insensitive. More... | |
bool | contains_ci_alnum (std::vector< std::string > const &haystack, std::string const &needle) |
Return whether a vector of strings contains a given string, case insensitive, and ignoring all non-alphanumerical characters. More... | |
template<class C > | |
bool | contains_duplicates (C const &v) |
Return whether a container contains duplicates. More... | |
template<typename T > | |
T | convert_from_string (std::string const &str, bool trim=false) |
Generic conversion from string to any data type that is supported by std::stringsteam operator >> . More... | |
template<> | |
double | convert_from_string< double > (std::string const &str, bool trim) |
Specialization of the generic conversion function for double , which also takes nan and inf into account. More... | |
template<> | |
std::string | convert_from_string< std::string > (std::string const &str, bool trim) |
Specialization of the generic conversion function for std::string . More... | |
GeoCoordinate | convert_geo_coordinate (std::string const &coordinate) |
Parse a string of geographic coordinates. More... | |
GeoCoordinate | convert_geo_coordinate (std::string const &latitude, std::string const &longitude) |
Parse strings of geographic coordinates. More... | |
static double | convert_single_geo_coordinate_ (std::string const &h1, std::string const &d, std::string const &m, std::string const &s, std::string const &h2, GeoCoordinateComponent component) |
Local helper function that takes parts of the regex matches and converts them to double. More... | |
void | convert_to_bool (Dataframe &df, size_t col_index) |
void | convert_to_bool (Dataframe &df, std::string const &col_name) |
template<typename ForwardIterator > | |
std::vector< bool > | convert_to_bool (ForwardIterator first, ForwardIterator last, size_t size=0) |
bool | convert_to_bool (std::string const &str) |
Convert a string to bool, return the result, and throw an exception when the conversion was not successful. More... | |
bool | convert_to_bool (std::string const &str, bool &result) |
Convert a string to bool, store the result in result , and return whether the conversion as successful. More... | |
template<typename ForwardIterator > | |
std::vector< double > | convert_to_bool_double (ForwardIterator first, ForwardIterator last, size_t size=0) |
double | convert_to_bool_double (std::string const &str) |
Convert a string to bool, but return it as a double, and throw an exception when the conversion was not successful. More... | |
bool | convert_to_bool_double (std::string const &str, double &result) |
Convert a string to bool, but store the result as a double in result , and return whether the conversion as successful. More... | |
void | convert_to_double (Dataframe &df, size_t col_index) |
void | convert_to_double (Dataframe &df, std::string const &col_name) |
template<typename ForwardIterator > | |
std::vector< double > | convert_to_double (ForwardIterator first, ForwardIterator last, size_t size=0) |
double | convert_to_double (std::string const &str) |
Convert a string to double, return the result, and throw an exception when the conversion was not successful. More... | |
bool | convert_to_double (std::string const &str, double &result) |
Convert a string to double, store the result in result , and return whether the conversion as successful. More... | |
template<typename T , class F > | |
bool | convert_to_numeric_ (std::string const &str, T &result, T initial, F conversion) |
static std::vector< Color > | convert_to_palette_ (NamedColorList const &list) |
Local helper function to convert a list of byte colors into a proper Color vector. More... | |
template<typename ForwardIterator > | |
std::vector< long long > | convert_to_signed_integer (ForwardIterator first, ForwardIterator last, size_t size=0) |
long long | convert_to_signed_integer (std::string const &str) |
Convert a string to signed integer, return the result, and throw an exception when the conversion was not successful. More... | |
bool | convert_to_signed_integer (std::string const &str, long long &result) |
Convert a string to signed integer, store the result in result , and return whether the conversion as successful. More... | |
template<typename ForwardIterator > | |
std::vector< std::tm > | convert_to_tm (ForwardIterator first, ForwardIterator last, size_t size=0) |
Convert a list of std::string to std::tm date/time objects, if possible. Throw otherwise. More... | |
template<typename ForwardIterator > | |
std::vector< std::tm > | convert_to_tm (ForwardIterator first, ForwardIterator last, std::string const &format, size_t size=0) |
Convert a list of std::string to std::tm date/time objects, if possible. Throw otherwise. More... | |
template<typename ForwardIterator > | |
std::vector< std::tm > | convert_to_tm (ForwardIterator first, ForwardIterator last, std::string const &format, std::string const &locale, size_t size=0) |
Convert a list of std::string to std::tm date/time objects, if possible. Throw otherwise. More... | |
std::tm | convert_to_tm (std::string const &str) |
Convert a std::string to a std::tm date/time object, if possible. Throw otherwise. More... | |
std::tm | convert_to_tm (std::string const &str, std::string const &format) |
Convert a std::string to a std::tm date/time object, if possible. Throw otherwise. More... | |
std::tm | convert_to_tm (std::string const &str, std::string const &format, std::string const &locale) |
Convert a std::string to a std::tm date/time object, if possible. Throw otherwise. More... | |
bool | convert_to_tm_ (std::string const &str, std::string const &format, std::string const &locale, std::tm &t) |
Local helper function that does the heavy load of time conversion. More... | |
template<typename S , typename T > | |
void | convert_to_type_ (Dataframe &df, size_t col_index) |
template<typename T > | |
void | convert_to_type_ (Dataframe &df, size_t col_index) |
template<typename ForwardIterator > | |
std::vector< unsigned long long > | convert_to_unsigned_integer (ForwardIterator first, ForwardIterator last, size_t size=0) |
unsigned long long | convert_to_unsigned_integer (std::string const &str) |
Convert a string to unsigned integer, return the result, and throw an exception when the conversion was not successful. More... | |
bool | convert_to_unsigned_integer (std::string const &str, unsigned long long &result) |
Convert a string to unsigned integer, store the result in result , and return whether the conversion as successful. More... | |
Matrix< double > | correlation_matrix (Matrix< double > const &data) |
Calculate the correlation Matrix of a given data Matrix. More... | |
template<class ForwardIterator > | |
std::pair< size_t, size_t > | count_finite_elements (ForwardIterator first, ForwardIterator last) |
Count the number of finite elements in a range of double values. More... | |
size_t | count_substring_occurrences (std::string const &str, std::string const &sub) |
Return the number of (possibly overlapping) occurrences of a substring in a string. More... | |
Matrix< double > | covariance_matrix (Matrix< double > const &data) |
Calculate the covariance Matrix of a given data Matrix. More... | |
constexpr double | cubed (double x) |
Cube of a number. More... | |
std::string | current_date () |
Returns the current date as a string in the format "2014-12-31". More... | |
std::string | current_path () |
Return the current (working) directory, simiar to getcwd(). More... | |
static std::string | current_path_getcwd_ () |
static std::string | current_path_unix_ () |
std::string | current_time () |
Returns the current time as a string in the format "13:37:42". More... | |
char | deescape (char c) |
Return the de-escaped char for a backslash-escaped char. More... | |
std::string | deescape (std::string const &text) |
Return a string where backslash-escaped characters are transformed into their respective string form. More... | |
template<typename T > | |
void | descending (T &f, T &s) |
Sort two values in descending order, inplace. More... | |
bool | detect_OS_AVX512_ () |
bool | detect_OS_AVX_ () |
bool | detect_OS_x64_ () |
void | dir_create (std::string const &path, bool with_parents=true) |
Create a directory. More... | |
bool | dir_exists (std::string const &dir) |
Return true iff the directory exists. More... | |
std::vector< std::string > | dir_list_contents (std::string const &dir, bool full_path=false, std::string const ®ex="") |
Get a list of files and directories in a directory. More... | |
static std::vector< std::string > | dir_list_contents_ (std::string const &dir, bool full_path, std::string const ®ex, std::function< bool(std::string const &)> condition) |
std::vector< std::string > | dir_list_directories (std::string const &dir, bool full_path=false, std::string const ®ex="") |
Get a list of directories in a directory. More... | |
std::vector< std::string > | dir_list_files (std::string const &dir, bool full_path=false, std::string const ®ex="") |
Get a list of files in a directory. More... | |
std::string | dir_normalize_path (std::string const &path) |
Normalize a dir name, i.e., make sure that the given path ends with exaclty one slash. More... | |
TableLayout | double_frame (bool condensed) |
TableLayout | double_grid (bool condensed) |
double | earth_movers_distance (const Histogram &h1, const Histogram &h2, bool norm) |
bool | ends_with (std::string const &text, std::string const &suffix) |
Return whether a string ends with another string, i.e., check for a suffix . More... | |
bool | ends_with (std::string const &text, std::string const &suffix, std::string &prefix) |
Return whether a string ends with another string, i.e., check for a suffix . More... | |
bool | ends_with_ci (std::string const &text, std::string const &suffix) |
Return whether a string ends with another string, i.e., check for a suffix, case insensitive. More... | |
bool | ends_with_ci (std::string const &text, std::string const &suffix, std::string &prefix) |
Return whether a string ends with another string, i.e., check for a suffix, case insensitive. More... | |
bool | ends_with_ci_alnum (std::string const &text, std::string const &suffix) |
Return whether a string ends with another string (suffix), comparing case-independent, and ignoring all non-alphanumerical characters. More... | |
bool | ends_with_ci_alnum (std::string const &text, std::string const &suffix, std::string &prefix, bool trim_prefix=false) |
Return whether a string ends with another string (suffix), comparing case-independent, and ignoring all non-alphanumerical characters. More... | |
bool | equal_ranges (Histogram const &lhs, Histogram const &rhs) |
bool | equals_ci (std::string const &lhs, std::string const &rhs) |
Compare two strings, case insensitive. More... | |
bool | equals_ci_alnum (std::string const &lhs, std::string const &rhs) |
Compare two strings, case insensitive, and ignoring all non-alphanumerical characters. More... | |
template<class Container , class UnaryPredicate > | |
void | erase_if (Container &c, UnaryPredicate p) |
Erases all elements from the container that satisfy a given predicate. An element is erased, if the predicate evaluates to true for it. The predicate needs to have a signature similar to (T const&)->bool. More... | |
std::string | escape (std::string const &text) |
Return a string where special chars are replaces by their escape sequence. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | euclidean_distance (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b) |
Calculate the Euclidean norm (L2 norm) distance between two (mathematical) vectors. More... | |
double | euclidean_distance (std::vector< double > const &vec_a, std::vector< double > const &vec_b) |
Calculate the Euclidean norm (L2 norm) distance between two vectors of double elements. More... | |
Matrix< double > | euclidean_distance_matrix (Matrix< double > const &data) |
Calculate the pairwise euclidean distance matrix between the rows of a given matrix. More... | |
template<class ForwardIterator > | |
double | euclidean_norm (ForwardIterator first, ForwardIterator last) |
Calculate the Euclidean norm (L2 norm) of a range of numbers. More... | |
double | euclidean_norm (std::vector< double > const &vec) |
Calculate the Euclidean norm (L2 norm) of a std::vector of double elements. More... | |
TableLayout | extended_frame (bool condensed) |
TableLayout | extended_grid (bool condensed) |
void | file_append (std::string const &content, std::string const &filename, bool create_dirs=true) |
Append the content of a string to a file. More... | |
std::string | file_basename (std::string const &filename) |
Remove directory name from file name if present. More... | |
std::string | file_basename (std::string const &filename, std::vector< std::string > const &remove_extensions) |
Remove the directory name from a file name if present, and remove a list of given extensions. More... | |
bool | file_exists (std::string const &filename) |
Return true iff the file exists (and is in fact a file, and not, e.g., a directory). More... | |
std::string | file_extension (std::string const &filename) |
Return the extension name of a file. More... | |
std::string | file_filename (std::string const &filename) |
Remove extension if present. More... | |
std::unordered_map< std::string, std::string > | file_info (std::string const &filename) |
Return information about a file. More... | |
bool | file_is_readable (std::string const &filename) |
Return whether a file is readable. More... | |
bool | file_is_readable (std::string const &filename, std::string &err_str) |
Return whether a file is readable, and potentially store the error message. More... | |
void | file_output_stream (std::string const &file_name, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out, bool create_dirs=true) |
Helper function to obtain an output stream to a file. More... | |
std::string | file_path (std::string const &filename) |
Return the path leading to a file. More... | |
std::string | file_read (std::string const &filename, bool detect_compression=true) |
Return the contents of a file as a string. More... | |
std::vector< std::string > | file_read_lines (std::string const &filename, bool detect_compression=true) |
Return the contents of a file as a vector of strings, one entry for each line. More... | |
size_t | file_size (std::string const &filename) |
Return the size of a file. More... | |
void | file_write (std::string const &content, std::string const &filename, bool create_dirs=true) |
Write the content of a string to a file. More... | |
std::vector< size_t > | filter_constant_columns (Matrix< double > &data, double epsilon=1e-5) |
Filter out columns that have nearly constant values, measured using an epsilon . More... | |
template<class ForwardIterator > | |
double | finite_maximum (ForwardIterator first, ForwardIterator last) |
Return the maximum of a range of double values. More... | |
template<class ForwardIterator > | |
double | finite_minimum (ForwardIterator first, ForwardIterator last) |
Return the minimum of a range of double values. More... | |
template<class ForwardIterator > | |
MinMaxPair< double > | finite_minimum_maximum (ForwardIterator first, ForwardIterator last) |
Return the minimum and the maximum of a range of double values. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
std::pair< std::vector< double >, std::vector< double > > | finite_pairs (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b) |
Helper function that cleans two ranges of double of the same length from non-finite values. More... | |
double | fisher_transformation (double correlation_coefficient) |
Apply Fisher z-transformation to a correlation coefficient. More... | |
std::vector< double > | fisher_transformation (std::vector< double > const &correlation_coefficients) |
Apply Fisher z-transformation to a vector of correlation coefficients. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
void | for_each_finite_pair (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b, std::function< void(double value_a, double value_b)> execute) |
Iterate two ranges of double values in parallel, and execute a function for each pair of values from the two ranges where both values are finite. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | fraction_of_variance_unexplained (ForwardIteratorA first_x, ForwardIteratorA last_x, ForwardIteratorB first_y, ForwardIteratorB last_y, LinearFunction lin_fct) |
Calculate the fraction of unexplained variance resulting from a linear fit of the input variables. More... | |
std::shared_ptr< BaseInputSource > | from_file (std::string const &file_name, bool detect_compression=true) |
Obtain an input source for reading from a file. More... | |
template<typename InputIterator > | |
std::vector< std::shared_ptr< BaseInputSource > > | from_files (InputIterator first, InputIterator last, bool detect_compression=true) |
Obtain a set of input sources for reading from files. More... | |
std::vector< std::shared_ptr< BaseInputSource > > | from_files (std::vector< std::string > const &file_names, bool detect_compression=true) |
Obtain a set of input sources for reading from files. More... | |
TwobitVector | from_nucleic_acids (std::string const &sequence) |
Turn a string of nucleic acids into a TwobitVector. More... | |
std::shared_ptr< BaseInputSource > | from_stdin () |
Obtain an input source for reading from standard input (i.e., stdin or cin). More... | |
std::shared_ptr< BaseInputSource > | from_stream (std::istream &input_stream) |
Obtain an input source for reading from a stream. More... | |
std::shared_ptr< BaseInputSource > | from_string (std::string const &input_string) |
Obtain an input source for reading from a string. More... | |
template<typename InputIterator > | |
std::vector< std::shared_ptr< BaseInputSource > > | from_strings (InputIterator first, InputIterator last) |
Obtain a set of input sources for reading from strings. More... | |
std::vector< std::shared_ptr< BaseInputSource > > | from_strings (std::vector< std::string > const &input_strings) |
Obtain a set of input sources for reading from strings. More... | |
double | geo_distance (GeoCoordinate const &c1, GeoCoordinate const &c2) |
Calculate the distance (in km) between two points on Earth. More... | |
template<class ForwardIterator > | |
double | geometric_mean (ForwardIterator first, ForwardIterator last) |
Calculate the geometric mean of a range of positive numbers. More... | |
double | geometric_mean (std::vector< double > const &vec) |
Calculate the geometric mean of a std::vector of double elements. More... | |
static std::string | get_attribute_string_ (Style const &s) |
Internal helper function that returns the attribute string of a Style based on its properties. More... | |
static std::array< std::pair< std::string, std::string >, 17 >::const_iterator | get_background_color_iterator (std::string name) |
Internal helper function that returns an iterator into the background color list. More... | |
static NamedColorList::const_iterator | get_color_list_iterator_ (NamedColorList const &list, std::string name) |
Internal helper function. More... | |
size_t | get_core_id_ (std::string const &cpu_path) |
std::string | get_cpu_model_ () |
void | get_cpuid_ (int32_t out[4], int32_t eax, int32_t ecx) |
static std::array< std::pair< std::string, std::string >, 17 >::const_iterator | get_foreground_color_iterator (std::string name) |
Internal helper function that returns an iterator into the foreground color list. More... | |
size_t | get_memtotal_ () |
size_t | get_numa_node_id_ (std::string const &cpu_path) |
int | get_physical_core_count_ (size_t n_cpu) |
std::string | get_vendor_string_ () |
std::vector< double > | glm_coefficients (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmLink const &link, GlmOutput const &output) |
Compute the model coefficients of a glm_fit(). More... | |
std::vector< double > | glm_coefficients (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmOutput const &output) |
Compute the model coefficients of a glm_fit(). More... | |
Matrix< double > | glm_convert_dataframe (Dataframe const &df) |
Matrix< double > | glm_convert_dataframe (Dataframe const &df, std::vector< std::string > row_order) |
std::vector< double > | glm_estimate_betas (GlmOutput const &output) |
Compute the beta estimates resulting from a glm_fit(). More... | |
std::pair< std::vector< double >, std::vector< double > > | glm_estimate_betas_and_var_covar (GlmOutput const &output, std::vector< double > const &meat) |
std::vector< double > | glm_estimate_betas_inv_tri_ (GlmOutput const &output, std::vector< double > const &inv_tri) |
Helper function to compute the betas, given that we have already inverted the tri matrix. More... | |
double | glm_estimate_intercept (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmLink const &link, GlmOutput const &output, std::vector< double > const &betas) |
Compute the intercept resulting from a glm_fit(). More... | |
double | glm_estimate_intercept (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmOutput const &output, std::vector< double > const &betas) |
Compute the intercept resulting from a glm_fit(). More... | |
template<class ForwardIterator > | |
GlmFactor< typename ForwardIterator::value_type > | glm_factor (ForwardIterator first, ForwardIterator last) |
template<class ForwardIterator > | |
GlmFactor< typename ForwardIterator::value_type > | glm_factor (ForwardIterator first, ForwardIterator last, std::vector< typename ForwardIterator::value_type > const &levels) |
template<class ForwardIterator > | |
GlmFactor< typename ForwardIterator::value_type > | glm_factor (ForwardIterator first, ForwardIterator last, std::vector< typename ForwardIterator::value_type > const &levels, std::vector< typename ForwardIterator::value_type > const &exclude) |
Reduce a list of values in the given range to a set of unique factors. More... | |
template<class T > | |
std::vector< size_t > | glm_factor_summary (GlmFactor< T > const &factor) |
Get the number of occurrences of each level in a GlmFactor. More... | |
GlmFamily | glm_family_binomial () |
Binomial family functions. More... | |
GlmFamily | glm_family_gamma () |
Gamma family functions. More... | |
GlmFamily | glm_family_gaussian () |
Gaussian/normal family functions. More... | |
GlmFamily | glm_family_poisson () |
Poisson family functions. More... | |
GlmOutput | glm_fit (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmExtras const &extras={}, GlmControl const &control={}) |
Fit a Generalized Linear Model (GLM) using a linear gaussian model. More... | |
GlmOutput | glm_fit (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmFamily const &family, GlmExtras const &extras={}, GlmControl const &control={}) |
Fit a Generalized Linear Model (GLM). More... | |
GlmOutput | glm_fit (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmFamily const &family, GlmLink const &link, GlmExtras const &extras={}, GlmControl const &control={}) |
Fit a Generalized Linear Model (GLM). More... | |
static void | glm_gaussian_ (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmExtras const &extras, GlmControl const &control, GlmFreedom const &freedom, GlmOutput &result) |
template<class T > | |
Dataframe | glm_indicator_variables (GlmFactor< T > const &factor, std::vector< std::string > const &row_names=std::vector< std::string >{}) |
Turn a GlmFactor into a set of (dummy) indicator variables to be used in regression. More... | |
template<class T > | |
Dataframe | glm_indicator_variables (GlmFactor< T > const &factor, T const &reference_level, std::vector< std::string > const &row_names=std::vector< std::string >{}) |
Turn a GlmFactor into a set of (dummy) indicator variables to be used in regression. More... | |
std::vector< double > | glm_inv_tri_ (std::vector< double > const &tri, size_t M) |
Invert diagonal and unit upper triangular matrices stored as one array. More... | |
static void | glm_irls_ (Matrix< double > const &x_predictors, std::vector< double > const &y_response, GlmFamily const &family, GlmLink const &link, GlmExtras const &extras, GlmControl const &control, GlmOutput &result) |
GlmLink | glm_link_identity () |
Identity link functions. More... | |
GlmLink | glm_link_inverse () |
Inverse link functions. More... | |
GlmLink | glm_link_log () |
Log link functions. More... | |
GlmLink | glm_link_logit () |
Logit link functions. More... | |
Dataframe | glm_prepare_dataframe (Dataframe const &df) |
Dataframe | glm_prepare_dataframe (Dataframe const &df, std::string &report) |
Color | gradient (std::map< double, Color > const &ranges, double value) |
Returns a Color that is created using a color gradient. More... | |
size_t | guess_number_of_threads (bool use_openmp=true, bool use_slurm=true, bool physical_cores=true) |
Make an educated guess on the number of threads to use for multi-threaded functionality. More... | |
template<class ForwardIterator > | |
double | harmonic_mean (ForwardIterator first, ForwardIterator last, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow) |
Calculate the harmonic mean of a range of positive numbers. More... | |
double | harmonic_mean (std::vector< double > const &vec, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow) |
Calculate the harmonic mean of a std::vector of double elements. More... | |
template<typename T > | |
constexpr std::size_t | hash_combine (std::size_t seed, T const &value) |
Combine a seed value (e.g., another hash) with the hash of a given type. More... | |
std::string | hash_hex (std::shared_ptr< BaseInputSource > source, HashingFunctions hash_fct) |
Calculate the hash of an input source, using a given hashing function, and return its hex representation as a string. More... | |
std::string | head (std::string const &text, size_t lines=10) |
Return the first lines of the text. More... | |
Color | heat_gradient (double percentage) |
Return a Color that represents a heat gradient for a given percentage value. More... | |
template<class ColorNorm > | |
Matrix< utils::Color > | heat_map_matrix_range_ (Matrix< double > const &values, HeatmapParameters const ¶meters) |
template<class ColorNorm > | |
Matrix< utils::Color > | heat_map_matrix_range_all_ (Matrix< double > const &values, HeatmapParameters const ¶meters) |
template<class ColorNorm > | |
Matrix< utils::Color > | heat_map_matrix_range_col_ (Matrix< double > const &values, HeatmapParameters const ¶meters) |
template<class ColorNorm > | |
Matrix< utils::Color > | heat_map_matrix_range_row_ (Matrix< double > const &values, HeatmapParameters const ¶meters) |
MinMaxPair< double > | heat_map_matrix_update_min_max_ (MinMaxPair< double > const &min_max, HeatmapParameters const ¶meters) |
size_t | hypergeometric_distribution (size_t n1, size_t n2, size_t t) |
Select a random sample from a hypergeometric distribution. More... | |
size_t | hypergeometric_distribution_gsl (size_t n1, size_t n2, size_t t) |
size_t | hypergeometric_distribution_inversion_mode_ (size_t n, size_t m, size_t N) |
size_t | hypergeometric_distribution_ratio_of_unifoms_ (size_t n, size_t m, size_t N) |
std::string | indent (std::string const &text, std::string const &indentation=" ") |
Indent each line of text with indentation and return the result. More... | |
double | index_of_dispersion (MeanStddevPair const &ms) |
Calculate the index of dispersion. More... | |
std::vector< double > | index_of_dispersion (std::vector< MeanStddevPair > const &ms) |
Calculate the index of dispersion. More... | |
InfoCompiler const & | info_get_compiler () |
Return information about compiler settings and flags. More... | |
InfoHardware const & | info_get_hardware () |
Return information about hardware features. More... | |
size_t | info_get_pid () |
Get the process ID of the current process. More... | |
bool | info_hyperthreads_enabled () |
Try to get whether hyperthreads are enabled in the current system. More... | |
size_t | info_number_of_threads_openmp () |
Get the number of threads as indicated by the OpenMP environment. More... | |
size_t | info_number_of_threads_slurm () |
Get the number of threads as indicated by the SLURM environment. More... | |
long | info_online_cpu_cores () |
size_t | info_physical_core_count () |
Get the number of CPU cores. More... | |
std::unordered_map< std::string, std::string > const & | info_preprocessor_definitions () |
Return a string map with some relevant preprocessor macros. More... | |
std::string | info_print_compiler () |
Print information about compiler settings and flags to a string. More... | |
std::string | info_print_hardware (bool full=false) |
Print information about hardware features to a string. More... | |
double | info_process_current_cpu_usage (bool all_cores=true, bool percent=true) |
Return the CPU usage of the current process. More... | |
size_t | info_process_current_file_count () |
Return the number of files (i.e., file descriptors) that the current process (the process calling this function) has opened at the moment. More... | |
size_t | info_process_current_memory_usage () |
Return the memory currently used by the current process, in bytes. More... | |
size_t | info_process_max_file_count () |
Return the maximum number of files (i.e., file descriptors) that can be opened simultaneously in the current process. More... | |
size_t | info_process_peak_memory_usage () |
Get the peak used memory, in bytes. More... | |
std::string | info_process_print_total_usage () |
Print usage information to a string. More... | |
std::pair< double, double > | info_process_total_cpu_time () |
Get the currently used cpu run time, similar to the Unix time command. More... | |
double | info_process_total_energy_consumption () |
Get energy consumption of the program so far, in Wh. More... | |
bool | info_stderr_is_terminal () |
Return true iff the standard error stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
bool | info_stdin_is_terminal () |
Return true iff the standard input stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
bool | info_stdout_is_terminal () |
Return true iff the standard output stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
double | info_system_current_cpu_usage (bool all_cores=true, bool percent=true) |
Return the CPU usage of the system, across all cores. More... | |
size_t | info_system_current_memory_available () |
Return the memory currently available in the system, in bytes. More... | |
size_t | info_system_current_memory_usage () |
Return the memory currently used across all running processes, in bytes. More... | |
unsigned int | info_task_cpu_cores (bool physical=false) |
std::pair< int, int > | info_terminal_size () |
Return the width and height of the terminal that is used to run the program, in number of columns and lines. More... | |
bool | info_use_avx () |
Assess if it is safe to use AVX features. More... | |
bool | info_use_avx2 () |
Assess if it is safe to use AVX2 features. More... | |
bool | info_use_avx512 () |
Assess if it is safe to use AVX512 features. More... | |
template<typename T > | |
std::vector< T >::iterator | insert_sorted (std::vector< T > &vec, T const &item) |
Insert into a vector vec , sorted by the value of the item . The vector must already be sorted. More... | |
template<typename T , typename Pred > | |
std::vector< T >::iterator | insert_sorted (std::vector< T > &vec, T const &item, Pred pred) |
Insert into a vector vec , sorted by the value of the item , using a predicate. The vector must already be sorted according to the predicate. More... | |
size_t | int_pow (size_t base, size_t exp) |
Calculate the power base^exp for positive integer values. More... | |
Color | interpolate (Color const &color1, Color const &color2, double fraction) |
Linearily interpolate between two Colors. More... | |
constexpr bool | is_alnum (char c) noexcept |
Return whether a char is a letter (a-z or A-Z) or a digit (0-9), ASCII-only. More... | |
constexpr bool | is_alpha (char c) noexcept |
Return whether a char is a letter (a-z or A-Z), ASCII-only. More... | |
constexpr bool | is_ascii (char c) noexcept |
Return whether a char is pure ASCII, that is, in the range [0, 127]. More... | |
template<typename T > | |
constexpr bool | is_ascii (std::false_type, T c) noexcept |
Implementation detail for is_ascii(char). More... | |
template<typename T > | |
constexpr bool | is_ascii (std::true_type, T c) noexcept |
Implementation detail for is_ascii(char). More... | |
constexpr bool | is_blank (char c) noexcept |
Return whether a char is either a space or a tab character. More... | |
bool | is_canonical_link (GlmFamily const &family, GlmLink const &link) |
constexpr bool | is_cntrl (char c) noexcept |
Return whether a char is a control character, according to iscntrl of the cctype> heade but ASCII-only. More... | |
bool | is_color_name (std::string const &name) |
Return true if the name represents one of the named colors offered by genesis, which is (currently) a shortcut for is_color_name_web() and is_color_name_xkcd(). More... | |
bool | is_color_name_lego (std::string const &name) |
Return true iff the given name is a named LEGO color. More... | |
bool | is_color_name_web (std::string const &name) |
Return true iff the given name is a named web color. More... | |
bool | is_color_name_xkcd (std::string const &name) |
Return true iff the given name is a named xkcd color. More... | |
constexpr bool | is_control (char c) noexcept |
Return whether a char is a control character, excluding white spaces, ASCII-only. More... | |
bool | is_convertible_to_bool (Dataframe const &df, size_t col_index) |
bool | is_convertible_to_bool (Dataframe const &df, std::string const &col_name) |
template<typename ForwardIterator > | |
bool | is_convertible_to_bool (ForwardIterator first, ForwardIterator last) |
bool | is_convertible_to_bool (std::string const &str) |
Return whether a string can be converted to bool. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_bool_double (ForwardIterator first, ForwardIterator last) |
bool | is_convertible_to_bool_double (std::string const &str) |
Return whether a string can be converted to bool (and stored as a double). More... | |
bool | is_convertible_to_double (Dataframe const &df, size_t col_index) |
bool | is_convertible_to_double (Dataframe const &df, std::string const &col_name) |
template<typename ForwardIterator > | |
bool | is_convertible_to_double (ForwardIterator first, ForwardIterator last) |
bool | is_convertible_to_double (std::string const &str) |
Return whether a string can be converted to double. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_signed_integer (ForwardIterator first, ForwardIterator last) |
bool | is_convertible_to_signed_integer (std::string const &str) |
Return whether a string can be converted to signed integer. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_tm (ForwardIterator first, ForwardIterator last) |
Return whether a list of std::string is convertible to std::tm date/time objects. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_tm (ForwardIterator first, ForwardIterator last, std::string const &format) |
Return whether a list of std::string is convertible to std::tm date/time objects. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_tm (ForwardIterator first, ForwardIterator last, std::string const &format, std::string const &locale) |
Return whether a list of std::string is convertible to std::tm date/time objects. More... | |
bool | is_convertible_to_tm (std::string const &str) |
Return whether a std::string is convertible to a std::tm date/time object, that is, whether it contains a date/time in a recognizable format. More... | |
bool | is_convertible_to_tm (std::string const &str, std::string const &format) |
Return whether a std::string is convertible to a std::tm date/time object, that is, whether it contains a date/time in a recognizable format. More... | |
bool | is_convertible_to_tm (std::string const &str, std::string const &format, std::string const &locale) |
Return whether a std::string is convertible to a std::tm date/time object, that is, whether it contains a date/time in a recognizable format. More... | |
template<typename ForwardIterator > | |
bool | is_convertible_to_unsigned_integer (ForwardIterator first, ForwardIterator last) |
bool | is_convertible_to_unsigned_integer (std::string const &str) |
Return whether a string can be converted to unsigned integer. More... | |
bool | is_defined (GlmFamily const &family) |
Check whether all necessary values and functors of a GlmFamily are set. More... | |
bool | is_defined (GlmLink const &link) |
Check whether all necessary values and functors of a GlmLink are set. More... | |
constexpr bool | is_digit (char c) noexcept |
Return whether a char is a digit (0-9), ASCII-only. More... | |
bool | is_dir (std::string const &path) |
Return true iff the provided path is a directory. More... | |
bool | is_file (std::string const &path) |
Return true iff the provided path is a (readable) file. More... | |
constexpr bool | is_graph (char c) noexcept |
Return whether a char is a character with graphical representation, according to isgraph of the cctype header, but ASCII-only. More... | |
bool | is_gzip_compressed_file (std::string const &file_name) |
Return whether a given file is gzip-compressed. More... | |
constexpr bool | is_lower (char c) noexcept |
Return whether a char is a lower case letter (a-z), ASCII-only. More... | |
constexpr bool | is_newline (char c) noexcept |
Return whether a char is either a new line or a carriage return character. More... | |
static bool | is_numerical_type_ (Dataframe const &df, size_t col_index) |
constexpr bool | is_other_space (char c) noexcept |
Return whether a char is some other white space charater that is neither space, tab, new line, or carriage return - that is, whether it is a form feed or a vertical tab. More... | |
constexpr bool | is_print (char c) noexcept |
Return whether a char is a printable character, according to isprint of the cctype header, but ASCII-only. More... | |
constexpr bool | is_punct (char c) noexcept |
Return whether a char is a punctuation mark, according to ispunct of the cctype header, but ASCII-only. More... | |
constexpr bool | is_space (char c) noexcept |
Return whether a char is some form of white space charater, so either space, tab, new line, carriage return, form feed, or vertical tab. More... | |
template<typename T > | |
bool | is_square (Matrix< T > const &data) |
Return whether a Matrix is a square matrix, that is, whether its number of rows and number of columns are idetical. More... | |
bool | is_strict_subset (Bitvector const &sub, Bitvector const &super) |
Strict subset. More... | |
bool | is_strict_superset (Bitvector const &super, Bitvector const &sub) |
Strict superset. More... | |
bool | is_subset (Bitvector const &sub, Bitvector const &super) |
Subset or equal. More... | |
bool | is_superset (Bitvector const &super, Bitvector const &sub) |
Superset or equal. More... | |
template<typename T > | |
bool | is_symmetric (Matrix< T > const &data) |
Return whether a Matrix is symmetric, i.e., whether it is square and m[ i, j ] == m[ j, i ] holds for all entries. More... | |
constexpr bool | is_upper (char c) noexcept |
Return whether a char is an upper case letter (A-Z), ASCII-only. More... | |
bool | is_valid_filename (std::string const &filename) |
Check whether a file name is valid. More... | |
bool | is_valid_int_pow (size_t base, size_t exp) |
Return whether the given power can be stored within a size_t . More... | |
constexpr bool | is_xdigit (char c) noexcept |
Return whether a char is a hexadecimal digit (0-9 or A-F or a-f), ASCII-only. More... | |
utils::Range< IteratorDeletions > | iterate_deletions (TwobitVector const &vector) |
utils::Range< IteratorInsertions > | iterate_insertions (TwobitVector const &vector) |
utils::Range< IteratorSubstitutions > | iterate_substitutions (TwobitVector const &vector) |
template<typename C > | |
std::string | join (C const &container, std::string const &delimiter=", ") |
Return a string where the elements of a container v are joined using the string delimiter in between them. More... | |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | join (Interval< DataType, NumericalType, IntervalKind > const &a, Interval< DataType, NumericalType, IntervalKind > const &b) |
Creates a new Interval that contains both intervals and whatever is between. More... | |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | join (Interval< DataType, NumericalType, IntervalKind > const &a, Interval< DataType, NumericalType, IntervalKind > const &b, DataType &&data) |
Creates a new Interval that contains both intervals and whatever is between. More... | |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | join (Interval< DataType, NumericalType, IntervalKind > const &a, Interval< DataType, NumericalType, IntervalKind > const &b, DataType const &data) |
Creates a new Interval that contains both intervals and whatever is between. More... | |
template<typename C , typename std::enable_if< ! std::is_same< typename C::value_type, unsigned char >::value &&! std::is_same< typename C::value_type, signed char >::value >::type * = nullptr> | |
std::ostream & | join (std::ostream &stream, C const &container, std::string const &delimiter=", ") |
Print elements of the given container to the output stream , joining them with the delimiter . More... | |
template<class InputIteratorA , class InputIteratorB > | |
double | kendalls_tau_correlation_coefficient (InputIteratorA first_a, InputIteratorA last_a, InputIteratorB first_b, InputIteratorB last_b, KendallsTauMethod method=KendallsTauMethod::kTauB) |
double | kendalls_tau_correlation_coefficient (std::vector< double > const &x, std::vector< double > const &y, KendallsTauMethod method=KendallsTauMethod::kTauB) |
Compute Kendall's Tau Correlation Coefficient. More... | |
double | kendalls_tau_correlation_coefficient_clean_ (std::vector< double > const &x, std::vector< double > const &y, KendallsTauMethod method) |
Compute Kendall's Tau, expecting clean input without nan values, using Knight's algorithm. More... | |
double | kendalls_tau_correlation_coefficient_naive (std::vector< double > const &x, std::vector< double > const &y, KendallsTauMethod method=KendallsTauMethod::kTauB) |
Compute a simple version of Kendall's Tau Correlation Coefficient. More... | |
size_t | kendalls_tau_count_tau_c_m_ (std::vector< double > const &x, std::vector< double > const &y) |
Helper function to count the number of unique values in both lists, using only those entris that are finite in both. More... | |
template<typename T > | |
size_t | kendalls_tau_count_ties_ (std::vector< T > const &values) |
Helper function to count the number of tied pairs induced by equal values. More... | |
size_t | kendalls_tau_count_ties_sorted_ (std::vector< double > const &values) |
Helper function to count the number of tied pairs induced by equal values, on a sorted input list. More... | |
size_t | kendalls_tau_count_ties_sorted_pairs_rank_ (std::vector< double > const &x, std::vector< double > const &y, std::vector< size_t > const &ranks) |
Helper function to count the number of tied pairs induced by equal values, on two input list with the sorting provided via a rank indexing list. More... | |
size_t | kendalls_tau_count_ties_sorted_rank_ (std::vector< double > const &values, std::vector< size_t > const &ranks) |
Helper function to count the number of tied pairs induced by equal values, on a sorted input list with the sorting provided via a rank indexing list. More... | |
size_t | kendalls_tau_merge_count_ (std::vector< double > &data, std::vector< double > &temp, size_t left, size_t mid, size_t right) |
Helper function for kendalls_tau_correlation_coefficient() to do a merge sort that counts the number of inversions performed. More... | |
double | kendalls_tau_method_ (std::vector< double > const &x, std::vector< double > const &y, size_t const concordant, size_t const discordant, size_t const n, size_t const n0, size_t const n1, size_t const n2, size_t const n3, KendallsTauMethod method) |
Given counts of concordant and discordant pairs, compute the final value, applying the requested adjustments. More... | |
size_t | kendalls_tau_sort_and_count_ (std::vector< double > &data, std::vector< double > &temp, size_t left, size_t right) |
Helper function for kendalls_tau_correlation_coefficient() to sort a list using merge sort, while counting the number of inversions performed. More... | |
double | log_binomial_coefficient (size_t n, size_t k) |
Compute the logarithm (base e) of the binomial coefficient, that is n choose k , for two integer numbers, for large numbers. More... | |
double | log_binomial_distribution (size_t k, size_t n, double p) |
Compute the logarithm (base e) of the probability mass function for a binomial distribution. More... | |
double | log_factorial (size_t n) |
Return the logarithm (base e) of the factorial of n , that is log(n!) . More... | |
std::vector< double > | log_factorial_lookup_generator_ () |
Helper function to generate above lookup table. More... | |
long | logging_progress_value (long value=-1) |
Hack function to make sure that the value arugment in LOG_PROG is only evaluated once. More... | |
std::vector< bool > | make_bool_vector_from_indices (std::vector< size_t > const &indices, size_t size=0) |
Helper function to create a bool vector from a set of indices to be set to true . More... | |
template<typename PredicateFunctor , typename BaseIterator > | |
FilterIterator< PredicateFunctor, BaseIterator > | make_filter_iterator (PredicateFunctor unary_func, BaseIterator begin, BaseIterator end=BaseIterator{}) |
Construct a filtering iterator, given the filter predicate function as well as the underlying base iterator begin and end. More... | |
template<typename PredicateFunctor , typename BaseIterator > | |
Range< FilterIterator< PredicateFunctor, BaseIterator > > | make_filter_range (PredicateFunctor unary_func, BaseIterator begin, BaseIterator end) |
Construct a filtering range, given the filter predicate function as well as the underlying base iterator begin and end. More... | |
template<typename PredicateFunctor , typename Container > | |
Range< FilterIterator< PredicateFunctor, typename Container::iterator > > | make_filter_range (PredicateFunctor unary_func, Container &container) |
Construct a filtering range, given the filter predicate function as well as a container, whose begin() and end() iterators are used, respectively. More... | |
template<typename PredicateFunctor , typename Container > | |
Range< FilterIterator< PredicateFunctor, typename Container::const_iterator > > | make_filter_range (PredicateFunctor unary_func, Container const &container) |
Construct a filtering range, given the filter predicate function as well as a const container, whose begin() and end() iterators are used, respectively. More... | |
std::unique_ptr< ColorNormalization > | make_heatmap_color_norm (Matrix< double > const &values, HeatmapParameters const ¶meters) |
Matrix< Color > | make_heatmap_matrix (Matrix< double > const &values, HeatmapParameters const ¶meters) |
template<typename T > | |
Optional< T > | make_optional (T const &v) |
Convenience function to create an Optional. More... | |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | make_safe_interval (NumericalType lhs, NumericalType rhs) |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | make_safe_interval (NumericalType lhs, NumericalType rhs, DataType &&data) |
template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed> | |
Interval< DataType, NumericalType, IntervalKind > | make_safe_interval (NumericalType lhs, NumericalType rhs, DataType const &data) |
SvgGroup | make_svg_axis (SvgAxisSettings const &settings, std::map< double, std::string > const &labels, std::string const &name="") |
Simple helper to make an axis. More... | |
SvgGroup | make_svg_axis (SvgAxisSettings const &settings, std::vector< Tickmarks::LabeledTick > const &labels, std::string const &name="", bool round_labels=true) |
Simple helper to make an axis. More... | |
std::pair< SvgGradientLinear, SvgGroup > | make_svg_color_bar (SvgColorBarSettings const &settings, ColorMap const &map, ColorNormalization const &norm, std::string const &id) |
static std::pair< SvgGradientLinear, SvgGroup > | make_svg_color_bar_discrete_ (SvgColorBarSettings const &settings, std::map< double, Color > const &stops) |
static std::pair< SvgGradientLinear, SvgGroup > | make_svg_color_bar_gradient_ (SvgColorBarSettings const &settings, ColorMap const &map, ColorNormalization const &norm, std::string const &id) |
static void | make_svg_color_bar_tickmarks_ (SvgColorBarSettings const &settings, ColorMap const &map, ColorNormalization const &norm, SvgGroup &group) |
SvgGroup | make_svg_color_list (ColorMap const &map, std::vector< std::string > const &labels) |
SvgGroup | make_svg_color_list (std::vector< Color > const &colors, std::vector< std::string > const &labels) |
void | make_svg_color_list_entry_ (size_t i, Color const &color, std::string const &label, SvgGroup &group) |
SvgGroup | make_svg_matrix (Matrix< Color > const &mat, SvgMatrixSettings settings) |
SvgGroup | make_svg_matrix (Matrix< Color > const &mat, SvgMatrixSettings settings, std::vector< std::string > const &row_labels) |
SvgGroup | make_svg_matrix (Matrix< Color > const &mat, SvgMatrixSettings settings, std::vector< std::string > const &row_labels, std::vector< std::string > const &col_labels) |
SvgGroup | make_svg_pie_chart (std::vector< double > const &values, std::vector< Color > const &colors, double radius=1.0, double start_angle=- PI/2.0, bool clockwise=true) |
Make a pie chart in SVG. More... | |
template<typename TransformFunctor , typename BaseIterator > | |
TransformIterator< TransformFunctor, BaseIterator > | make_transform_iterator (TransformFunctor unary_func, BaseIterator iterator) |
Construct a transforming iterator, given the underlying base iterator and the transformation function. More... | |
template<typename TransformFunctor , typename BaseIterator > | |
Range< TransformIterator< TransformFunctor, BaseIterator > > | make_transform_range (TransformFunctor unary_func, BaseIterator begin, BaseIterator end) |
Construct a transforming range, given the transformation function as well as the underlying base iterator begin and end. More... | |
template<typename TransformFunctor , typename Container > | |
Range< TransformIterator< TransformFunctor, typename Container::iterator > > | make_transform_range (TransformFunctor unary_func, Container &container) |
Construct a transforming range, given the transformation function as well as a container, whose begin() and end() iterators are used, respectively. More... | |
template<typename TransformFunctor , typename Container > | |
Range< TransformIterator< TransformFunctor, typename Container::const_iterator > > | make_transform_range (TransformFunctor unary_func, Container const &container) |
Construct a transforming range, given the transformation function as well as a const container, whose begin() and end() iterators are used, respectively. More... | |
template<typename T , typename... Args> | |
std::unique_ptr< T > | make_unique (Args &&... args) |
Returns a std::unique_ptr for a given type. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | manhattan_distance (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b) |
Calculate the Manhattan norm (L1 norm) distance between two (mathematical) vectors. More... | |
double | manhattan_distance (std::vector< double > const &vec_a, std::vector< double > const &vec_b) |
Calculate the Manhattan norm (L1 norm) distance between two vectors of double elements. More... | |
Matrix< double > | manhattan_distance_matrix (Matrix< double > const &data) |
Calculate the pairwise manhatten distance matrix between the rows of a given matrix. More... | |
template<class ForwardIterator > | |
double | manhattan_norm (ForwardIterator first, ForwardIterator last) |
Calculate the Manhattan norm (L1 norm) of a range of numbers. More... | |
double | manhattan_norm (std::vector< double > const &vec) |
Calculate the Manhattan norm (L1 norm) of a std::vector of double elements. More... | |
bool | match_wildcards (std::string const &str, std::string const &pattern) |
Return whether a string is matched by a wildcard pattern containing ? and * for single and mutliple (0 or more) wildcard characters, respectively. More... | |
template<typename T = double, typename A = double, typename B = double> | |
Matrix< T > | matrix_addition (Matrix< A > const &a, Matrix< B > const &b) |
Calculate the element-wise sum of two Matrices. More... | |
template<typename T = double, typename A = double, typename B = double> | |
Matrix< T > | matrix_addition (Matrix< A > const &matrix, B const &scalar) |
Calculate the element-wise sum of a Matrix and a scalar. More... | |
template<typename T > | |
std::vector< MinMaxPair< T > > | matrix_col_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the column-wise min and max values of a Matrix. More... | |
template<typename T > | |
std::vector< T > | matrix_col_sums (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the sum of each column and return the result as a vector. More... | |
template<typename T > | |
MinMaxPair< T > | matrix_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the min and max values of a Matrix. More... | |
template<typename T = double, typename A = double, typename B = double> | |
Matrix< T > | matrix_multiplication (Matrix< A > const &a, Matrix< B > const &b) |
Calculate the product of two Matrices. More... | |
template<typename T = double, typename A = double, typename B = double> | |
std::vector< T > | matrix_multiplication (Matrix< A > const &a, std::vector< B > const &b) |
Calculate the product of a Matrices a with a vector b , as if the vector was a Matrix with only one column. More... | |
template<typename T = double, typename A = double, typename B = double> | |
Matrix< T > | matrix_multiplication (Matrix< A > const &matrix, B const &scalar) |
Calculate the element-wise multiplication of a Matrix and a scalar. More... | |
template<typename T = double, typename A = double, typename B = double> | |
std::vector< T > | matrix_multiplication (std::vector< A > const &a, Matrix< B > const &b) |
Calculate the product of a vector a with a Matrices b , as if the vector was a Matrix with only one row. More... | |
template<typename T > | |
std::vector< MinMaxPair< T > > | matrix_row_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the row-wise min and max values of a Matrix. More... | |
template<typename T > | |
std::vector< T > | matrix_row_sums (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the sum of each row and return the result as a vector. More... | |
template<typename T > | |
Matrix< T > | matrix_sort_by_col_sum_symmetric (Matrix< T > const &data) |
Sort rows and columns of a Matrix by the sum or the columns. More... | |
template<typename T > | |
Matrix< T > | matrix_sort_by_row_sum_symmetric (Matrix< T > const &data) |
Sort rows and columns of a Matrix by the sum or the rows. More... | |
template<typename T > | |
Matrix< T > | matrix_sort_diagonal_symmetric (Matrix< T > const &data) |
Sort a Matrix so that the highest entries are on the diagonal. More... | |
template<typename T = double, typename A = double, typename B = double> | |
Matrix< T > | matrix_subtraction (Matrix< A > const &a, Matrix< B > const &b) |
Calculate the element-wise difference of two Matrices. More... | |
template<typename T > | |
T | matrix_sum (Matrix< T > const &data, bool ignore_non_finite_values=true) |
Calculate the sum of all elements in a Matrix. More... | |
size_t | max_bin (const Histogram &h) |
double | max_value (const Histogram &h) |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | maximum_distance (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b) |
Calculate the Maximum norm (infinity norm) distance between two (mathematical) vectors. More... | |
double | maximum_distance (std::vector< double > const &vec_a, std::vector< double > const &vec_b) |
Calculate the Maximum norm (infinity norm) distance between two vectors of double elements. More... | |
Matrix< double > | maximum_distance_matrix (Matrix< double > const &data) |
Calculate the pairwise maximum distance matrix between the rows of a given matrix. More... | |
template<class ForwardIterator > | |
double | maximum_norm (ForwardIterator first, ForwardIterator last) |
Calculate the Maximum norm (infinity norm) of a range of numbers. More... | |
double | maximum_norm (std::vector< double > const &vec) |
Calculate the Maximum norm (infinity norm) of a std::vector of double elements. More... | |
double | mean (const Histogram &h) |
Compute the bin-weighted arithmetic mean. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | mean_squared_error (ForwardIteratorA first_x, ForwardIteratorA last_x, ForwardIteratorB first_y, ForwardIteratorB last_y, LinearFunction lin_fct) |
Calculate the mean squared error obtained from a linear fit of the input variables. More... | |
template<class ForwardIterator > | |
MeanStddevPair | mean_stddev (ForwardIterator first, ForwardIterator last, double epsilon=-1.0) |
Calculate the arithmetic mean and standard deviation of a range of double elements. More... | |
MeanStddevPair | mean_stddev (std::vector< double > const &vec, double epsilon=-1.0) |
Calculate the mean and standard deviation of a std::vector of double elements. More... | |
double | median (const Histogram &h) |
template<class RandomAccessIterator > | |
double | median (RandomAccessIterator first, RandomAccessIterator last) |
Calculate the median value of a sorted range of double values. More... | |
double | median (std::vector< double > const &vec) |
Calculate the median value of a vector of double . More... | |
size_t | min_bin (const Histogram &h) |
double | min_value (const Histogram &h) |
TableLayout | minimal_layout () |
template<class T > | |
std::pair< T, T > | minmax_value (T const &a, T const &b) |
Returns the lowest and the greatest of the given values, by value. More... | |
template<class T , class Compare > | |
std::pair< T, T > | minmax_value (T const &a, T const &b, Compare comp) |
Returns the lowest and the greatest of the given values, by value. More... | |
static std::string | mode_to_string_ (std::ios_base::openmode mode) |
Matrix< double > | multi_dimensional_scaling (Matrix< double > const &distances, Matrix< double > const &initial_values, size_t dimensions=2, size_t iterations=100, MdsAlgorithm algorithm=MdsAlgorithm::kUcf) |
Multi-Dimensional Scaling (MDS). More... | |
Matrix< double > | multi_dimensional_scaling (Matrix< double > const &distances, size_t dimensions=2, size_t iterations=100, MdsAlgorithm algorithm=MdsAlgorithm::kUcf) |
Multi-Dimensional Scaling (MDS). More... | |
static Matrix< double > | multi_dimensional_scaling_smacof (Matrix< double > const &distances, Matrix< double > const &initial_values, size_t dimensions, size_t iterations) |
static Matrix< double > | multi_dimensional_scaling_ucf (Matrix< double > const &distances, Matrix< double > const &initial_values, size_t dimensions, size_t iterations) |
std::vector< size_t > | multinomial_distribution (std::vector< double > const &p, size_t n) |
Select a random sample following a multinomial distribution. More... | |
std::vector< size_t > | multinomial_distribution (std::vector< size_t > const &p, size_t n) |
Select a random sample following a multinomial distribution. More... | |
template<class T > | |
std::vector< size_t > | multinomial_distribution_ (std::vector< T > const &p, size_t n) |
std::vector< size_t > | multivariate_hypergeometric_distribution (std::vector< size_t > const &p, size_t n) |
Select a random sample following a multivariate hypergeometric distribution. More... | |
template<typename ForwardIterator , typename T = typename ForwardIterator::value_type, typename Comp = std::less<T>> | |
std::vector< T > | n_first_elements (ForwardIterator first, ForwardIterator last, size_t n, Comp comp=std::less< T >{}) |
Return the n first elements of a given input range in sorting order. More... | |
void | normalize (Histogram &h, double total) |
std::vector< MinMaxPair< double > > | normalize_cols (Matrix< double > &data) |
Normalize the columns of a Matrix so that all values are in the range [ 0.0, 1.0 ] . More... | |
std::vector< MinMaxPair< double > > | normalize_rows (Matrix< double > &data) |
Normalize the rows of a Matrix so that all values are in the range [ 0.0, 1.0 ] . More... | |
void | offset (Histogram &h, double value) |
bool | operator!= (Color const &lhs, Color const &rhs) |
bool | operator!= (JsonDocument const &lhs, JsonDocument const &rhs) |
bool | operator!= (JsonDocument const &v, std::nullptr_t) |
bool | operator!= (NexusTaxa const &lhs, NexusTaxa const &rhs) |
template<typename T > | |
bool | operator!= (nullopt_t, Optional< T > const &x) |
template<typename T > | |
bool | operator!= (Optional< T > const &x, nullopt_t) |
template<typename T , typename U > | |
bool | operator!= (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator!= (Optional< T > const &x, U const &v) |
bool | operator!= (std::nullptr_t, JsonDocument const &v) |
template<typename T , typename U > | |
bool | operator!= (U const &v, Optional< T > const &x) |
Bitvector | operator& (Bitvector const &lhs, Bitvector const &rhs) |
constexpr bool | operator& (SkipWhitespace lhs, SkipWhitespace rhs) noexcept |
And-operator to check whether a SkipWhitespace is set. More... | |
bool | operator< (const JsonDocument::ValueType lhs, const JsonDocument::ValueType rhs) |
bool | operator< (JsonDocument const &lhs, JsonDocument const &rhs) |
bool | operator< (JsonDocument::const_reference lhs, JsonDocument::const_reference rhs) |
template<typename T > | |
bool | operator< (nullopt_t, Optional< T > const &x) |
template<typename T > | |
bool | operator< (Optional< T > const &, nullopt_t) |
template<typename T , typename U > | |
bool | operator< (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator< (Optional< T > const &x, U const &v) |
template<typename T , typename U > | |
bool | operator< (U const &v, Optional< T > const &x) |
std::ostream & | operator<< (std::ostream &os, Color const &h) |
Write a textual representation of the Color the a stream, in the format "(r, g, b, a)". More... | |
std::ostream & | operator<< (std::ostream &os, const Histogram &h) |
std::ostream & | operator<< (std::ostream &os, const HistogramAccumulator &h) |
template<> | |
std::ostream & | operator<< (std::ostream &os, const Matrix< signed char > &matrix) |
Template specialization for signed char , in order to print nicely. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, const Matrix< T > &matrix) |
Print the elements of a Matrix to a stream, using operator << for each element. More... | |
template<> | |
std::ostream & | operator<< (std::ostream &os, const Matrix< unsigned char > &matrix) |
Template specialization for unsigned char , in order to print nicely. More... | |
std::ostream & | operator<< (std::ostream &os, GeoCoordinate const &coord) |
std::ostream & | operator<< (std::ostream &os, NexusBlock const &block) |
std::ostream & | operator<< (std::ostream &out, Bitvector const &bv) |
Insertion operator that outputs a Bitvector as a string of '0's and '1's. More... | |
std::ostream & | operator<< (std::ostream &out, Style const &style) |
Print the properties of a Style object to a stream. More... | |
std::ostream & | operator<< (std::ostream &out, Table const &table) |
std::ostream & | operator<< (std::ostream &out, TableLayout::Binder const &binder) |
bool | operator<= (JsonDocument const &lhs, JsonDocument const &rhs) |
template<typename T > | |
bool | operator<= (nullopt_t, Optional< T > const &) |
template<typename T > | |
bool | operator<= (Optional< T > const &x, nullopt_t) |
template<typename T , typename U > | |
bool | operator<= (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator<= (Optional< T > const &x, U const &v) |
template<typename T , typename U > | |
bool | operator<= (U const &v, Optional< T > const &x) |
bool | operator== (Color const &lhs, Color const &rhs) |
bool | operator== (JsonDocument const &lhs, JsonDocument const &rhs) |
bool | operator== (JsonDocument const &v, std::nullptr_t) |
bool | operator== (JsonDocument::const_reference lhs, JsonDocument::const_reference rhs) |
bool | operator== (NexusTaxa const &lhs, NexusTaxa const &rhs) |
template<typename T > | |
bool | operator== (nullopt_t, Optional< T > const &x) |
template<typename T > | |
bool | operator== (Optional< T > const &x, nullopt_t) |
template<typename T , typename U > | |
bool | operator== (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator== (Optional< T > const &x, U const &v) |
bool | operator== (std::nullptr_t, JsonDocument const &v) |
template<typename T , typename U > | |
bool | operator== (U const &v, Optional< T > const &x) |
bool | operator> (JsonDocument const &lhs, JsonDocument const &rhs) |
template<typename T > | |
bool | operator> (nullopt_t, Optional< T > const &) |
template<typename T > | |
bool | operator> (Optional< T > const &x, nullopt_t) |
template<typename T , typename U > | |
bool | operator> (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator> (Optional< T > const &x, U const &v) |
template<typename T , typename U > | |
bool | operator> (U const &v, Optional< T > const &x) |
bool | operator>= (JsonDocument const &lhs, JsonDocument const &rhs) |
template<typename T > | |
bool | operator>= (nullopt_t, Optional< T > const &x) |
template<typename T > | |
bool | operator>= (Optional< T > const &, nullopt_t) |
template<typename T , typename U > | |
bool | operator>= (Optional< T > const &x, Optional< U > const &y) |
template<typename T , typename U > | |
bool | operator>= (Optional< T > const &x, U const &v) |
template<typename T , typename U > | |
bool | operator>= (U const &v, Optional< T > const &x) |
std::istream & | operator>> (std::istream &in, Bitvector &bv) |
Extraction operator that inputs a Bitvector from a string of '0's and '1's, and stops at the first char that is not '0' or '1'. More... | |
Bitvector | operator^ (Bitvector const &lhs, Bitvector const &rhs) |
Bitvector | operator| (Bitvector const &lhs, Bitvector const &rhs) |
template<class ForwardIterator > | |
double | p_norm (ForwardIterator first, ForwardIterator last, double p=2.0) |
Calculate the p-norm of a range of numbers. More... | |
double | p_norm (std::vector< double > const &vec, double p=2.0) |
Calculate the p-norm of a std::vector of double elements. More... | |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | p_norm_distance (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b, double p=2.0) |
Calculate the p-norm distance between two (mathematical) vectors. More... | |
double | p_norm_distance (std::vector< double > const &vec_a, std::vector< double > const &vec_b, double p=2.0) |
Calculate the p-norm distance between two vectors of double elements. More... | |
Matrix< double > | p_norm_distance_matrix (Matrix< double > const &data, double p=2.0) |
Calculate the pairwise distance matrix between the rows of a given matrix. More... | |
template<typename F , typename T1 , typename T2 , typename T = typename std::common_type<T1, T2>::type, typename R = typename std::result_of<typename std::decay<F>::type(T, T)>::type> | |
MultiFuture< R > | parallel_block (T1 begin, T2 end, F &&body, std::shared_ptr< ThreadPool > thread_pool=nullptr, size_t num_blocks=0, bool auto_wait=true) |
Parallel block over a range of elements, breaking the range into blocks for which the body function is executed individually. More... | |
template<typename F , typename T1 , typename T2 , typename T = typename std::common_type<T1, T2>::type> | |
MultiFuture< void > | parallel_for (T1 begin, T2 end, F &&body, std::shared_ptr< ThreadPool > thread_pool=nullptr, size_t num_blocks=0, bool auto_wait=true) |
Parallel for over a range of positions, breaking the range into blocks for which the body function is executed individually. More... | |
template<typename F , typename T > | |
MultiFuture< void > | parallel_for_each (T &container, F &&body, std::shared_ptr< ThreadPool > thread_pool=nullptr, size_t num_blocks=0, bool auto_wait=true) |
Parallel for each over a container, processing it in blocks for which the body function is executed individually. More... | |
template<typename F , typename T > | |
MultiFuture< void > | parallel_for_each (T const begin, T const end, F &&body, std::shared_ptr< ThreadPool > thread_pool=nullptr, size_t num_blocks=0, bool auto_wait=true) |
Parallel for each over a container, processing it in blocks for which the body function is executed individually. More... | |
template<class T > | |
T | parse_float (utils::InputStream &source) |
Read a floating point number from a stream and return it. More... | |
template<class T > | |
T | parse_integer (utils::InputStream &source) |
Alias for parse_signed_integer(). More... | |
std::string | parse_number_string (utils::InputStream &source) |
Read a general number string from an input stream. More... | |
std::string | parse_quoted_string (utils::InputStream &source, bool use_escapes=true, bool use_twin_quotes=false, bool include_qmarks=false) |
Read a string in quotation marks from a stream and return it. More... | |
template<class T > | |
T | parse_signed_integer (utils::InputStream &source) |
Read a signed integer from a stream and return it. More... | |
template<class T > | |
T | parse_unsigned_integer (utils::InputStream &source) |
Read an unsigned integer from a stream and return it. More... | |
size_t | parse_unsigned_integer_naive_ (utils::InputStream &source) |
Naive parsing that simply loops over chars. More... | |
size_t | parse_unsigned_integer_size_t (utils::InputStream &source) |
Parse the input source as an unsigned int into a size_t. More... | |
bool | path_exists (std::string const &path) |
Return whether a path exists, i.e., is a file or directory. More... | |
static uint32_t | pcg32_rotr32 (uint32_t x, unsigned int r) |
template<class ForwardIteratorA , class ForwardIteratorB > | |
double | pearson_correlation_coefficient (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b) |
Calculate the Pearson Correlation Coefficient between two ranges of double . More... | |
double | pearson_correlation_coefficient (std::vector< double > const &vec_a, std::vector< double > const &vec_b) |
Calculate the Pearson Correlation Coefficient between the entries of two vectors. More... | |
uint32_t | permuted_congruential_generator () |
Fast random number generator for 32bit integers. More... | |
uint32_t | permuted_congruential_generator (uint32_t max) |
Fast random number generator for 32bit integers, for numbers in the range [0, max] . More... | |
uint32_t | permuted_congruential_generator (uint32_t min, uint32_t max) |
Fast random number generator for 32bit integers, for numbers in the range [min, max] . More... | |
bool | permuted_congruential_generator_bool () |
Fast random number generator for 32bit integers, for bool with 0.5 probability. More... | |
bool | permuted_congruential_generator_bool (uint32_t chance_one_in) |
Fast random number generator for 32bit integers, for bool with a given chance. More... | |
void | permuted_congruential_generator_init (uint64_t seed) |
Set the seed for permuted_congruential_generator(). More... | |
PcaData | principal_component_analysis (Matrix< double > const &data, size_t components=0, PcaStandardization standardization=PcaStandardization::kCorrelation) |
Perfom a Principal Component Analysis on a given data Matrix. More... | |
template<typename T > | |
std::string | print (Matrix< T > const &matrix, size_t rows=10, size_t cols=10) |
Print a Matrix to a std::string . More... | |
template<typename T > | |
void | print (std::ostream &out, Matrix< T > const &matrix, size_t rows=10, size_t cols=10) |
Print a Matrix to an out stream. See print( Matrix<T> const&, size_t, size_t ) for details. More... | |
template<typename T > | |
void | print_byte_matrix_ (std::ostream &os, const Matrix< T > &matrix, size_t width) |
Local helper function to avoid code duplication. More... | |
double | quartile_coefficient_of_dispersion (Quartiles const &q) |
Calculate the quartile_coefficient_of_dispersion. More... | |
std::vector< double > | quartile_coefficient_of_dispersion (std::vector< Quartiles > const &q) |
Calculate the quartile_coefficient_of_dispersion. More... | |
template<class RandomAccessIterator > | |
Quartiles | quartiles (RandomAccessIterator first, RandomAccessIterator last) |
Calculate the Quartiles of a sorted range of double values. More... | |
Quartiles | quartiles (std::vector< double > const &vec) |
Calculate the Quartiles of a vector of double . More... | |
template<class RandomAccessIterator > | |
std::vector< size_t > | ranking_dense (RandomAccessIterator first, RandomAccessIterator last) |
Return the ranking of the values in the given range, using Dense ranking ("1223" ranking). More... | |
std::vector< size_t > | ranking_dense (std::vector< double > const &vec) |
Return the ranking of the values in the given range, using Dense ranking ("1223" ranking). More... | |
template<class RandomAccessIterator > | |
std::vector< double > | ranking_fractional (RandomAccessIterator first, RandomAccessIterator last) |
Return the ranking of the values in the given range, using Fractional ranking ("1 2.5 2.5 4" ranking). More... | |
std::vector< double > | ranking_fractional (std::vector< double > const &vec) |
Return the ranking of the values in the given range, using Fractional ranking ("1 2.5 2.5 4" ranking). More... | |
template<class RandomAccessIterator > | |
std::vector< size_t > | ranking_modified (RandomAccessIterator first, RandomAccessIterator last) |
Return the ranking of the values in the given range, using Modified competition ranking ("1334" ranking). More... | |
std::vector< size_t > | ranking_modified (std::vector< double > const &vec) |
Return the ranking of the values in the given range, using Modified competition ranking ("1334" ranking). More... | |
template<class RandomAccessIterator > | |
std::vector< size_t > | ranking_ordinal (RandomAccessIterator first, RandomAccessIterator last) |
Return the ranking of the values in the given range, using Ordinal ranking ("1234" ranking). More... | |
std::vector< size_t > | ranking_ordinal (std::vector< double > const &vec) |
Return the ranking of the values in the given range, using Ordinal ranking ("1234" ranking). More... | |
template<class RandomAccessIterator > | |
std::vector< size_t > | ranking_standard (RandomAccessIterator first, RandomAccessIterator last) |
Return the ranking of the values in the given range, using Standard competition ranking ("1224" ranking). More... | |
std::vector< size_t > | ranking_standard (std::vector< double > const &vec) |
Return the ranking of the values in the given range, using Standard competition ranking ("1224" ranking). More... | |
template<typename InputStream > | |
char | read_char_or_throw (InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone) |
Lexing function that reads a single char from the stream and checks whether it equals the provided one. More... | |
template<typename InputStream > | |
char | read_char_or_throw (InputStream &source, std::function< bool(char)> criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone) |
Lexing function that reads a single char from the stream and checks whether it fulfills the provided criterion. More... | |
size_t | read_id_from_file_ (std::string const &filename) |
template<typename InputStream > | |
std::string | read_to_end_of_line (InputStream &source) |
Lexing function that reads until the end of the line (i.e., to the new line char), and returns the read chars (excluding the new line char). More... | |
template<typename InputStream > | |
std::string | read_until (InputStream &source, char criterion) |
Lexing function that reads from the stream until its current char equals the provided one. The read chars are returned. More... | |
template<typename InputStream > | |
std::string | read_until (InputStream &source, std::function< bool(char)> criterion) |
Lexing function that reads from the stream until its current char fulfills the provided criterion. The read chars are returned. More... | |
template<typename InputStream > | |
std::string | read_while (InputStream &source, char criterion) |
Lexing function that reads from the stream while its current char equals the provided one. The read chars are returned. More... | |
template<typename InputStream > | |
std::string | read_while (InputStream &source, std::function< bool(char)> criterion) |
Lexing function that reads from the stream while its current char fulfills the provided criterion. The read chars are returned. More... | |
static bool | readlink_internal_ (const std::string &path, std::string &buffer, ssize_t length) |
std::string | real_path (std::string const &path, bool resolve_link=true) |
Return the real path of a file or directory, similar to realpath(). More... | |
static std::string | real_path_realpath_ (std::string const &path, bool resolve_link) |
static std::string | real_path_unix_ (std::string const &path, bool resolve_link) |
static std::string | realpath_file_ (const std::string &path) |
TridiagonalDecompositionData | reduce_to_tridiagonal_matrix (Matrix< double > &data) |
Triangular decomposition of a symmetric matrix. More... | |
static void | relative_dir_base_split_ (std::string const &path, std::string &dir, std::string &base) |
std::string | remove_all (std::string const &text, std::string const &search) |
Return a copy of a string, where all occurrences of a search string are removed. More... | |
std::string | remove_all_chars (std::string const &text, std::string const &search_chars) |
Remove all occurrences of the search_chars in text . More... | |
template<class UnaryPredicate > | |
std::string | remove_all_chars_pred (std::string const &text, UnaryPredicate predicate) |
Remove all occurrences characters for which predicate is true in text . More... | |
std::string | remove_all_non_alnum (std::string const &text) |
Remove all non-alphanumerical characters from a string. More... | |
std::string | repeat (std::string const &word, size_t times) |
Take a string and repeat it a given number of times. More... | |
std::string | replace_all (std::string const &text, std::string const &search, std::string const &replace) |
Return a copy of a string, where all occurrences of a search string are replaced by a replace string. More... | |
std::string | replace_all_chars (std::string const &text, std::string const &search_chars, char replace) |
Replace all occurrences of the search_chars in text by the replace char. More... | |
template<class UnaryPredicate > | |
std::string | replace_all_chars_pred (std::string const &text, UnaryPredicate predicate, char replace) |
Replace all occurrences of characters for which predicate is true in text by the replace char. More... | |
Color | resolve_color_string (std::string const &color_str) |
Resolve a string representing a color. More... | |
double | round_to (double x, size_t accuracy_order) |
Retun the value of x , rounded to the decimal digit given by accuracy_order . More... | |
std::string | sanitize_filename (std::string const &filename) |
Remove or replace all invalid parts of a filename. More... | |
std::string | sanitize_geo_coordinate (std::string const &coordinate, bool two_components=true) |
Replace non-ascii symbols used in geographic coordinates by their ascii equivalents. More... | |
void | scale (Histogram &h, double factor) |
std::vector< size_t > | select_without_replacement (size_t k, size_t n) |
Select k many unique numbers out of the range [ 0, n ) . More... | |
Bitvector | set_minus (Bitvector const &lhs, Bitvector const &rhs) |
double | sigma (const Histogram &h) |
Compute the bin-weighted standard deviation. More... | |
template<typename T > | |
constexpr int | signum (T x) |
Get the sign of a value, which is either -1, 0, or 1. More... | |
template<typename T > | |
constexpr int | signum (T x, std::false_type) |
Implementation of signum(T x) for unsigned types. See there for details. More... | |
template<typename T > | |
constexpr int | signum (T x, std::true_type) |
Implementation of signum(T x) for signed types. See there for details. More... | |
TableLayout | simple_frame (bool condensed) |
TableLayout | simple_grid (bool condensed) |
TableLayout | simple_layout (bool condensed) |
template<class ForwardIteratorA , class ForwardIteratorB > | |
LinearFunction | simple_linear_regression (ForwardIteratorA first_x, ForwardIteratorA last_x, ForwardIteratorB first_y, ForwardIteratorB last_y) |
Simple linear regression, for predicting the dependent variable y given the independent variable x , using ordinary least squares regression. More... | |
template<typename InputStream > | |
void | skip_to_end_of_line (InputStream &source) |
Lexing function that advances the stream to the end of the line, i.e., to the new line char. More... | |
template<typename InputStream > | |
void | skip_until (InputStream &source, char criterion) |
Lexing function that advances the stream until its current char equals the provided one. More... | |
template<typename InputStream > | |
void | skip_until (InputStream &source, std::function< bool(char)> criterion) |
Lexing function that advances the stream until its current char fulfills the provided criterion. More... | |
template<typename InputStream > | |
void | skip_while (InputStream &source, char criterion) |
Lexing function that advances the stream while its current char equals the provided one. More... | |
template<typename InputStream > | |
void | skip_while (InputStream &source, std::function< bool(char)> criterion) |
Lexing function that advances the stream while its current char fulfills the provided criterion. More... | |
template<typename RandomAccessIterator > | |
std::vector< size_t > | sort_indices (RandomAccessIterator first, RandomAccessIterator last) |
Get the indices to the sorted order of the given range. More... | |
template<typename RandomAccessIterator , typename Comparator > | |
std::vector< size_t > | sort_indices (RandomAccessIterator first, RandomAccessIterator last, Comparator comparator) |
Get the indices to the sorted order of the given range. More... | |
template<typename RandomAccessIterator > | |
void | sort_natural (RandomAccessIterator first, RandomAccessIterator last, bool reverse=false) |
Sort a range of std::string (or convertible to std::string) elements, using natural sorting; see compare_natural(). More... | |
template<class RandomAccessIteratorA , class RandomAccessIteratorB > | |
double | spearmans_rank_correlation_coefficient (RandomAccessIteratorA first_a, RandomAccessIteratorA last_a, RandomAccessIteratorB first_b, RandomAccessIteratorB last_b) |
Calculate Spearman's Rank Correlation Coefficient between two ranges of double . More... | |
double | spearmans_rank_correlation_coefficient (std::vector< double > const &vec_a, std::vector< double > const &vec_b) |
Calculate Spearman's Rank Correlation Coefficient between the entries of two vectors. More... | |
std::vector< std::string > | split (std::string const &str, char delimiter='\t', const bool trim_empty=true) |
Spilt a string into parts, given a delimiter char. More... | |
std::vector< std::string > | split (std::string const &str, std::function< bool(char)> delimiter_predicate, const bool trim_empty=true) |
Spilt a string into parts, given a delimiter_predicate that returns true for delimiters chars. More... | |
std::vector< std::string > | split (std::string const &str, std::string const &delimiters, const bool trim_empty=true) |
Spilt a string into parts, given a delimiters set of chars. More... | |
static std::vector< std::string > | split_ (std::string const &string, std::function< size_t(std::string const &, size_t)> find_pos, size_t advance_by, const bool trim_empty) |
Local function that does the work for the split cuntions. More... | |
std::vector< std::string > | split_at (std::string const &str, std::string const &delimiter, const bool trim_empty=true) |
Spilt a string into parts, given a delimiter string. More... | |
std::vector< size_t > | split_range_list (std::string const &str) |
Split a string containing positive interger numbers into its parts and resolve ranges. More... | |
constexpr double | squared (double x) |
Square of a number. More... | |
template<typename RandomAccessIterator > | |
std::vector< size_t > | stable_sort_indices (RandomAccessIterator first, RandomAccessIterator last) |
Get the indices to the stable sorted order of the given range. More... | |
template<typename RandomAccessIterator , typename Comparator > | |
std::vector< size_t > | stable_sort_indices (RandomAccessIterator first, RandomAccessIterator last, Comparator comparator) |
Get the indices to the stable sorted order of the given range. More... | |
std::vector< MeanStddevPair > | standardize_cols (Matrix< double > &data, bool scale_means=true, bool scale_std=true) |
Standardize the columns of a Matrix by subtracting the mean and scaling to unit variance. More... | |
std::vector< MeanStddevPair > | standardize_rows (Matrix< double > &data, bool scale_means=true, bool scale_std=true) |
Standardize the rows of a Matrix by subtracting the mean and scaling to unit variance. More... | |
bool | starts_with (std::string const &text, std::string const &prefix) |
Return whether a string starts with another string, i.e., check for a prefix . More... | |
bool | starts_with (std::string const &text, std::string const &prefix, std::string &suffix) |
Return whether a string starts with another string, i.e., check for a prefix . More... | |
bool | starts_with_ci (std::string const &text, std::string const &prefix) |
Return whether a string starts with another string, i.e., check for a prefix , case insensitive. More... | |
bool | starts_with_ci (std::string const &text, std::string const &prefix, std::string &suffix) |
Return whether a string starts with another string, i.e., check for a prefix , case insensitive. More... | |
bool | starts_with_ci_alnum (std::string const &text, std::string const &prefix) |
Return whether a string starts with another string (prefix), comparing case-independent, and ignoring all non-alphanumerical characters. More... | |
bool | starts_with_ci_alnum (std::string const &text, std::string const &prefix, std::string &suffix, bool trim_suffix=false) |
Return whether a string starts with another string (prefix), comparing case-independent, and ignoring all non-alphanumerical characters. More... | |
int | strcasecmp (char const *s1, char const *s2) |
Compares two strings, ignoring case differences. More... | |
static std::string | strerror_ () |
Overload of error-reporting function, to enable use with VS. More... | |
int | strncasecmp (char const *s1, char const *s2, size_t n) |
Compares up to n chars of two strings, ignoring case differences. More... | |
double | sum (const Histogram &h) |
std::string | summarize_column (Dataframe const &df, size_t col_index) |
std::string | summarize_column (Dataframe const &df, std::string const &col_name) |
std::string | summarize_column_common_ (Dataframe const &df, size_t col_index, std::string const &description) |
template<typename T > | |
std::string | summarize_column_double_ (Dataframe const &df, size_t col_index) |
template<typename T > | |
std::string | summarize_column_int_ (Dataframe const &df, size_t col_index) |
std::string | summarize_column_string_ (Dataframe const &df, size_t col_index) |
std::string | summarize_columns (Dataframe const &df) |
Matrix< double > | sums_of_squares_and_cross_products_matrix (Matrix< double > const &data) |
Calculate the Sums of Squares and Cross Products Matrix (SSCP Matrix). More... | |
std::string | svg_arc (double center_x, double center_y, double radius, double start_angle, double end_angle, bool wedge=false) |
Create an arc to use in an SvgPath. More... | |
template<typename T > | |
std::string | svg_attribute (std::string const &name, T const &value, std::string const &unit="") |
SvgBox | svg_bounding_box (std::vector< SvgPoint > const &points) |
Compute the bounding box of a set of points. More... | |
SvgBox | svg_bounding_box (std::vector< SvgPoint > const &points, SvgTransform const &transform) |
Compute the bounding box of a set of points, including their transformation. More... | |
std::string | svg_comment (std::string const &content) |
std::string | svg_data_uri (std::string const &media_type, std::string const &content, bool encode_base64=false) |
template<typename T , typename Traits > | |
void | swap (BlockingConcurrentQueue< T, Traits > &a, BlockingConcurrentQueue< T, Traits > &b) MOODYCAMEL_NOEXCEPT |
void | swap (Color &lhs, Color &rhs) |
template<typename T , typename Traits > | |
void | swap (ConcurrentQueue< T, Traits > &a, ConcurrentQueue< T, Traits > &b) noexcept |
void | swap (ConsumerToken &a, ConsumerToken &b) noexcept |
void | swap (Histogram &lhs, Histogram &rhs) |
void | swap (HistogramAccumulator &lhs, HistogramAccumulator &rhs) |
void | swap (NexusTaxa &lhs, NexusTaxa &rhs) |
void | swap (NexusTrees &lhs, NexusTrees &rhs) |
template<typename T > | |
void | swap (Optional< T > &x, Optional< T > &y) |
void | swap (ProducerToken &a, ProducerToken &b) noexcept |
void | swap (Style &lhs, Style &rhs) |
template<typename T , typename Traits > | |
void | swap (typename ConcurrentQueue< T, Traits >::ImplicitProducerKVP &a, typename ConcurrentQueue< T, Traits >::ImplicitProducerKVP &b) noexcept |
template<typename T > | |
void | swap_cols (Matrix< T > &data, size_t col_a, size_t col_b) |
Swap (interchange) two columns of a Matrix, given their indices. More... | |
template<typename T > | |
void | swap_rows (Matrix< T > &data, size_t row_a, size_t row_b) |
Swap (interchange) two rows of a Matrix, given their indices. More... | |
static bool | symlink_resolve_ (const std::string &start, std::string &end) |
Bitvector | symmetric_difference (Bitvector const &lhs, Bitvector const &rhs) |
std::string | tail (std::string const &text, size_t lines=10) |
Return the last lines of the text. More... | |
template<typename ForwardIterator > | |
std::vector< std::tm > | time_to_tm (ForwardIterator first, ForwardIterator last, bool use_local_time=false, size_t size=0) |
Convert a list of std::time_t objects to a std::vector of std::tm objects. More... | |
std::tm | time_to_tm (std::time_t const &time, bool use_local_time=false) |
Convert std::time_t object to a std::tm object. More... | |
std::vector< std::tm > | time_to_tm (std::vector< std::time_t > const ×, bool use_local_time=false) |
Convert a std::vector of std::time_t objects to a std::vector of std::tm objects. More... | |
std::string | tm_date_to_string (std::tm const &time) |
Print the given std::tm object as a std::string containing only the date, using the ISO 8601 extended format. More... | |
std::string | tm_time_to_string (std::tm const &time) |
Print the given std::tm object as a std::string containing only the time, using the ISO 8601 extended format. More... | |
std::string | tm_to_string (std::tm const &time) |
Print the given std::tm object as a std::string , using the ISO 8601 extended format. More... | |
std::string | tm_to_string (std::tm const &time, std::string const &format) |
Print the given std::tm object as a std::string , using the format . More... | |
std::string | tm_to_string (std::tm const &time, std::string const &format, std::string const &locale) |
Print the given std::tm object as a std::string , using the format and locale . More... | |
template<typename ForwardIterator > | |
std::vector< std::time_t > | tm_to_time (ForwardIterator first, ForwardIterator last, bool use_local_time=false, size_t size=0) |
Convert a list of std::tm objects to a std::vector of std::time_t objects. More... | |
std::time_t | tm_to_time (std::tm time, bool use_local_time=false) |
Convert std::tm object to a std::time_t object. More... | |
std::vector< std::time_t > | tm_to_time (std::vector< std::tm > const ×, bool use_local_time=false) |
Convert a std::vector of std::tm objects to a std::vector of std::time_t objects. More... | |
template<typename T > | |
std::string | to_bit_string (T const x, char const zero='0', char const one='1', bool const byte_space=true) |
Return the bit representation of an unsigned int. More... | |
std::shared_ptr< BaseOutputTarget > | to_file (std::string const &file_name, GzipCompressionLevel compression_level, bool auto_adjust_filename=true) |
Obtain an output target for writing to a file. More... | |
std::shared_ptr< BaseOutputTarget > | to_file (std::string const &file_name, std::ios_base::openmode mode=std::ios_base::out) |
Obtain an output target for writing to a file, using a specific output mode. More... | |
std::shared_ptr< BaseOutputTarget > | to_gzip_block_file (std::string const &file_name, std::size_t block_size=GzipBlockOStream::GZIP_DEFAULT_BLOCK_SIZE, GzipCompressionLevel compression_level=GzipCompressionLevel::kDefaultCompression, std::shared_ptr< ThreadPool > thread_pool=nullptr, bool auto_adjust_filename=true) |
Obtain an output target for writing gzip block compressed data to a file. More... | |
std::shared_ptr< BaseOutputTarget > | to_gzip_file (std::string const &file_name) |
Obtain an output target for writing to a gzip-compressed file. More... | |
constexpr char | to_lower (char c) noexcept |
Return the lower case version of a letter, ASCII-only. More... | |
std::string | to_lower (std::string const &str) |
Return an all-lowercase copy of the given string, locale-aware. More... | |
std::string | to_lower_ascii (std::string const &str) |
Return an all-lowercase copy of the given string, ASCII-only. More... | |
void | to_lower_ascii_inplace (std::string &str) |
Turn the given string to all-lowercase, ASCII-only. More... | |
void | to_lower_inplace (std::string &str) |
Turn the given string to all-lowercase, locale-aware. More... | |
std::string | to_nucleic_acids (TwobitVector const &vec) |
Turn a TwobitVector into its string representation of nucleic acids. More... | |
std::shared_ptr< BaseOutputTarget > | to_stderr () |
Obtain an output target for writing to standard error (i.e., stderr or cerr). More... | |
std::shared_ptr< BaseOutputTarget > | to_stdout () |
Obtain an output target for writing to standard output (i.e., stdout or cout). More... | |
std::shared_ptr< BaseOutputTarget > | to_stream (std::ostream &target_stream, GzipCompressionLevel compression_level=GzipCompressionLevel::kNoCompression) |
Obtain an output target for writing to a stream. More... | |
std::shared_ptr< BaseOutputTarget > | to_string (std::string &target_string) |
Obtain an output target for writing to a string. More... | |
std::string | to_string_byte_format (size_t value) |
Produce a human readable formatting of a size in bytes, using the appropriate suffix. More... | |
std::string | to_string_leading_zeros (size_t value, size_t length=6) |
Return a string representation of a size_t value with a fixed length, that is, by adding leading zeros. More... | |
template<typename T > | |
std::string | to_string_nice (T const &v) |
Return a string representation of a given value. More... | |
std::string | to_string_precise (double value, int precision=6) |
Return a precise string representation of the input value, using the provided precision value (determining its decimal places). More... | |
std::string | to_string_rounded (double value, int precision=6) |
Return a string representation of the input value, using the provided precision value (determining its decimal places) to round, and truncate trailing zeros. More... | |
constexpr char | to_upper (char c) noexcept |
Return the upper case version of a letter, ASCII-only. More... | |
std::string | to_upper (std::string const &str) |
Return an all-uppercase copy of the given string, locale-aware. More... | |
std::string | to_upper_ascii (std::string const &str) |
Return an all-uppercase copy of the given string, ASCII-only. More... | |
void | to_upper_ascii_inplace (std::string &str) |
Turn the given string to all-uppercase, ASCII-only, inline. More... | |
void | to_upper_inplace (std::string &str) |
Turn the given string to all-uppercase, locale-aware. More... | |
TwobitVector::ValueType | translate_from_nucleic_acid (char site) |
Translate a char into TwobitVector::ValueType. More... | |
char | translate_to_nucleic_acid (TwobitVector::ValueType value) |
Translate a TwobitVector::ValueType into its char representation. More... | |
template<typename T > | |
Matrix< T > | transpose (Matrix< T > const &mat) |
Transpose a Matrix. More... | |
template<typename T > | |
void | transpose_inplace (Matrix< T > &mat) |
Transpose a Matrix inplace, without allocating a new Matrix. More... | |
size_t | triangular_index (size_t i, size_t j, size_t n) |
Given indices i and j in a quadratic Matrix, find the corresponding linear index. More... | |
std::pair< size_t, size_t > | triangular_indices (size_t k, size_t n) |
Given a linear index in a upper triangular Matrix, find the corresponding Matrix indices. More... | |
size_t | triangular_size (size_t n) |
Calculate the number of linear indices needed for a triangular Matrix of size n . More... | |
void | tridiagonal_ql_algorithm (Matrix< double > &data, TridiagonalDecompositionData &tri, size_t max_iterations=1000) |
Reduce a symmetric matrix to a symmetric tridiagonal matrix. More... | |
std::string | trim (std::string const &s, std::string const &delimiters=" \f\n\r\t\v") |
Return a copy of the input string, with trimmed white spaces (or any other delimiters ). More... | |
std::string | trim_left (std::string const &s, std::string const &delimiters=" \f\n\r\t\v") |
Return a copy of the input string, with right trimmed white spaces (or any other delimiters ). More... | |
std::string | trim_right (std::string const &s, std::string const &delimiters=" \f\n\r\t\v") |
Return a copy of the input string, with left trimmed white spaces (or any other delimiters ). More... | |
std::vector< double > | udu_transpose_ (size_t M, std::vector< double > const &U, double scale) |
Calculate U.D.U-transpose. More... | |
std::vector< double > | udvdu_transpose_ (size_t M, std::vector< double > const &U, std::vector< double > const &V, double scale) |
Calculate U.D.V.D.U-transpose. More... | |
bool | validate (Dataframe const &df) |
template<class ForwardIterator > | |
double | weighted_arithmetic_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight) |
Calculate the weighted arithmetic mean of a range of double values. More... | |
double | weighted_arithmetic_mean (std::vector< double > const &values, std::vector< double > const &weights) |
Calculate the weighted arithmetic mean of a std::vector of double elements. More... | |
template<class ForwardIterator > | |
double | weighted_geometric_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight) |
Calculate the weighted geometric mean of a range of positive numbers. More... | |
double | weighted_geometric_mean (std::vector< double > const &values, std::vector< double > const &weights) |
Calculate the weighted geometric mean of a std::vector of double elements. More... | |
template<class ForwardIterator > | |
double | weighted_harmonic_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow) |
Calculate the weighted harmonic mean of a range of positive numbers. More... | |
double | weighted_harmonic_mean (std::vector< double > const &values, std::vector< double > const &weights, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow) |
Calculate the weighted harmonic mean of a std::vector of double elements. More... | |
double | weighted_inner_product (std::vector< double > const &x_input, std::vector< double > const &y_input, std::vector< double > const &weights=std::vector< double >{}) |
(Weighted) inner product of two vectors. More... | |
GlmFreedom | weighted_mean_centering (std::vector< double > const &y_input, std::vector< double > const &weights, std::vector< size_t > const &strata, bool with_intercept, bool centering, std::vector< double > &y_output) |
(Weighted) mean and centering. More... | |
double | weighted_residuals (std::vector< double > const &x_input, std::vector< double > const &y_input, std::vector< double > const &weights, std::vector< double > &y_output) |
Calculate the residuals from (weighted) regression through the origin. More... | |
double | weighted_sum (std::vector< double > const &x_input, std::vector< double > const &weights=std::vector< double >{}) |
(Weighted) sum of a vector of values. More... | |
double | weighted_sum_of_squares (std::vector< double > const &x_input, std::vector< double > const &weights=std::vector< double >{}) |
(Weighted) sum of squares. More... | |
std::string | wrap (std::string const &text, size_t line_length=80) |
Wrap a text at a given line_length . More... | |
uint64_t | xgetbv (unsigned int index) |
template<typename T > | |
std::string | xml_attribute (std::string const &name, T const &value) |
std::string | xml_comment (std::string const &content) |
std::string | xml_deescape (std::string const &txt) |
De-escape special XML characters. More... | |
std::string | xml_escape (std::string const &txt) |
Escape special XML characters. More... | |
const XmlComment * | xml_value_to_comment (const XmlValue *v) |
Converts a pointer to an XmlValue to XmlComment if appropriate. More... | |
const XmlElement * | xml_value_to_element (const XmlValue *v) |
Converts a pointer to an XmlValue to XmlElement if appropriate. More... | |
const XmlMarkup * | xml_value_to_markup (const XmlValue *v) |
Converts a pointer to an XmlValue to XmlMarkup if appropriate. More... | |
Enumerations | |
enum | ColorListDiverging { kBrbg, kPiyg, kPrgn, kPuor, kRdbu, kRdgy, kRdylbu, kRdylgn, kSpectral } |
enum | ColorListMisc { kNextstrain } |
enum | ColorListQualitative { kAccent, kDark2, kPaired, kPastel1, kPastel2, kSet1, kSet2, kSet3 } |
enum | ColorListSequential { kBupubk, kBlues, kBugn, kBupu, kGnbu, kGreens, kGreys, kOranges, kOrrd, kPubu, kPubugn, kPurd, kPurples, kRdpu, kReds, kYlgn, kYlgnbu, kYlorbr, kYlorrd, kHeat, kMagma, kInferno, kPlasma, kViridis } |
enum | GeoCoordinateComponent { kLatitude, kLongitude } |
Local helper enum that indicates which component of a coordinate we are dealing with. More... | |
enum | GzipCompressionLevel : int { kDefaultCompression = -1, kNoCompression = 0, kBestSpeed = 1, kBestCompression = 9 } |
List of possible compression levels used for GzipOStream. More... | |
enum | HarmonicMeanZeroPolicy { kThrow, kIgnore, kReturnZero, kCorrection } |
Select a policy on how to treat zeroes in the computation of harmonic_mean() and weighted_harmonic_mean(). More... | |
enum | HashingFunctions { kMD5, kSHA1, kSHA256 } |
List of the currently implemented hashing functions. More... | |
enum | KendallsTauMethod { kTauA, kTauB, kTauC } |
Method for computing Kendall's Tau. More... | |
enum | KmeansInitializationStrategy { kRandomAssignments, kRandomCentroids, kKmeansPlusPlus, kNone } |
Enum of the initialization strategies offered by the Kmeans implementation. More... | |
enum | MdsAlgorithm { kUcf, kSmacof } |
Choice of algorithm to use for Multi-Dimensional Scaling (MDS). More... | |
enum | PcaStandardization { kCorrelation, kCovariance, kSSCP } |
Setting for principal_component_analysis() to determine which form of standardization of the data to use prior to perfoming the PCA. More... | |
enum | RedBackColor { kInvalid, kRed, kBlack, kKDoubleBlack } |
Definition for Red-Black Tree coloring. More... | |
enum | SkipWhitespace : unsigned char { kNone = 0, kLeading = 1, kTrailing = 2, kSurrounding = 3 } |
Option to determine how to treat surrounding whitespace when scanning an input stream. More... | |
Typedefs | |
using | DefaultIntervalNumericalType = int |
Default numerical type to use in an Interval. More... | |
using | InputReader = AsynchronousReader |
Alias for the either AsynchronousReader or SynchronousReader. More... | |
using | KahanSum = CompensatedSum< KahanSummation > |
Typedef shorthand for a Kahan sum. More... | |
using | KleinSum = CompensatedSum< KleinSummation > |
Typedef shorthand for a Kahan Babushka Klein sum. More... | |
using | NamedColorList = std::vector< std::pair< std::string, ColorBytes > > |
using | NeumaierSum = CompensatedSum< NeumaierSummation > |
Typedef shorthand for a Kahan Babushka Neumaier sum. More... | |
Variables | |
static const std::array< std::string, 128 > | ascii_names_ |
List of all ASCII names. More... | |
static const std::array< std::string, 128 > | ascii_symbols_ |
List of all ASCII symbols. More... | |
static const char | base64_encode_lookup_ [] |
static const char | base64_pad_char_ = '=' |
const std::vector< Color > | color_list_accent_ |
const std::vector< Color > | color_list_blues_ |
const std::vector< Color > | color_list_brbg_ |
const std::vector< Color > | color_list_bugn_ |
const std::vector< Color > | color_list_bupu_ |
const std::vector< Color > | color_list_bupubk_ |
Our own color list used for visualizing trees. More... | |
const std::vector< Color > | color_list_dark2_ |
const std::vector< Color > | color_list_gnbu_ |
const std::vector< Color > | color_list_greens_ |
const std::vector< Color > | color_list_greys_ |
const std::vector< Color > | color_list_heat_ |
const std::vector< Color > | color_list_inferno_ |
const NamedColorList | color_list_lego_ |
Struct that stores a static const map of named LEGO colors. More... | |
const std::vector< Color > | color_list_magma_ |
static const std::vector< Color > | color_list_nextstrain_256_ |
const std::vector< Color > | color_list_oranges_ |
const std::vector< Color > | color_list_orrd_ |
const std::vector< Color > | color_list_paired_ |
const std::vector< Color > | color_list_pastel1_ |
const std::vector< Color > | color_list_pastel2_ |
const std::vector< Color > | color_list_piyg_ |
const std::vector< Color > | color_list_plasma_ |
const std::vector< Color > | color_list_prgn_ |
const std::vector< Color > | color_list_pubu_ |
const std::vector< Color > | color_list_pubugn_ |
const std::vector< Color > | color_list_puor_ |
const std::vector< Color > | color_list_purd_ |
const std::vector< Color > | color_list_purples_ |
const std::vector< Color > | color_list_rdbu_ |
const std::vector< Color > | color_list_rdgy_ |
const std::vector< Color > | color_list_rdpu_ |
const std::vector< Color > | color_list_rdylbu_ |
const std::vector< Color > | color_list_rdylgn_ |
const std::vector< Color > | color_list_reds_ |
const std::vector< Color > | color_list_set1_ |
const std::vector< Color > | color_list_set2_ |
const std::vector< Color > | color_list_set3_ |
const std::vector< Color > | color_list_spectral_ |
const std::vector< Color > | color_list_viridis_ |
const NamedColorList | color_list_web_ |
Struct that stores a static const map of named web colors. More... | |
const NamedColorList | color_list_xkcd_ |
Struct that stores a static const map of named xkcd colors. More... | |
const std::vector< Color > | color_list_ylgn_ |
const std::vector< Color > | color_list_ylgnbu_ |
const std::vector< Color > | color_list_ylorbr_ |
const std::vector< Color > | color_list_ylorrd_ |
static const std::vector< std::vector< Color > > | color_lists_nextstrain_1_16_ |
constexpr double | EARTH_MEAN_RADIUS = 6371.0 |
Earth is not flat! More... | |
static const std::array< std::string, 9 > | formats_ |
static std::mutex | genesis_log_mutex_ |
static const std::size_t | GZIP_DEFAULT_BUFFER_SIZE = (std::size_t) 1 << 20 |
Default buffer size for all gzip (de)compression buffers. More... | |
static const std::array< std::string, 3 > | locales_ = {{ "C", "en_US.UTF-8", "" }} |
static const std::array< double, 1024 > | log_factorial_lookup_ |
Log-factorial log(x!) lookup table for fast computation of binomial coefficients. See binomial_coefficient_approx() for usage, and see log_factorial_lookup_generator_() for the generator function. More... | |
constexpr double | MDS_EPSILON = 0.0000001 |
const nullopt_t | nullopt ((nullopt_t::init())) |
Optional to indicate an empty value. More... | |
static const uint64_t | pcg32_increment = 1442695040888963407u |
static const uint64_t | pcg32_multiplier = 6364136223846793005u |
static uint64_t | pcg32_state = 0x4d595df4d0f33173 |
constexpr double | PI = 3.141592653589793238463 |
Make the world go round. More... | |
static std::mutex | tm_mutex_ |
The std::localtime and std::gmtime functions are not thread safe, due to their shared internal state. Make sure that we can use them from multiple threads. More... | |
|
inlineconstexpr |
Calculate the absolute differenence between two values.
This function is particularly useful for unsigned types, as subtracting them and then using std::abs() does not work for them.
Definition at line 95 of file common.hpp.
|
inline |
Lexing function that checks whether the current char from the stream equals the provided one.
If not, the function throws std::runtime_error
. The stream is not advanced (i.e., it stays at its current position). For a similar function that reads (i.e., also advances) the current char from the stream, see read_char_or_throw().
Using the parameter skip_ws
, it is possible to skip leading and/or trailing whitespaces before/after treating the criterion
char. See SkipWhitespace for more information.
Definition at line 385 of file scanner.hpp.
|
inline |
Lexing function that checks whether the current char from the stream fulfills the provided criterion.
If not, the function throws std::runtime_error
. The stream is not advanced (i.e., it stays at its current position). For a similar function that reads (i.e., also advances) the current char from the stream, see read_char_or_throw().
Using the parameter skip_ws
, it is possible to skip leading and/or trailing whitespaces before/after treating the criterion
char. See SkipWhitespace for more information.
Definition at line 422 of file scanner.hpp.
double genesis::utils::aitchison_norm | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the Aitchison norm of a range of positive numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element.
Following [1], the Aitchison norm \( \| x \|_a \) of a vector \( x \) with \( s \) elements is caluclated as
\( \| x \|_a = \sqrt{ \frac{1}{2s} \sum_{j=1}^{s} \sum_{k=1}^{s} \left( \ln{ \frac{x_j}{x_k} } \right)^2 } \)
That is, the calculation is in \( \mathcal{O}( s^2 ) \).
[1] V. Pawlowsky-Glahn, J. J. Egozcue, and R. Tolosana-Delgado, "Modelling and Analysis of Compositional Data". Chichester, UK: John Wiley & Sons, Ltd, 2015. https://onlinelibrary.wiley.com/doi/book/10.1002/9781119003144
Definition at line 216 of file distance.hpp.
|
inline |
Calculate the Aitchison norm of a std::vector
of double
elements.
Definition at line 262 of file distance.hpp.
|
inline |
Check whether two doubles are almost equal, using a relative epsilon to compare them.
Definition at line 157 of file common.hpp.
double genesis::utils::arithmetic_mean | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the arithmetic mean of a range of numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. The function then calculates the arithmetic mean of all finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored.
std::vector
. Definition at line 438 of file statistics.hpp.
|
inline |
Calculate the arithmetic mean of a std::vector
of double
elements.
Definition at line 473 of file statistics.hpp.
|
inline |
Sort two values in ascending order, inplace.
Definition at line 70 of file common.hpp.
T genesis::utils::base64_decode_ | ( | std::string const & | input | ) |
Definition at line 152 of file base64.cpp.
std::string base64_decode_string | ( | std::string const & | input | ) |
Definition at line 283 of file base64.cpp.
std::vector< std::uint8_t > base64_decode_uint8 | ( | std::string const & | input | ) |
Definition at line 277 of file base64.cpp.
std::string base64_encode | ( | std::string const & | input, |
size_t | line_length | ||
) |
Definition at line 272 of file base64.cpp.
std::string base64_encode | ( | std::vector< std::uint8_t > const & | input, |
size_t | line_length | ||
) |
Definition at line 267 of file base64.cpp.
std::string genesis::utils::base64_encode_ | ( | T const & | input, |
size_t | line_length | ||
) |
Definition at line 52 of file base64.cpp.
ForwardIt genesis::utils::binary_find | ( | ForwardIt | first, |
ForwardIt | last, | ||
const T & | value, | ||
Compare | comp = {} |
||
) |
Binary search on a sorted/partitioned range, returns an iterator to the element if found.
See https://en.cppreference.com/w/cpp/algorithm/lower_bound for details.
Definition at line 56 of file algorithm.hpp.
|
inline |
Compute the binomial coefficient, that is n
choose k
, for two integer numbers, for large numbers.
The precise integer function binomial_coefficient_int() can only handle values up to n == 62
(for non-small k
at least). That is, at n == 63, k == 29
, we have exhausted the range of 64bit numbers.
To also be able to work with larger n
and k
, we here offer an approximation that returns a double
value instead, and hence can compute binomial coefficients of up to n == 1029
(exclusive) for all values of k
, which for k == n/2
is about as large as double precision allows. The approximation is not quite up to double precision, and returns values with an error roughly in the range of e-12 for large numbers.
For n > 1029
, we attempt to compute this, which will work for smaller values of k
. In case this overflows the double
precision range, positive infinity is returned instead. The first such combination is n==1030
and k==500
, causing inf
to be returned.
The returned values for all n
and k
that are also valid with the integer version binomial_coefficient_int() yield identical results (up to float precision). That is, in particular for all n < 63
, as well as for larger n
with small k
. Note furthermore that we use a lookup table of factorials for the bulk of the computation here. Hence, for larger numbers, this function is also faster than explicity computing the values.
See also log_binomial_coefficient() for the log-space variant of this function.
Definition at line 99 of file binomial.hpp.
|
inline |
Local helper function to check that n and k are valid for a binomial coefficient.
Definition at line 427 of file binomial.cpp.
size_t binomial_coefficient_int | ( | size_t | n, |
size_t | k | ||
) |
Compute the binomial coefficient, that is n
choose k
, for two integer numbers.
The function throws for invalid arguments (n or k equal to 0, or k larger than n), or on overflow. For all n < 63
, this does not overflow with 64 bit numbers.
Definition at line 458 of file binomial.cpp.
|
inline |
Compute the probability mass function for a binomial distribution.
Note that we reverse the order of k
and n
here compared to binomial_coefficient() here, in order to comply with common notation.
We are working in log-space for the main part of the computation, and only translate back at the very end. For large n
, we are attempting to compute the distribution, but it might underflow. See binomial_coefficient() for details.
Definition at line 121 of file binomial.hpp.
std::string bitstring | ( | TwobitVector const & | vec | ) |
Return a string with a bit-representation of a TwobitVector.
It returns the words of the vector with bits in the order of the underlying integer type. This is mainly useful for debugging and testing.
Definition at line 124 of file utils/math/twobit_vector/functions.cpp.
std::string bitstring | ( | TwobitVector::WordType const & | vec | ) |
Return a string with a bit-representation of a TwobitVector::WordType.
It returns the word with bits in the order of the underlying integer type. This is mainly useful for debugging and testing.
Definition at line 140 of file utils/math/twobit_vector/functions.cpp.
Take the bitwise and
of two Bitvectors of potentially different size.
The function is the same as the normal version, but allows to use Bitvectors of different sizes. By default (use_larger == false
), we use the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m )
with m = min( lhs.size(), rhs.size() )
. If use_larger
is set however, the resulting Bitvector has the max size of the two inputs, with the bits at the end (the ones after m
) being false
.
Definition at line 45 of file utils/math/bitvector/operators.cpp.
Take the bitwise or
of two Bitvectors of potentially different size.
The function is the same as the normal version, but allows to use Bitvectors of different sizes. By default (use_larger == false
), we use the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m )
with m = min( lhs.size(), rhs.size() )
. If use_larger
is set however, the resulting Bitvector has the max size of the two inputs, with the bits at the end (the ones after m
) being false
.
Definition at line 58 of file utils/math/bitvector/operators.cpp.
Take the bitwise xor
of two Bitvectors of potentially different size.
The function is the same as the normal version, but allows to use Bitvectors of different sizes. By default (use_larger == false
), we use the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m )
with m = min( lhs.size(), rhs.size() )
. If use_larger
is set however, the resulting Bitvector has the max size of the two inputs, with the bits at the end (the ones after m
) being false
.
Definition at line 71 of file utils/math/bitvector/operators.cpp.
|
static |
|
constexprnoexcept |
std::string char_to_hex | ( | char | c, |
bool | full = true |
||
) |
Return the name and hex representation of a char
.
This is meant for user output, for example to warn about invalid input characters. Hence, by default, a text-representation is returned, using the form
LF (0x0A; control: NL line feed, new line) 'N' (0x4E; letter: capital N)
where non-printable characters are abbreviated by their symbol, and printable characters are included in single quotation marks.
Non-ASCII characters (those outside of the 0-127 interval) are written in the form
non-ASCII char (0xF7)
If full
is set to false
, just the two-byte hex presentation is returned (e.g., 4E
for N
).
std::string char_to_hex | ( | unsigned char | c, |
bool | full = true |
||
) |
Return the name and hex representation of a char
, given as an unsigned char
.
This overload is meant for situations were a text input is read from file as unsigned char
. The rest of the function is identical to char_to_hex( char, bool ), see there for details.
|
static |
|
static |
Definition at line 157 of file strict_fstream.cpp.
|
static |
Definition at line 177 of file strict_fstream.cpp.
|
static |
Definition at line 188 of file strict_fstream.cpp.
|
inline |
Definition at line 57 of file common.hpp.
void genesis::utils::closure | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the closure of a range of numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. Then, the closure [1] of the elements is calculated, that is, they are all divided by their total sum. This is used in compositional data analysis. Non-finite elements are ignored, negative elements throw an exception.
[1] J. Aitchison, "The statistical analysis of compositional data". Chapman and Hall London, 1986. https://www.jstor.org/stable/2345821
Definition at line 288 of file statistics.hpp.
|
inline |
Calculate the closure of a std::vector
of double
elements.
Definition at line 330 of file statistics.hpp.
|
inline |
Calculate the index of dispersion.
The coefficient of variation (CV), also known as the relative standard deviation (RSD), is defined as the ratio of the standard deviation to the mean. See mean_stddev() to calculate those values. See https://en.wikipedia.org/wiki/Coefficient_of_variation for details.
Definition at line 1125 of file statistics.hpp.
|
inline |
Calculate the index of dispersion.
The coefficient of variation (CV), also known as the relative standard deviation (RSD), is defined as the ratio of the standard deviation to the mean. See mean_stddev() to calculate those values. See https://en.wikipedia.org/wiki/Coefficient_of_variation for details.
Definition at line 1133 of file statistics.hpp.
Color color_from_bytes | ( | unsigned char | r, |
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a | ||
) |
Create a Color given three or four values in the range [ 0, 255 ]
for each of the components red, green and blue, and optionally alpha.
Definition at line 53 of file utils/color/functions.cpp.
Color color_from_hex | ( | std::string const & | hex_color, |
std::string const & | prefix = "#" |
||
) |
Create a Color given a hex color string in the format "#003366[ff]".
The hash sign in the beginning can be replaced by any given prefix. If the string is not correctly formatted, an std::invalid_argument exception is thrown. If the string contains only RGB, alpha is set to 1.0
.
Definition at line 63 of file utils/color/functions.cpp.
Color color_from_name | ( | std::string const & | name | ) |
Return the color represented by the given name, which is (currently) a shortcut for color_from_name_web() and color_from_name_xkcd().
Color color_from_name_lego | ( | std::string const & | name | ) |
Retrieve a named LEGO color by name.
Names are compared only by their alnum chars, and the letter case is ignored. If the color name does not exist, an std::invalid_argument
exception is thrown.
The colors are taken from the colors.csv.gz
table of the LEGO Catalog Database at https://rebrickable.com/downloads/ on 2024-06-17. They were published with the note
You can use these files for any purpose.
which we interpret as the table being in the public domain.
Color color_from_name_web | ( | std::string const & | name | ) |
Color color_from_name_xkcd | ( | std::string const & | name | ) |
Retrieve a named xkcd color by name.
Names are compared only by their alnum chars, and the letter case is ignored. If the color name does not exist, an std::invalid_argument
exception is thrown.
The colors are taken from an [https://xkcd.com/](xkcd) color survey. They were published under Public Domain, http://creativecommons.org/publicdomain/zero/1.0/. See https://xkcd.com/color/rgb/ and https://blog.xkcd.com/2010/05/03/color-survey-results/ for details. See also our Acknowledgements.
std::vector< Color > const & color_list_accent | ( | ) |
Color palette accent
.
Provides a color palette with 8 colors, 4 pale and 4 saturated, for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 158 of file list_qualitative.cpp.
std::vector< Color > const & color_list_blues | ( | ) |
Color palette blues
.
Provides a sequential blue color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1411 of file list_sequential.cpp.
std::vector< Color > const & color_list_brbg | ( | ) |
Color palette brbg
.
Provides a diverging color palette with brown low, white middle, and blue-green high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 200 of file list_diverging.cpp.
std::vector< Color > const & color_list_bugn | ( | ) |
Color palette bugn
.
Provides a sequential blue-green color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1416 of file list_sequential.cpp.
std::vector< Color > const & color_list_bupu | ( | ) |
Color palette bupu
.
Provides a sequential blue-purple color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1421 of file list_sequential.cpp.
std::vector< Color > const & color_list_bupubk | ( | ) |
Color Palette bupubk
.
Provides a sequential blue color palette of light blue, purple and black. Particularly useful for visualizing trees, as the light blue is still visible when used to color branches.
Definition at line 1406 of file list_sequential.cpp.
std::vector< Color > const & color_list_dark2 | ( | ) |
Color palette dark2
.
Provides a color palette with 8 dark colors based on color_list_set2() for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 163 of file list_qualitative.cpp.
std::vector< Color > const & color_list_diverging | ( | ColorListDiverging | palette | ) |
Definition at line 249 of file list_diverging.cpp.
std::vector< Color > const & color_list_diverging | ( | std::string const & | palette | ) |
Definition at line 282 of file list_diverging.cpp.
std::vector< std::string > color_list_diverging_names | ( | ) |
Definition at line 317 of file list_diverging.cpp.
std::vector< Color > const & color_list_gnbu | ( | ) |
Color palette gnbu
.
Provides a sequential green-blue color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1426 of file list_sequential.cpp.
std::vector< Color > const & color_list_greens | ( | ) |
Color palette greens
.
Provides a sequential green color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1431 of file list_sequential.cpp.
std::vector< Color > const & color_list_greys | ( | ) |
Color palette greys
.
Provides a sequential grey color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1436 of file list_sequential.cpp.
std::vector< Color > const & color_list_heat | ( | ) |
Color palette heat
.
Provides a sequential heat color palette from white via yellow to orange and red.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1501 of file list_sequential.cpp.
std::vector< Color > const & color_list_inferno | ( | ) |
Color palette inferno
.
This Matplotlib color palette is adapted from https://github.com/BIDS/colormap. New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and Eric Firing. The colormaps are released under the CC0 license / public domain dedication. See https://creativecommons.org/publicdomain/zero/1.0/ for the license. See also our Acknowledgements.
Definition at line 1511 of file list_sequential.cpp.
std::vector< Color > const & color_list_magma | ( | ) |
Color palette magma
.
This Matplotlib color palette is adapted from https://github.com/BIDS/colormap. New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and Eric Firing. The colormaps are released under the CC0 license / public domain dedication. See https://creativecommons.org/publicdomain/zero/1.0/ for the license. See also our Acknowledgements.
Definition at line 1506 of file list_sequential.cpp.
std::vector< Color > const & color_list_misc | ( | ColorListMisc | palette | ) |
Definition at line 480 of file list_misc.cpp.
std::vector< Color > const & color_list_misc | ( | std::string const & | palette | ) |
Definition at line 489 of file list_misc.cpp.
std::vector< std::string > color_list_misc_names | ( | ) |
Definition at line 500 of file list_misc.cpp.
std::vector< Color > const & color_list_nextstrain | ( | ) |
Color palette from the the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov.
The palette starts at purple and blue, progresses via green and yellow, towards orange and red. This function returns a palette with 256 entries. The original palette also has a reduced set of colors when using < 16 entries. We made these available via the color_list_nextstrain( size_t n ) function, see there for details.
This color palette is adapted from the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov, using their color scheme https://github.com/nextstrain/ncov/blob/master/config/color_schemes.tsv and converting parts of it to RGB double
values. The repository at https://github.com/nextstrain/ncov is published under the MIT license. See also our Acknowledgements.
Definition at line 471 of file list_misc.cpp.
std::vector< Color > color_list_nextstrain | ( | size_t | n | ) |
Color palette from the the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov.
The original palette has a reduced set of colors when using < 16 entries. This function makes these reduced color sets available when using n < 16
. All values above that use the full palette (with 256) and interpolate to the requested number of entries. NB: The original palette continues to 500 colors as well, but the differences between adjacent entries are diminishing, so that our approach of interpolation when requesting a palette with more than 256 entries yields highly similar entries. Also, who needs a palette with that many entries anyway?!
This color palette is adapted from the Nextstrain build for novel coronavirus (nCoV) at https://nextstrain.org/ncov, using their color scheme https://github.com/nextstrain/ncov/blob/master/config/color_schemes.tsv and converting parts of it to RGB double
values. The repository at https://github.com/nextstrain/ncov is published under the MIT license. See also our Acknowledgements.
Definition at line 460 of file list_misc.cpp.
std::vector< Color > const & color_list_oranges | ( | ) |
Color palette oranges
.
Provides a sequential orange color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1441 of file list_sequential.cpp.
std::vector< Color > const & color_list_orrd | ( | ) |
Color palette orrd
.
Provides a sequential orange-red color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1446 of file list_sequential.cpp.
std::vector< Color > const & color_list_paired | ( | ) |
Color palette paired
.
Provides a color palette with 12 colors in 6 pairs for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 168 of file list_qualitative.cpp.
std::vector< Color > const & color_list_pastel1 | ( | ) |
Color palette pastel1
.
Provides a color palette with 9 colors based on color_list_set1() for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 173 of file list_qualitative.cpp.
std::vector< Color > const & color_list_pastel2 | ( | ) |
Color palette pastel2
.
Provides a color palette with 9 colors based on color_list_set2() for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 178 of file list_qualitative.cpp.
std::vector< Color > const & color_list_piyg | ( | ) |
Color palette piyg
.
Provides a diverging color palette with pink low, white middle, and yellow-green high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 205 of file list_diverging.cpp.
std::vector< Color > const & color_list_plasma | ( | ) |
Color palette plasma
.
This Matplotlib color palette is adapted from https://github.com/BIDS/colormap. New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and Eric Firing. The colormaps are released under the CC0 license / public domain dedication. See https://creativecommons.org/publicdomain/zero/1.0/ for the license. See also our Acknowledgements.
Definition at line 1516 of file list_sequential.cpp.
std::vector< Color > const & color_list_prgn | ( | ) |
Color palette prgn
.
Provides a diverging color palette with purple low, white middle, and green high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 210 of file list_diverging.cpp.
std::vector< Color > const & color_list_pubu | ( | ) |
Color palette pubu
.
Provides a sequential purple-blue color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1451 of file list_sequential.cpp.
std::vector< Color > const & color_list_pubugn | ( | ) |
Color palette pubugn
.
Provides a sequential purple-blue-green color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1456 of file list_sequential.cpp.
std::vector< Color > const & color_list_puor | ( | ) |
Color palette puor
.
Provides a diverging color palette with orange low, white middle, and purple high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 215 of file list_diverging.cpp.
std::vector< Color > const & color_list_purd | ( | ) |
Color palette purd
.
Provides a sequential purple-red color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1461 of file list_sequential.cpp.
std::vector< Color > const & color_list_purples | ( | ) |
Color palette purples
.
Provides a sequential purple color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1466 of file list_sequential.cpp.
std::vector< Color > const & color_list_qualitative | ( | ColorListQualitative | palette | ) |
Definition at line 202 of file list_qualitative.cpp.
std::vector< Color > const & color_list_qualitative | ( | std::string const & | palette | ) |
Definition at line 232 of file list_qualitative.cpp.
std::vector< std::string > color_list_qualitative_names | ( | ) |
Definition at line 264 of file list_qualitative.cpp.
std::vector< Color > const & color_list_rdbu | ( | ) |
Color palette rdbu
.
Provides a diverging color palette with red low, white middle, and blue high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 220 of file list_diverging.cpp.
std::vector< Color > const & color_list_rdgy | ( | ) |
Color palette rdgy
.
Provides a diverging color palette with red low, white middle, and grey high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 225 of file list_diverging.cpp.
std::vector< Color > const & color_list_rdpu | ( | ) |
Color palette rdpu
.
Provides a sequential red-purple color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1471 of file list_sequential.cpp.
std::vector< Color > const & color_list_rdylbu | ( | ) |
Color palette rdylbu
.
Provides a diverging color palette with red low, pale yellow middle, and blue high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 230 of file list_diverging.cpp.
std::vector< Color > const & color_list_rdylgn | ( | ) |
Color palette rdylgn
.
Provides a diverging color palette with red low, pale yellow middle, and green high.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 235 of file list_diverging.cpp.
std::vector< Color > const & color_list_reds | ( | ) |
Color palette reds
.
Provides a sequential red color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1476 of file list_sequential.cpp.
std::vector< Color > const & color_list_sequential | ( | ColorListSequential | palette | ) |
Definition at line 1530 of file list_sequential.cpp.
std::vector< Color > const & color_list_sequential | ( | std::string const & | palette | ) |
Definition at line 1608 of file list_sequential.cpp.
std::vector< std::string > color_list_sequential_names | ( | ) |
Definition at line 1688 of file list_sequential.cpp.
std::vector< Color > const & color_list_set1 | ( | ) |
Color palette set1
.
Provides a color palette with 9 easy-to-name colors for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 183 of file list_qualitative.cpp.
std::vector< Color > const & color_list_set2 | ( | ) |
Color palette set2
.
Provides a color palette with 8 hard-to-name colors for use with qualitative/categorical data.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 188 of file list_qualitative.cpp.
std::vector< Color > const & color_list_set3 | ( | ) |
Color palette set3
.
Provides a color palette with 12 colors for use with qualitative/categorical data. The colors are more saturated than the Pastels but less so than set2().
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 193 of file list_qualitative.cpp.
std::vector< Color > const & color_list_spectral | ( | ) |
Color palette spectral
.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 240 of file list_diverging.cpp.
std::vector< Color > const & color_list_viridis | ( | ) |
Color palette viridis
.
This Matplotlib color palette is adapted from https://github.com/BIDS/colormap. New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and Eric Firing. The colormaps are released under the CC0 license / public domain dedication. See https://creativecommons.org/publicdomain/zero/1.0/ for the license. See also our Acknowledgements.
Definition at line 1521 of file list_sequential.cpp.
std::vector< Color > const & color_list_ylgn | ( | ) |
Color palette ylgn
.
Provides a sequential yellow-green color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1481 of file list_sequential.cpp.
std::vector< Color > const & color_list_ylgnbu | ( | ) |
Color palette ylgnbu
.
Provides a sequential yellow-green-blue color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1486 of file list_sequential.cpp.
std::vector< Color > const & color_list_ylorbr | ( | ) |
Color palette ylorbr
.
Provides a sequential yellow-orange-brown color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1491 of file list_sequential.cpp.
std::vector< Color > const & color_list_ylorrd | ( | ) |
Color palette ylorrd
.
Provides a sequential yellow-orange-red color palette of increasing saturation.
Provides a diverging rainbow color palette with red low, pale yellow middle, and blue high.
This ColorBrewer color palette is adapted from https://github.com/axismaps/colorbrewer and https://github.com/Gnuplotting/gnuplot-palettes by converting the colors to RGB double
values. The original ColorBrewer color specifications and designs were developed by Cynthia Brewer (http://colorbrewer.org/), while their gnuplot equivalets are authored by Anna Schneider, and published under the Apache-2.0 license. See also our Acknowledgements.
Definition at line 1496 of file list_sequential.cpp.
std::map< double, Color > color_stops | ( | ColorMap const & | map, |
ColorNormalization const & | norm | ||
) |
Definition at line 53 of file helpers.cpp.
std::map< double, Color > color_stops | ( | ColorMap const & | map, |
ColorNormalizationBoundary const & | norm | ||
) |
Definition at line 138 of file helpers.cpp.
std::map< double, Color > color_stops | ( | ColorMap const & | map, |
ColorNormalizationDiverging const & | norm | ||
) |
Definition at line 94 of file helpers.cpp.
std::map< double, Color > color_stops | ( | ColorMap const & | map, |
ColorNormalizationLinear const & | norm | ||
) |
Definition at line 78 of file helpers.cpp.
std::map< double, Color > color_stops | ( | ColorMap const & | map, |
ColorNormalizationLogarithmic const & | norm | ||
) |
Definition at line 89 of file helpers.cpp.
std::map< double, std::string > color_tickmarks | ( | ColorNormalization const & | norm, |
size_t | num_ticks | ||
) |
Definition at line 157 of file helpers.cpp.
std::map< double, std::string > color_tickmarks | ( | ColorNormalizationBoundary const & | norm, |
size_t | num_ticks | ||
) |
Definition at line 262 of file helpers.cpp.
std::map< double, std::string > color_tickmarks | ( | ColorNormalizationDiverging const & | norm, |
size_t | num_ticks | ||
) |
Definition at line 215 of file helpers.cpp.
std::map< double, std::string > color_tickmarks | ( | ColorNormalizationLinear const & | norm, |
size_t | num_ticks | ||
) |
Definition at line 182 of file helpers.cpp.
std::map< double, std::string > color_tickmarks | ( | ColorNormalizationLogarithmic const & | norm, |
size_t | num_ticks | ||
) |
Definition at line 193 of file helpers.cpp.
std::string color_to_hex | ( | Color const & | c, |
std::string const & | prefix = "#" , |
||
bool | uppercase = false , |
||
bool | with_alpha = false |
||
) |
Return a hex string representation of a Color in the format "#003366[ff]".
The hash sign in the beginning can be replaced by any given prefix
. If uppercase
is set to true
, any outputted alphabetical chars (that is, A to F for hex strings) are uppercase. if with_alpha
is set to true
, two additional hex digits are printed for the alpha channel.
Definition at line 100 of file utils/color/functions.cpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
int compare_natural | ( | std::string const & | lhs, |
std::string const & | rhs | ||
) |
Compare two strings with natural human sorting, that is "A1", "A2", "A100", instead of the standard sort by ASCII value "A1", "A100", "A2".
Returns negavie if lhs
< rhs
, 0
if they are equal, and positive if lhs
> rhs
.
Definition at line 341 of file string.cpp.
|
inlineconstexpr |
Three-way comparison (spaceship operator) for C++ <20.
Return -1
if lhs < rhs
, return +1
if lhs > rhs
, return 0
if lhs == rhs
, for arithmetic types.
Definition at line 145 of file common.hpp.
|
inline |
Returns whether a container object has a certain element.
The usage of std::find just to check for presence of a certain item is a bit cumbersome. This template simply takes any container and a value and returns true iff the value is present in the container.
Definition at line 74 of file algorithm.hpp.
bool contains_ci | ( | std::vector< std::string > const & | haystack, |
std::string const & | needle | ||
) |
Return whether a vector of strings contains a given string, case insensitive.
Definition at line 59 of file string.cpp.
bool contains_ci_alnum | ( | std::vector< std::string > const & | haystack, |
std::string const & | needle | ||
) |
Return whether a vector of strings contains a given string, case insensitive, and ignoring all non-alphanumerical characters.
Definition at line 71 of file string.cpp.
|
inline |
Return whether a container contains duplicates.
The container does not need to be sorted. For speed, the function internally copies the elements of the container.
Definition at line 86 of file algorithm.hpp.
T genesis::utils::convert_from_string | ( | std::string const & | str, |
bool | trim = false |
||
) |
Generic conversion from string to any data type that is supported by std::stringsteam operator >>
.
This function is useful for general conversion. It throw when the string cannot be fully converted. That is, if there is more content after the converted value. If trim
is false
(default), this is also affected by white space. In that case, the value to be parsed has to be the only content of the input string.
Definition at line 59 of file convert.hpp.
|
inline |
Specialization of the generic conversion function for double
, which also takes nan
and inf
into account.
Definition at line 101 of file convert.hpp.
|
inline |
Specialization of the generic conversion function for std::string
.
Definition at line 89 of file convert.hpp.
GeoCoordinate convert_geo_coordinate | ( | std::string const & | coordinate | ) |
Parse a string of geographic coordinates.
The function accepts many different formats for geographical coordinates. Some exemplary valid cases:
50d4m17.698N 14d24m2.826E
40:26:46N,79:56:55W
40:26:46.302N 179:56:55.903W
49°59'56.948"N, 15°48'22.989"E
50d4m17.698N 14d24m2.826E
49.9991522N, 150.8063858E
40°26′47″N 79°58′36″W
40d 26′ 47″ N 79d 58′ 36″ W
40.446195N 79.948862W
40,446195° 79,948862°
40° 26.7717 / -79° 56.93172
40.446195, -79.948862
N 49° 59.94913', E 15° 48.38315'
The hemispheres can be given as [NS]
for the first component and [EW]
for the second, and can either preceed or follow the numeric values. Degrees, Minutes and Seconds can be separated by the letters [dms]
, by degree (°
), prime ( ′ 
), single quotation mark (‘’), double prime (
″), double quoation mark (
"), or by colons (
:), respectively. The two components (NS and EW) can be separated by comma (
,) or slash (
/`).
There are some caveats: The hemisphere strings (NESW
) have to be in capitial letters, while the letters used for degrees, minute and seconds (dms
) have to be lower case. This constraint avoids ambiguity between seconds (s
) and south (S
). Also, either the decimal separator can be a comma, or the separator between components, but not both. This again avoids ambiguity while parsing.
Definition at line 255 of file utils/tools/geodesy/functions.cpp.
GeoCoordinate convert_geo_coordinate | ( | std::string const & | latitude, |
std::string const & | longitude | ||
) |
Parse strings of geographic coordinates.
This is the same as convert_geo_coordinate( std::string const& ), with the only different being that the two components (NW and EW) are given separately. See there for details.
Definition at line 250 of file utils/tools/geodesy/functions.cpp.
|
static |
Local helper function that takes parts of the regex matches and converts them to double.
The strings h1
, d
, m
, s
and h2
are the matches of the regex. The parameter component
is the hemisphere of this coordinate component, NS or EW, which is determined by whether the matches are the first or the second component of the coordinate.
Definition at line 70 of file utils/tools/geodesy/functions.cpp.
void convert_to_bool | ( | Dataframe & | df, |
size_t | col_index | ||
) |
Definition at line 156 of file utils/containers/dataframe/operators.cpp.
void convert_to_bool | ( | Dataframe & | df, |
std::string const & | col_name | ||
) |
Definition at line 186 of file utils/containers/dataframe/operators.cpp.
std::vector<bool> genesis::utils::convert_to_bool | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Definition at line 144 of file convert.hpp.
bool convert_to_bool | ( | std::string const & | str | ) |
Convert a string to bool, return the result, and throw an exception when the conversion was not successful.
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as false
), with all text case insensitive.
Definition at line 65 of file convert.cpp.
bool convert_to_bool | ( | std::string const & | str, |
bool & | result | ||
) |
Convert a string to bool, store the result in result
, and return whether the conversion as successful.
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as false
), with all text case insensitive.
Definition at line 49 of file convert.cpp.
std::vector<double> genesis::utils::convert_to_bool_double | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Definition at line 207 of file convert.hpp.
double convert_to_bool_double | ( | std::string const & | str | ) |
Convert a string to bool, but return it as a double, and throw an exception when the conversion was not successful.
This conversion is useful to work with dataframes that are all double, for example to work with our Generalized Linear Model implementation, see glm_fit().
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as quiet_NaN
), with all text case insensitive.
Definition at line 103 of file convert.cpp.
bool convert_to_bool_double | ( | std::string const & | str, |
double & | result | ||
) |
Convert a string to bool, but store the result as a double in result
, and return whether the conversion as successful.
This conversion is useful to work with dataframes that are all double, for example to work with our Generalized Linear Model implementation, see glm_fit().
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as quiet_NaN
), with all text case insensitive.
Definition at line 84 of file convert.cpp.
void convert_to_double | ( | Dataframe & | df, |
size_t | col_index | ||
) |
Definition at line 192 of file utils/containers/dataframe/operators.cpp.
void convert_to_double | ( | Dataframe & | df, |
std::string const & | col_name | ||
) |
Definition at line 206 of file utils/containers/dataframe/operators.cpp.
std::vector<double> genesis::utils::convert_to_double | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Definition at line 260 of file convert.hpp.
double convert_to_double | ( | std::string const & | str | ) |
Convert a string to double, return the result, and throw an exception when the conversion was not successful.
Definition at line 161 of file convert.cpp.
bool convert_to_double | ( | std::string const & | str, |
double & | result | ||
) |
Convert a string to double, store the result in result
, and return whether the conversion as successful.
Definition at line 150 of file convert.cpp.
bool genesis::utils::convert_to_numeric_ | ( | std::string const & | str, |
T & | result, | ||
T | initial, | ||
F | conversion | ||
) |
Definition at line 123 of file convert.cpp.
|
static |
std::vector<long long> genesis::utils::convert_to_signed_integer | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Definition at line 313 of file convert.hpp.
long long convert_to_signed_integer | ( | std::string const & | str | ) |
Convert a string to signed integer, return the result, and throw an exception when the conversion was not successful.
Definition at line 193 of file convert.cpp.
bool convert_to_signed_integer | ( | std::string const & | str, |
long long & | result | ||
) |
Convert a string to signed integer, store the result in result
, and return whether the conversion as successful.
Definition at line 182 of file convert.cpp.
std::vector<std::tm> genesis::utils::convert_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Convert a list of std::string
to std::tm
date/time objects, if possible. Throw otherwise.
The function tries to guess the format. See convert_to_tm( std::string const& ) for details. For long lists, this can be expensive, as the formats are tried again for each entry separately.
If the size
of the list is known, this can be given to reserve that much memory first.
Definition at line 314 of file date_time.hpp.
std::vector<std::tm> genesis::utils::convert_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::string const & | format, | ||
size_t | size = 0 |
||
) |
Convert a list of std::string
to std::tm
date/time objects, if possible. Throw otherwise.
The function uses the given format
. See convert_to_tm( std::string const&, std::string const& ) for details.
If the size
of the list is known, this can be given to reserve that much memory first.
Definition at line 287 of file date_time.hpp.
std::vector<std::tm> genesis::utils::convert_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::string const & | format, | ||
std::string const & | locale, | ||
size_t | size = 0 |
||
) |
Convert a list of std::string
to std::tm
date/time objects, if possible. Throw otherwise.
The function uses the given format
and locale
. See convert_to_tm( std::string const&, std::string const&, std::string const& ) for details.
If the size
of the list is known, this can be given to reserve that much memory first.
Definition at line 260 of file date_time.hpp.
std::tm convert_to_tm | ( | std::string const & | str | ) |
Convert a std::string
to a std::tm
date/time object, if possible. Throw otherwise.
The function tries different common formats for convenience, in the following order: First only dates, then dates/times combined, last only times. The reasoning for that order is that in most typical scientific datasets, the day is more relevant than the exact time during the day, so they mostly likely contain dates only.
The exact formats that are tried are as follows:
# | Format | Type | Explanation | Example |
---|---|---|---|---|
1 | %Y-%m-%d | Date | ISO 8601 extended format | 2020-04-17 |
2 | %Y%m%d | Date | ISO 8601 basic format | 20200417 |
3 | %Y-%m-%dT%H:%M:%S | Date/Time | ISO 8601 extended format | 2020-04-17T00:27:58 |
4 | %Y-%m-%d %H:%M:%S | Date/Time | ISO 8601 extended format, but separated by a whitespace, as allowed in RFC 3339 | 2020-04-17 00:27:58 |
5 | %Y%m%dT%H%M%S | Date/Time | ISO 8601 basic format | 20200417T002758 |
6 | %Y%m%d %H%M%S | Date/Time | ISO 8601 basic format, but separated by a whitespace | 20200417 002758 |
7 | %Y%m%d%H%M%S | Date/Time | ISO 8601 basic format, with no separator | 20200417002758 |
8 | %H:%M:%S | Time | ISO 8601 extended format | 00:27:58 |
9 | %H%M%S | Time | ISO 8601 basic format | 002758 |
While this will most likely be able to parse any given date/time string that is used in scientific data, it is almost certainly slower than setting the format manually, if known, using the function convert_to_tm( std::string const&, std::string const& )
More exotic formats, such as the stupid US format 04/17/2020, or the slighly more reasonable UK format 17/04/2020, are not tried, as they might be mistaken for one another. Furthermore, time zone information is not used and leads to an exception being thrown (e.g., "2020-04-06T00:27:58+00:00" or "20200406T002758Z"). If those are needed, they have to be specified, again using the function convert_to_tm( std::string const&, std::string const& )
Definition at line 341 of file date_time.cpp.
std::tm convert_to_tm | ( | std::string const & | str, |
std::string const & | format | ||
) |
Convert a std::string
to a std::tm
date/time object, if possible. Throw otherwise.
For a list of the available format
parameters, see https://en.cppreference.com/w/cpp/io/manip/get_time or http://www.cplusplus.com/reference/ctime/strftime/
The function tries different std::locale settings for convenience, in the order "C"
(POSIX), "en_US.UTF-8"
, and ""
(user-preferred). If a format
is used that does not depend on the locale, this does not induce a performance penalty. In order to also specify the locale, use convert_to_tm( std::string const&, std::string const&, std::string const& ) instead.
Definition at line 325 of file date_time.cpp.
std::tm convert_to_tm | ( | std::string const & | str, |
std::string const & | format, | ||
std::string const & | locale | ||
) |
Convert a std::string
to a std::tm
date/time object, if possible. Throw otherwise.
For a list of the available format
parameters, see https://en.cppreference.com/w/cpp/io/manip/get_time or http://www.cplusplus.com/reference/ctime/strftime/
The available locale
strings depend on the operating system and user settings. Typically, on Unix/Linux/POSIX/MacOS machines, the command locale -a
should give a valid list.
Definition at line 314 of file date_time.cpp.
bool genesis::utils::convert_to_tm_ | ( | std::string const & | str, |
std::string const & | format, | ||
std::string const & | locale, | ||
std::tm & | t | ||
) |
Local helper function that does the heavy load of time conversion.
We use this variant, which returns its success, to not have to try catch
in the functions that guess the format.
Definition at line 242 of file date_time.cpp.
void genesis::utils::convert_to_type_ | ( | Dataframe & | df, |
size_t | col_index | ||
) |
Definition at line 111 of file utils/containers/dataframe/operators.cpp.
void genesis::utils::convert_to_type_ | ( | Dataframe & | df, |
size_t | col_index | ||
) |
Definition at line 123 of file utils/containers/dataframe/operators.cpp.
std::vector<unsigned long long> genesis::utils::convert_to_unsigned_integer | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | size = 0 |
||
) |
Definition at line 366 of file convert.hpp.
unsigned long long convert_to_unsigned_integer | ( | std::string const & | str | ) |
Convert a string to unsigned integer, return the result, and throw an exception when the conversion was not successful.
Definition at line 225 of file convert.cpp.
bool convert_to_unsigned_integer | ( | std::string const & | str, |
unsigned long long & | result | ||
) |
Convert a string to unsigned integer, store the result in result
, and return whether the conversion as successful.
Definition at line 214 of file convert.cpp.
Calculate the correlation Matrix of a given data
Matrix.
This is done by standardizing the mean and variance of the given data
and then calculating the sums_of_squares_and_cross_products_matrix().
Definition at line 197 of file math/matrix.cpp.
std::pair<size_t, size_t> genesis::utils::count_finite_elements | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Count the number of finite elements in a range of double values.
The function iterates a range of values that are expected to be double values. It uses std::isfinite
as criterion for validity of the values.
The return value is a pair containing the number of finite elements as first
, and the number of total number elements in the range as second
(the size of the range).
Definition at line 150 of file statistics.hpp.
size_t count_substring_occurrences | ( | std::string const & | str, |
std::string const & | sub | ||
) |
Return the number of (possibly overlapping) occurrences of a substring in a string.
Definition at line 518 of file string.cpp.
Calculate the covariance Matrix of a given data
Matrix.
This is done by standardizing the mean of the given data
and then calculating the sums_of_squares_and_cross_products_matrix().
Definition at line 211 of file math/matrix.cpp.
|
inlineconstexpr |
Cube of a number.
Simply \( x^3 \), but faster than std::pow
for the low exponent. Meant as an abbreviation where the argument is not already a variable, e.g., cubed( x - 1.0 )
, without the need to store the intermediate argument term.
Definition at line 235 of file common.hpp.
std::string current_date | ( | ) |
Returns the current date as a string in the format "2014-12-31".
Definition at line 68 of file date_time.cpp.
std::string current_path | ( | ) |
Return the current (working) directory, simiar to getcwd().
The function behaves similar to getcwd(). The path is returned with a trailing slash, for conveniently apppending file names to it.
As this function changes the directory in the process, it is not thread safe.
|
static |
|
static |
std::string current_time | ( | ) |
Returns the current time as a string in the format "13:37:42".
Definition at line 88 of file date_time.cpp.
char deescape | ( | char | c | ) |
Return the de-escaped char for a backslash-escaped char.
The function takes the char that follows a backslash in an escaped string and returns its de-escaped char. That is, n
is turned into a new line (\n
), t
is turned into a tab (\t
) and r
is turned into a carrier return (\r
). All other chars (e.g., quotation marks or the backslash itself) are simply returned as-is.
Definition at line 980 of file string.cpp.
std::string deescape | ( | std::string const & | text | ) |
Return a string where backslash-escaped characters are transformed into their respective string form.
All occurrences of backslash + char
in the string are de-escaped. That is, all \n
, \t
and \r
are turned into their respective control sequences, while all other chars folloing a backslash are translated into the char itself (so that e.g., quotation marks or backslashes themself can be escaped).
Also see deescape( char c ).
Definition at line 958 of file string.cpp.
|
inline |
Sort two values in descending order, inplace.
Definition at line 81 of file common.hpp.
void dir_create | ( | std::string const & | path, |
bool | with_parents = true |
||
) |
bool dir_exists | ( | std::string const & | dir | ) |
std::vector< std::string > dir_list_contents | ( | std::string const & | dir, |
bool | full_path = false , |
||
std::string const & | regex = "" |
||
) |
Get a list of files and directories in a directory.
If full_path
is set to true
, the path of the provided dir
is prepended to the resulting list. If a non-empy regex
is provided, file names are filtered by this regular expression.
If the directory is not readable, the function throws std::runtime_error
.
|
static |
std::vector< std::string > dir_list_directories | ( | std::string const & | dir, |
bool | full_path = false , |
||
std::string const & | regex = "" |
||
) |
Get a list of directories in a directory.
Behaves the same as dir_list_contents(), except tat only directories are listed (i.e., no files). See there for an explanation of the arguments.
std::vector< std::string > dir_list_files | ( | std::string const & | dir, |
bool | full_path = false , |
||
std::string const & | regex = "" |
||
) |
Get a list of files in a directory.
Behaves the same as dir_list_contents(), except tat only files are listed (i.e., no directories). See there for an explanation of the arguments.
std::string dir_normalize_path | ( | std::string const & | path | ) |
TableLayout double_frame | ( | bool | condensed | ) |
Definition at line 573 of file utils/text/table.cpp.
TableLayout double_grid | ( | bool | condensed | ) |
Definition at line 554 of file utils/text/table.cpp.
Definition at line 48 of file utils/math/histogram/distances.cpp.
bool ends_with | ( | std::string const & | text, |
std::string const & | suffix | ||
) |
Return whether a string ends with another string, i.e., check for a suffix
.
Definition at line 230 of file string.cpp.
bool ends_with | ( | std::string const & | text, |
std::string const & | suffix, | ||
std::string & | prefix | ||
) |
Return whether a string ends with another string, i.e., check for a suffix
.
This version of the function then stores the prefix
of the matched text
, containing all leading characters that did not match the suffix
pattern. If there is no match, the prefix
is left unchanged.
Definition at line 238 of file string.cpp.
bool ends_with_ci | ( | std::string const & | text, |
std::string const & | suffix | ||
) |
Return whether a string ends with another string, i.e., check for a suffix, case insensitive.
Definition at line 248 of file string.cpp.
bool ends_with_ci | ( | std::string const & | text, |
std::string const & | suffix, | ||
std::string & | prefix | ||
) |
Return whether a string ends with another string, i.e., check for a suffix, case insensitive.
This version of the function then stores the prefix
of the matched text
, containing all leading characters that did not match the suffix
pattern. If there is no match, the prefix
is left unchanged.
Definition at line 254 of file string.cpp.
bool ends_with_ci_alnum | ( | std::string const & | text, |
std::string const & | suffix | ||
) |
Return whether a string ends with another string (suffix), comparing case-independent, and ignoring all non-alphanumerical characters.
For example, "S2-1.sorted:1.REF_CNT"
ends with "[ref-cnt]"
, according to this function.
Definition at line 264 of file string.cpp.
bool ends_with_ci_alnum | ( | std::string const & | text, |
std::string const & | suffix, | ||
std::string & | prefix, | ||
bool | trim_prefix = false |
||
) |
Return whether a string ends with another string (suffix), comparing case-independent, and ignoring all non-alphanumerical characters.
For example, "S2-1.sorted:1.REF_CNT"
ends with "[ref-cnt]"
, according to this function.
This version of the function then stores the prefix
of the matched text
, containing all leading characters that did not match the suffix
pattern. If there is no match, the prefix
is left unchanged.
If additionally trim_prefix
is set, all trailing non-alphanumerical characters of the prefix
are removed. For example, "S2-1.sorted:1.REF_CNT"
ends with "[ref-cnt]"
, and then contains the prefix "S2-1.sorted:1."
- with trim_prefix
, this is reduced to "S2-1.sorted:1"
instead.
Definition at line 271 of file string.cpp.
Definition at line 55 of file histogram.cpp.
bool equals_ci | ( | std::string const & | lhs, |
std::string const & | rhs | ||
) |
Compare two strings, case insensitive.
Definition at line 114 of file string.cpp.
bool equals_ci_alnum | ( | std::string const & | lhs, |
std::string const & | rhs | ||
) |
Compare two strings, case insensitive, and ignoring all non-alphanumerical characters.
Definition at line 128 of file string.cpp.
|
inline |
Erases all elements from the container that satisfy a given predicate. An element is erased, if the predicate evaluates to true for it. The predicate needs to have a signature similar to (T const&)->bool.
c | The container to modify. |
p | The predicate to satisfy. |
Definition at line 107 of file algorithm.hpp.
std::string escape | ( | std::string const & | text | ) |
Return a string where special chars are replaces by their escape sequence.
All new lines are transformed into either \r or \n, tabs into \t. Double quotation marks are preceeded by a backslash, also the backslash itself will be escaped, so that "</tt> becomes <tt>\\"
and \
becomes \\
.
Definition at line 930 of file string.cpp.
double genesis::utils::euclidean_distance | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b | ||
) |
Calculate the Euclidean norm (L2 norm) distance between two (mathematical) vectors.
The function is a more expressive version of p_norm_distance( ForwardIteratorA, ForwardIteratorA, ForwardIteratorB, ForwardIteratorB, double ) with p == 2.0
. See there for details.
Definition at line 381 of file distance.hpp.
|
inline |
Calculate the Euclidean norm (L2 norm) distance between two vectors of double
elements.
The function is a more expressive version of p_norm_distance( std::vector<double> const&, std::vector<double> const&, double ) with p == 2.0
. See there for details.
Definition at line 395 of file distance.hpp.
Calculate the pairwise euclidean distance matrix between the rows of a given matrix.
See p_norm_distance_matrix() for details. This function simply uses a fixed p == 2.0
for more expressive code.
Definition at line 110 of file distance.cpp.
double genesis::utils::euclidean_norm | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the Euclidean norm (L2 norm) of a range of numbers.
The function is a more expressive version of p_norm( ForwardIterator, ForwardIterator, double ) with p == 2.0
. See there for details.
Definition at line 154 of file distance.hpp.
|
inline |
Calculate the Euclidean norm (L2 norm) of a std::vector
of double
elements.
The function is a more expressive version of p_norm( std::vector<double> const&, double ) with p == 2.0
. See there for details.
Definition at line 165 of file distance.hpp.
TableLayout extended_frame | ( | bool | condensed | ) |
Definition at line 523 of file utils/text/table.cpp.
TableLayout extended_grid | ( | bool | condensed | ) |
Definition at line 504 of file utils/text/table.cpp.
void file_append | ( | std::string const & | content, |
std::string const & | filename, | ||
bool | create_dirs = true |
||
) |
std::string file_basename | ( | std::string const & | filename | ) |
std::string file_basename | ( | std::string const & | filename, |
std::vector< std::string > const & | remove_extensions | ||
) |
Remove the directory name from a file name if present, and remove a list of given extensions.
After obtaining the file basename (the final rightmost segment of the file path after the last directory seperator /
), the remove_extensions
are also removed from the file name. The given list is iterated regularly, and removed (from right to left, as these are suffixes) from the file name, if present.
For example:
std::string path = "/path/to/filename.txt.gz"; std::cout << file_basename( path, { ".gz", ".txt" }) << "\n";
yields "filename". This is useful for example to remove a set of known extensions for a file type, for clean user output. Not all extensions have to be present; those that are not, are simply skipped.
bool file_exists | ( | std::string const & | filename | ) |
Return true iff the file exists (and is in fact a file, and not, e.g., a directory).
Internally, this function simply returns the value of file_is_readable(), meaning that we also check that the file can actually be read. That is semantically a bit different from just stating that it is a file... But file system stuff in C++ pre-17 is hard, and this works for now.
std::string file_extension | ( | std::string const & | filename | ) |
Return the extension name of a file.
Also see file_filename().
std::string file_filename | ( | std::string const & | filename | ) |
Remove extension if present.
Caveat: Does not remove the path. So, if the filename itself does not contain an extension separator ".", but the path does, this will yield an unwanted result. Call file_basename() first.
std::unordered_map< std::string, std::string > file_info | ( | std::string const & | filename | ) |
bool file_is_readable | ( | std::string const & | filename | ) |
Return whether a file is readable.
For this, the file has to exist, and be accessible. Another potential error is that too many files are opened already.
See file_is_readable( std::string const&, std::string& ) for a version of the function that also allows to retrieve the error message in cases where the result is false
.
bool file_is_readable | ( | std::string const & | filename, |
std::string & | err_str | ||
) |
|
inline |
Helper function to obtain an output stream to a file.
This function is used internally by all file writers. It makes sure that the file is writable, and throws an exception otherwise.
Furthermore, the function checks whether the path already exists. If it exists and Options::allow_file_overwriting() is not explicitly activated, the function throws, too. This is a safty measure to ensure that users cannot accidentally overwrite their files.
[in] | file_name | Path to the file to write to. |
[out] | out_stream | Reference to the target output stream. Unfortunately, we cannot return streams, as they do not offer copy or move, so we have to do it this way. |
[in] | mode | Mode flag as used by std::ostream. |
[in] | create_dirs | Create parent directories if needed. |
Definition at line 72 of file output_stream.hpp.
std::string file_path | ( | std::string const & | filename | ) |
std::string file_read | ( | std::string const & | filename, |
bool | detect_compression = true |
||
) |
Return the contents of a file as a string.
If the parameter detect_compression
is true
(default), it is first determined whether the file is gzip compressed, and if so, the file is decompressed when reading.
If the file is not readable, the function throws std::runtime_error
.
std::vector< std::string > file_read_lines | ( | std::string const & | filename, |
bool | detect_compression = true |
||
) |
Return the contents of a file as a vector of strings, one entry for each line.
If the parameter detect_compression
is true
(default), it is first determined whether the file is gzip compressed, and if so, the file is decompressed when reading.
If the file is not readable, the function throws std::runtime_error
.
size_t file_size | ( | std::string const & | filename | ) |
void file_write | ( | std::string const & | content, |
std::string const & | filename, | ||
bool | create_dirs = true |
||
) |
Write the content of a string to a file.
If the file cannot be written to, the function throws an exception. Also, by default, if the file already exists, an exception is thrown. See Options::allow_file_overwriting() to change this behaviour.
std::vector< size_t > filter_constant_columns | ( | Matrix< double > & | data, |
double | epsilon = 1e-5 |
||
) |
Filter out columns that have nearly constant values, measured using an epsilon
.
The Matrix is modified so that all columns c
with max(c) - min(c) <= epsilon
are removed.
The function returns a sorted list of all column indices of the original matrix that are kept, i.e., that have a greater min-max difference than epsilon
. This is useful for e.g., visualising the result of an Edge PCA.
[in,out] | data | Matrix to filter inplace. |
[in] | epsilon | Maximum deviation for what is considered constant. |
Definition at line 158 of file math/matrix.cpp.
double genesis::utils::finite_maximum | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Return the maximum of a range of double values.
Only finite values are used in the comparison. If there are no finite values at all in the range, a quite NaN is returned.
Definition at line 207 of file statistics.hpp.
double genesis::utils::finite_minimum | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Return the minimum of a range of double values.
Only finite values are used in the comparison. If there are no finite values at all in the range, a quite NaN is returned.
Definition at line 175 of file statistics.hpp.
MinMaxPair<double> genesis::utils::finite_minimum_maximum | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Return the minimum and the maximum of a range of double values.
Only finite values are used in the comparison. If there are no finite values at all in the range, a quite NaN is returned.
Definition at line 239 of file statistics.hpp.
std::pair<std::vector<double>, std::vector<double> > genesis::utils::finite_pairs | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b | ||
) |
Helper function that cleans two ranges of double
of the same length from non-finite values.
This function is used for cleaning data input. It iterates both same-length ranges in parallel and copies pairs elements to the two result vectors (one for each range), if both values are finite. The result vectors thus have equal size.
Definition at line 252 of file common.hpp.
|
inline |
Apply Fisher z-transformation to a correlation coefficient.
The coefficient can be calculated with pearson_correlation_coefficient() or spearmans_rank_correlation_coefficient() and has to be in range [ -1.0, 1.0 ]
.
There is also a version of this function for a vector of coefficients.
Definition at line 265 of file correlation.hpp.
|
inline |
Apply Fisher z-transformation to a vector of correlation coefficients.
See fisher_transformation( double ) for details.
Definition at line 285 of file correlation.hpp.
void genesis::utils::for_each_finite_pair | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b, | ||
std::function< void(double value_a, double value_b)> | execute | ||
) |
Iterate two ranges of double
values in parallel, and execute a function for each pair of values from the two ranges where both values are finite.
The ranges need to have the same length.
Definition at line 286 of file common.hpp.
double genesis::utils::fraction_of_variance_unexplained | ( | ForwardIteratorA | first_x, |
ForwardIteratorA | last_x, | ||
ForwardIteratorB | first_y, | ||
ForwardIteratorB | last_y, | ||
LinearFunction | lin_fct | ||
) |
Calculate the fraction of unexplained variance resulting from a linear fit of the input variables.
See https://en.wikipedia.org/wiki/Fraction_of_variance_unexplained for some details.
|
inline |
Obtain an input source for reading from a file.
The input source returned from this function can be used in the reader classes, e.g., placement::JplaceReader or sequence::FastaReader.
If the parameter detect_compression
is true
(default), it is first determined whether the file is gzip compressed, and if so, a transparent decompression layer is added. That means, gzip-compressed files can be decompressed automatically and on the fly.
Definition at line 68 of file input_source.hpp.
|
inline |
Obtain a set of input sources for reading from files.
See from_file() for details. This version returnes multiple input sources from an interator over file names, which can be used for parallely reading from multiple files for speedup.
Definition at line 112 of file input_source.hpp.
|
inline |
Obtain a set of input sources for reading from files.
See from_file() for details. This version returnes multiple input sources, which can be used for parallely reading from multiple files for speedup. This function can for example be used with the output of utils::dir_list_files().
Definition at line 91 of file input_source.hpp.
TwobitVector from_nucleic_acids | ( | std::string const & | sequence | ) |
Turn a string of nucleic acids into a TwobitVector.
Definition at line 93 of file utils/math/twobit_vector/functions.cpp.
|
inline |
Obtain an input source for reading from standard input (i.e., stdin or cin).
The input source returned from this function can be used in the reader classes, e.g., placement::JplaceReader or sequence::FastaReader.
Definition at line 205 of file input_source.hpp.
|
inline |
Obtain an input source for reading from a stream.
The input source returned from this function can be used in the reader classes, e.g., placement::JplaceReader or sequence::FastaReader.
Definition at line 189 of file input_source.hpp.
|
inline |
Obtain an input source for reading from a string.
The input source returned from this function can be used in the reader classes, e.g., placement::JplaceReader or sequence::FastaReader.
Definition at line 134 of file input_source.hpp.
|
inline |
Obtain a set of input sources for reading from strings.
See from_string() and from_files() for details.
Definition at line 167 of file input_source.hpp.
|
inline |
Obtain a set of input sources for reading from strings.
See from_string() and from_files() for details.
Definition at line 148 of file input_source.hpp.
double geo_distance | ( | GeoCoordinate const & | c1, |
GeoCoordinate const & | c2 | ||
) |
Calculate the distance (in km) between two points on Earth.
Uses the Haversine formula. See convert_geo_coordinate() for a conversion function for geographical coordinates.
Definition at line 317 of file utils/tools/geodesy/functions.cpp.
double genesis::utils::geometric_mean | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the geometric mean of a range of positive numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. The function then calculates the geometric mean of all positive finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored. If finite non-positive numbers (zero or negative) are found, an exception is thrown.
std::vector
. Definition at line 574 of file statistics.hpp.
|
inline |
Calculate the geometric mean of a std::vector
of double
elements.
Definition at line 613 of file statistics.hpp.
|
static |
|
static |
|
static |
size_t genesis::utils::get_core_id_ | ( | std::string const & | cpu_path | ) |
void genesis::utils::get_cpuid_ | ( | int32_t | out[4], |
int32_t | eax, | ||
int32_t | ecx | ||
) |
|
static |
size_t genesis::utils::get_numa_node_id_ | ( | std::string const & | cpu_path | ) |
int genesis::utils::get_physical_core_count_ | ( | size_t | n_cpu | ) |
std::vector< double > glm_coefficients | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmLink const & | link, | ||
GlmOutput const & | output | ||
) |
Compute the model coefficients of a glm_fit().
Overload where the link function can be specified, for links other than identity.
Note that the functions glm_estimate_intercept() and glm_estimate_betas() compute their values in the original space of the predictors and response, and not on the link scale. This is particularly important when using a link function other than identity. See glm_estimate_intercept() for an example of the value computed.
std::vector< double > glm_coefficients | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmOutput const & | output | ||
) |
Compute the model coefficients of a glm_fit().
This simply calls glm_estimate_intercept() and glm_estimate_betas(), and stores the results in a vector, i.e., the intercept, followed by the beta coefficients. This is hence a convenience function for cases where all coefficients are needed. See these two functions for specifics on the values that they are computing.
Assumes identity link function such as from glm_link_identity(). See the other overload of the function to specify the link function.
Definition at line 223 of file dataframe.cpp.
Matrix< double > glm_convert_dataframe | ( | Dataframe const & | df, |
std::vector< std::string > | row_order | ||
) |
Definition at line 187 of file dataframe.cpp.
std::vector< double > glm_estimate_betas | ( | GlmOutput const & | output | ) |
Compute the beta estimates resulting from a glm_fit().
The GlmOutput::betaQ result expresses the betas in terms of the GlmOutput::Xb basis space, which is an orthogonal representaton of the original predictor matrix. To turn this into betas expressed in the original predictor column space, this function inverts the triangular transformation matrix GlmOutput::tri, and uses this to transform the betaQ into betas.
std::pair<std::vector<double>, std::vector<double> > genesis::utils::glm_estimate_betas_and_var_covar | ( | GlmOutput const & | output, |
std::vector< double > const & | meat | ||
) |
std::vector<double> genesis::utils::glm_estimate_betas_inv_tri_ | ( | GlmOutput const & | output, |
std::vector< double > const & | inv_tri | ||
) |
double glm_estimate_intercept | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmLink const & | link, | ||
GlmOutput const & | output, | ||
std::vector< double > const & | betas | ||
) |
Compute the intercept resulting from a glm_fit().
Overload where the link function can be specified, for links other than identity.
Note that this function computes the intercept in the original space of the predictors and response. For instance, assuming the data has been generated like this:
beta_0 = 0.5 beta_1 = 0.3 X = np.linspace(start=1, stop=10, num=10) Y = np.exp(beta_0 + beta_1 * X)
and the GLM has accordingly been run with glm_family_poisson()/glm_link_log(), that is, with a log link. Then, this function here computes the intercept as originally specified, i.e., 0.5
.
double glm_estimate_intercept | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmOutput const & | output, | ||
std::vector< double > const & | betas | ||
) |
Compute the intercept resulting from a glm_fit().
This takes the input and output of the glm_fit(), as well as the list of betas
in the original predictor column space, which is computed by glm_estimate_betas().
Assumes identity link function such as from glm_link_identity(). See the other overload of the function to specify the link function.
GlmFactor<typename ForwardIterator::value_type> genesis::utils::glm_factor | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 166 of file factor.hpp.
GlmFactor<typename ForwardIterator::value_type> genesis::utils::glm_factor | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::vector< typename ForwardIterator::value_type > const & | levels | ||
) |
Definition at line 152 of file factor.hpp.
GlmFactor<typename ForwardIterator::value_type> genesis::utils::glm_factor | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::vector< typename ForwardIterator::value_type > const & | levels, | ||
std::vector< typename ForwardIterator::value_type > const & | exclude | ||
) |
Reduce a list of values in the given range to a set of unique factors.
The function takes a range (first
to last
, with last being the past-the-end element) and finds all unique values (called levels
) in the range. These are stored in the GlmFactor::levels set of the result. The provided values in the given range are then encoded in GlmFactor::values using the indices of the unique values in the levels.
If the parameter levels
is not provided, the found unique levels are sorted. If however levels
are provided, these are used instead, and their ordering is used for the encoding of the values. Any value that is not found in the provided levels
is assigned max size_t
as an indicator of an unused/missing level.
The paramter exclude
works similary: All levels in the exlcude
list are removed from the result (no matter whether levels
were provided or the found ones are used), and all corresponding values are encoded as max size_t
.
Definition at line 88 of file factor.hpp.
std::vector<size_t> genesis::utils::glm_factor_summary | ( | GlmFactor< T > const & | factor | ) |
Get the number of occurrences of each level in a GlmFactor.
The resulting vector indicates how often each level of the factor occurs in its values, using the same indices as the levels:
// List the number of occurrences for each factor. auto const smry = glm_factor_summary( factor ); for( size_t i = 0; i < factor.levels.size(); ++i ) { std::cout << "Level " << factor.levels[i] << ": " << smry[i]; }
This is for example useful for user output.
Definition at line 193 of file factor.hpp.
|
inline |
Binomial family functions.
The canonical link for binomial is logit, see glm_link_logit().
Definition at line 120 of file family.hpp.
|
inline |
Gamma family functions.
The canonical link for gamma is identity, see glm_link_gamma().
Definition at line 266 of file family.hpp.
|
inline |
Gaussian/normal family functions.
The canonical link for gaussian/normal is identity, see glm_link_identity().
Definition at line 226 of file family.hpp.
|
inline |
Poisson family functions.
The canonical link for poisson is log, see glm_link_log().
Definition at line 181 of file family.hpp.
GlmOutput glm_fit | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmExtras const & | extras = {} , |
||
GlmControl const & | control = {} |
||
) |
Fit a Generalized Linear Model (GLM) using a linear gaussian model.
See the Acknowledgements for details on the license and original authors.
GlmOutput glm_fit | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmFamily const & | family, | ||
GlmExtras const & | extras = {} , |
||
GlmControl const & | control = {} |
||
) |
Fit a Generalized Linear Model (GLM).
Uses the canonical link function of the provided distribution family.
See the Acknowledgements for details on the license and original authors.
GlmOutput glm_fit | ( | Matrix< double > const & | x_predictors, |
std::vector< double > const & | y_response, | ||
GlmFamily const & | family, | ||
GlmLink const & | link, | ||
GlmExtras const & | extras = {} , |
||
GlmControl const & | control = {} |
||
) |
Fit a Generalized Linear Model (GLM).
See the Acknowledgements for details on the license and original authors.
|
static |
Dataframe genesis::utils::glm_indicator_variables | ( | GlmFactor< T > const & | factor, |
std::vector< std::string > const & | row_names = std::vector<std::string>{} |
||
) |
Turn a GlmFactor into a set of (dummy) indicator variables to be used in regression.
The function uses the most common level as reference level, and otherwise behaves the same as glm_indicator_variables().
Definition at line 302 of file factor.hpp.
Dataframe genesis::utils::glm_indicator_variables | ( | GlmFactor< T > const & | factor, |
T const & | reference_level, | ||
std::vector< std::string > const & | row_names = std::vector<std::string>{} |
||
) |
Turn a GlmFactor into a set of (dummy) indicator variables to be used in regression.
The function takes a factor
object, and for its k
levels creates k - 1
dummy indicator variables that encode the factors for regression. The given reference_level
is excluded, and for all other levels, a column is returned that contains 1.0
wherever the values
of the factor
are equal to that level, and 0.0
otherwise. Missing/exluded levels are encoded as NaN
.
Definition at line 214 of file factor.hpp.
std::vector<double> genesis::utils::glm_inv_tri_ | ( | std::vector< double > const & | tri, |
size_t | M | ||
) |
|
inline |
Identity link functions.
The canonical family for identiy is normal/gaussian, see glm_family_gaussian().
Definition at line 153 of file utils/math/regression/link.hpp.
|
inline |
Inverse link functions.
The canonical family for inverse is gamma, see glm_family_gamma().
Definition at line 182 of file utils/math/regression/link.hpp.
|
inline |
Log link functions.
The canonical family for logit is poisson, see glm_family_poisson().
Definition at line 125 of file utils/math/regression/link.hpp.
|
inline |
Logit link functions.
The canonical family for logit is binomial, see glm_family_binomial().
Definition at line 97 of file utils/math/regression/link.hpp.
Definition at line 181 of file dataframe.cpp.
Definition at line 51 of file dataframe.cpp.
Returns a Color that is created using a color gradient.
The function takes a color gradient in form of a map from double to Color. The keys in the map are offset positions (stops) with specific Colors assigned to them. An arbitrary number of keys in between these boundaries is allowed.
Each key is associated with a Color value, which indicates the color at that position.
Example:
// Prepare gradient ranges. auto ranges = std::map<double, Color>(); ranges[ 0.0 ] = Color( 0.0, 1.0, 0.0 ); ranges[ 0.5 ] = Color( 1.0, 1.0, 0.0 ); ranges[ 1.0 ] = Color( 1.0, 0.0, 0.0 ); // Get color at 30% of the green-yellow-red gradient. Color c = gradient( ranges, 0.3 );
This map defines the same gradient that is used for heat_gradient
. The range boundaries do not have to be [ 0.0, 1.0 ]
. They can be set to any range that is needed to reflect the range of possible values.
The second parameter of this function then takes the position at which the gradient is evaluated. Values outside of the interval that is defined by the range are set to the closest interval border value.
For example, given the range map above, a value of 0.0 gives green; 0.5 gives yellow; 1.0 gives red; values in between are interpolated linearily.
Definition at line 170 of file utils/color/functions.cpp.
size_t guess_number_of_threads | ( | bool | use_openmp = true , |
bool | use_slurm = true , |
||
bool | physical_cores = true |
||
) |
Make an educated guess on the number of threads to use for multi-threaded functionality.
This function uses multiple sources and ways to try to guess a reasonable number of threads:
use_openmp
is set, we use the omp_get_max_threads()
function or the OMP_NUM_THREADS
environment variable to get a number of threads, using the info_number_of_threads_openmp() function. For details, see there.use_slurm
is set, we get a number of cores from the environment variable SLURM_CPUS_PER_TASK
.std::thread::hardware_concurrency()
as another hint. If furthermore physical_cores
is set, and hyperthreads are enabled, we divide that hardware concurrency number by two, in order to account for hyperthreads, resulting in the number of physical cores available on the system (ideally). This avoids core oversubscription that could otherwise be the result of using all threads instead of all physical cores.If the numbers disagree with each other, we prefer OpenMP over slurm over hardware_concurrency()
, that is, we are going from most specific to least. Furthermore, if the OpenMP based guess yields exactly the same number as the hardware concurrency, we also use the physical_cores
setting, as this result usually indicates that OpenMP left at its default, in which case we also want to avoid core oversubscription due to hyperthreading.
The function is guaranteed to return a non-zero value, meaning that at least the main thread is always accounted for. This is important for Options::get().init_global_thread_pool(), which will account for that, and initialize the number of additional threads to one fewer than this.
double genesis::utils::harmonic_mean | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
HarmonicMeanZeroPolicy | zero_policy = HarmonicMeanZeroPolicy::kThrow |
||
) |
Calculate the harmonic mean of a range of positive numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. The function then calculates the harmonic mean of all non-negative or positive (depending on the zero_policy
) finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored. If finite negative numbers are found, an exception is thrown. Zero values are treated according to the zero_policy
.
std::vector
. Definition at line 775 of file statistics.hpp.
|
inline |
Calculate the harmonic mean of a std::vector
of double
elements.
Definition at line 849 of file statistics.hpp.
|
inlineconstexpr |
std::string hash_hex | ( | std::shared_ptr< BaseInputSource > | source, |
HashingFunctions | hash_fct | ||
) |
Calculate the hash of an input source, using a given hashing function, and return its hex representation as a string.
See HashingFunctions for the list of available hashing functions.
Definition at line 47 of file utils/tools/hash/functions.cpp.
std::string head | ( | std::string const & | text, |
size_t | lines | ||
) |
Return the first lines of the text.
Definition at line 496 of file string.cpp.
Color heat_gradient | ( | double | percentage | ) |
Return a Color that represents a heat gradient for a given percentage value.
Given a percentage value in the range of [ 0.0, 1.0]
, the functions represents the heat of that value. For 0.0, the heat gradient value is green, for 0.5 yellow and for 1.0 red. The values in between are interpolated linearily.
Definition at line 203 of file utils/color/functions.cpp.
Matrix<utils::Color> genesis::utils::heat_map_matrix_range_ | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 136 of file heat_map.cpp.
Matrix<utils::Color> genesis::utils::heat_map_matrix_range_all_ | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 67 of file heat_map.cpp.
Matrix<utils::Color> genesis::utils::heat_map_matrix_range_col_ | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 111 of file heat_map.cpp.
Matrix<utils::Color> genesis::utils::heat_map_matrix_range_row_ | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 89 of file heat_map.cpp.
MinMaxPair<double> genesis::utils::heat_map_matrix_update_min_max_ | ( | MinMaxPair< double > const & | min_max, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 52 of file heat_map.cpp.
size_t hypergeometric_distribution | ( | size_t | n1, |
size_t | n2, | ||
size_t | t | ||
) |
Select a random sample from a hypergeometric distribution.
This is the distribution of drawing balls without replacement from an urn with two colors. Here, n1
and n2
are the numbers of balls of each color, and t
is the number of balls to sample, and the return value is the number of balls of the first color. See https://en.wikipedia.org/wiki/Hypergeometric_distribution
Definition at line 401 of file distribution.cpp.
size_t genesis::utils::hypergeometric_distribution_gsl | ( | size_t | n1, |
size_t | n2, | ||
size_t | t | ||
) |
Definition at line 463 of file distribution.cpp.
size_t genesis::utils::hypergeometric_distribution_inversion_mode_ | ( | size_t | n, |
size_t | m, | ||
size_t | N | ||
) |
Definition at line 279 of file distribution.cpp.
size_t genesis::utils::hypergeometric_distribution_ratio_of_unifoms_ | ( | size_t | n, |
size_t | m, | ||
size_t | N | ||
) |
Definition at line 176 of file distribution.cpp.
std::string indent | ( | std::string const & | text, |
std::string const & | indentation = " " |
||
) |
Indent each line of text
with indentation
and return the result.
By default, four spaces are used to indent. Whether the text ends with a new line or not is not changed. Any trailing indentation chars are trimmed, in order to not have trailing whitespaces in the result (except for the new line, if the text ends in one).
Definition at line 719 of file string.cpp.
|
inline |
Calculate the index of dispersion.
The index of dispersion, also known as the dispersion index, coefficient of dispersion, relative variance, variance-to-mean ratio (VMR) or Fano factor, is defined as the ratio of the variance to the mean. Variance is the square of the standard deviation. See mean_stddev() to calculate those values. See https://en.wikipedia.org/wiki/Index_of_dispersion for details.
Definition at line 1151 of file statistics.hpp.
|
inline |
Calculate the index of dispersion.
The index of dispersion, also known as the dispersion index, coefficient of dispersion, relative variance, variance-to-mean ratio (VMR) or Fano factor, is defined as the ratio of the variance to the mean. Variance is the square of the standard deviation. See mean_stddev() to calculate those values. See https://en.wikipedia.org/wiki/Index_of_dispersion for details.
Definition at line 1159 of file statistics.hpp.
InfoCompiler const & info_get_compiler | ( | ) |
InfoHardware const & info_get_hardware | ( | ) |
size_t info_get_pid | ( | ) |
Get the process ID of the current process.
This is a POSIX system call, using getpid()
. See https://man7.org/linux/man-pages/man2/getpid.2.html and https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpid.2.html for details. We wrap this here to avoid having the system headers included. Furthermore, we convert to a size_t for convenience, although typically, the pid is an int
(guaranteed to be non-negative for an actual process).
bool info_hyperthreads_enabled | ( | ) |
size_t info_number_of_threads_openmp | ( | ) |
Get the number of threads as indicated by the OpenMP environment.
If genesis was compiled with OpenMP support (that is, if GENESIS_OPENMP
is defined, which is done via the CMake script), we use omp_get_max_threads()
to get a number of threads from that. If however genesis was compiled without OpenMP support, we instead consider the environment variable OMP_NUM_THREADS
as a source for the OpenMP threads.
If unsuccessful, 0 is returned.
size_t info_number_of_threads_slurm | ( | ) |
size_t info_physical_core_count | ( | ) |
Get the number of CPU cores.
This tries to get the physical core count, and if that fails, it uses std::thread::hardware_concurrency() along with info_hyperthreads_enabled() to determine a best guess at the number of physical cores.
std::unordered_map< std::string, std::string > const & info_preprocessor_definitions | ( | ) |
std::string info_print_compiler | ( | ) |
std::string info_print_hardware | ( | bool | full = false | ) |
Print information about hardware features to a string.
This lists hardware features such as memory, CPU model, and potentially CPU features. If full
is given, each CPU feature that we test for is listed. Otherwise, by default, we just print a summary of the features that are important to us, such as AVX.
double info_process_current_cpu_usage | ( | bool | all_cores = true , |
bool | percent = true |
||
) |
Return the CPU usage of the current process.
The first time the function is called, it is being initialized, and will return 0.0, as there is no usage to be reported yet. Any subsequent call with then report the usage since the last call.
By default, this reports the total usage across all cores. That is, for multi-core systems, this can report usage up to the number of cores. For instance, two cores fully running on a 4-core system would report 200% usage (using return value 200.0 by default, or 2.0 if percent
is set to false
). If however all_cores
is set to false
, this is instead divided by the number of cores, and so would return 50% usage (using return value 50.0 or 0.5, depending on percent
) instead.
size_t info_process_current_file_count | ( | ) |
size_t info_process_current_memory_usage | ( | ) |
size_t info_process_max_file_count | ( | ) |
size_t info_process_peak_memory_usage | ( | ) |
std::string info_process_print_total_usage | ( | ) |
std::pair< double, double > info_process_total_cpu_time | ( | ) |
double info_process_total_energy_consumption | ( | ) |
bool info_stderr_is_terminal | ( | ) |
bool info_stdin_is_terminal | ( | ) |
bool info_stdout_is_terminal | ( | ) |
double info_system_current_cpu_usage | ( | bool | all_cores = true , |
bool | percent = true |
||
) |
Return the CPU usage of the system, across all cores.
size_t info_system_current_memory_available | ( | ) |
size_t info_system_current_memory_usage | ( | ) |
unsigned int genesis::utils::info_task_cpu_cores | ( | bool | physical = false | ) |
std::pair< int, int > info_terminal_size | ( | ) |
bool info_use_avx | ( | ) |
bool info_use_avx2 | ( | ) |
bool info_use_avx512 | ( | ) |
std::vector<T>::iterator genesis::utils::insert_sorted | ( | std::vector< T > & | vec, |
T const & | item | ||
) |
Insert into a vector vec
, sorted by the value of the item
. The vector must already be sorted.
Definition at line 152 of file algorithm.hpp.
std::vector<T>::iterator genesis::utils::insert_sorted | ( | std::vector< T > & | vec, |
T const & | item, | ||
Pred | pred | ||
) |
Insert into a vector vec
, sorted by the value of the item
, using a predicate. The vector must already be sorted according to the predicate.
Definition at line 166 of file algorithm.hpp.
|
inline |
Calculate the power base^exp
for positive integer values.
Remark: This overflows quite easily. The function does not check whether the desired power actually fits within size_t
. Use is_valid_int_pow() to check for this first.
Rationale for this function: One could argue that int powers are not really useful, particularly because of the fast overflow. However, using doubles leads to rounding errors, at least for bigger numbers. So, within the valid range, this function is more accurate. Also, it is faster.
Definition at line 191 of file common.hpp.
Linearily interpolate between two Colors.
Definition at line 154 of file utils/color/functions.cpp.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
Implementation detail for is_ascii(char).
|
constexprnoexcept |
Implementation detail for is_ascii(char).
|
constexprnoexcept |
Definition at line 106 of file family.hpp.
|
constexprnoexcept |
bool is_color_name | ( | std::string const & | name | ) |
Return true
if the name represents one of the named colors offered by genesis, which is (currently) a shortcut for is_color_name_web() and is_color_name_xkcd().
bool is_color_name_lego | ( | std::string const & | name | ) |
Return true iff the given name is a named LEGO color.
Names are compared only by their alnum chars, and the letter case is ignored. See color_from_name_lego() for details on this color list.
bool is_color_name_web | ( | std::string const & | name | ) |
bool is_color_name_xkcd | ( | std::string const & | name | ) |
Return true iff the given name is a named xkcd color.
Names are compared only by their alnum chars, and the letter case is ignored. See color_from_name_xkcd() for details on this color list.
|
constexprnoexcept |
bool is_convertible_to_bool | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 61 of file utils/containers/dataframe/operators.cpp.
bool is_convertible_to_bool | ( | Dataframe const & | df, |
std::string const & | col_name | ||
) |
Definition at line 78 of file utils/containers/dataframe/operators.cpp.
bool genesis::utils::is_convertible_to_bool | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 162 of file convert.hpp.
bool is_convertible_to_bool | ( | std::string const & | str | ) |
Return whether a string can be converted to bool.
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as false
), with all text case insensitive.
Definition at line 74 of file convert.cpp.
bool genesis::utils::is_convertible_to_bool_double | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 225 of file convert.hpp.
bool is_convertible_to_bool_double | ( | std::string const & | str | ) |
Return whether a string can be converted to bool (and stored as a double).
This conversion is useful to work with dataframes that are all double, for example to work with our Generalized Linear Model implementation, see glm_fit().
Strings that can be converted to bool with this function are true
, false
, yes
, no
, on
, off
, 1
, 0
, and the empty string (evaluated as quiet_NaN
), with all text case insensitive.
Definition at line 112 of file convert.cpp.
bool is_convertible_to_double | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 84 of file utils/containers/dataframe/operators.cpp.
bool is_convertible_to_double | ( | Dataframe const & | df, |
std::string const & | col_name | ||
) |
Definition at line 100 of file utils/containers/dataframe/operators.cpp.
bool genesis::utils::is_convertible_to_double | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 278 of file convert.hpp.
bool is_convertible_to_double | ( | std::string const & | str | ) |
Return whether a string can be converted to double.
Definition at line 172 of file convert.cpp.
bool genesis::utils::is_convertible_to_signed_integer | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 331 of file convert.hpp.
bool is_convertible_to_signed_integer | ( | std::string const & | str | ) |
Return whether a string can be converted to signed integer.
Definition at line 204 of file convert.cpp.
bool genesis::utils::is_convertible_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Return whether a list of std::string
is convertible to std::tm
date/time objects.
The function tries to guess the format. See convert_to_tm( std::string const& ) for details. For long lists, this can be expensive, as the formats are tried again for each entry separately.
Definition at line 405 of file date_time.hpp.
bool genesis::utils::is_convertible_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::string const & | format | ||
) |
Return whether a list of std::string
is convertible to std::tm
date/time objects.
The function uses the given format
. See convert_to_tm( std::string const&, td::string const& ) for details.
Definition at line 383 of file date_time.hpp.
bool genesis::utils::is_convertible_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
std::string const & | format, | ||
std::string const & | locale | ||
) |
Return whether a list of std::string
is convertible to std::tm
date/time objects.
The function uses the given format
and locale
. See convert_to_tm( std::string const&, std::string const&, std::string const& ) for details.
Definition at line 361 of file date_time.hpp.
bool is_convertible_to_tm | ( | std::string const & | str | ) |
Return whether a std::string
is convertible to a std::tm
date/time object, that is, whether it contains a date/time in a recognizable format.
The function tries to guess the format. See convert_to_tm( std::string const& ) for details.
Definition at line 381 of file date_time.cpp.
bool is_convertible_to_tm | ( | std::string const & | str, |
std::string const & | format | ||
) |
Return whether a std::string
is convertible to a std::tm
date/time object, that is, whether it contains a date/time in a recognizable format.
The function uses the given format
. See convert_to_tm( std::string const&, std::string const& ) for details.
Definition at line 368 of file date_time.cpp.
bool is_convertible_to_tm | ( | std::string const & | str, |
std::string const & | format, | ||
std::string const & | locale | ||
) |
Return whether a std::string
is convertible to a std::tm
date/time object, that is, whether it contains a date/time in a recognizable format.
The function uses the given format
and locale
. See convert_to_tm( std::string const&, std::string const&, std::string const& ) for details.
Definition at line 361 of file date_time.cpp.
bool genesis::utils::is_convertible_to_unsigned_integer | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Definition at line 384 of file convert.hpp.
bool is_convertible_to_unsigned_integer | ( | std::string const & | str | ) |
Return whether a string can be converted to unsigned integer.
Definition at line 236 of file convert.cpp.
|
inline |
Check whether all necessary values and functors of a GlmFamily are set.
Definition at line 101 of file family.hpp.
|
inline |
Check whether all necessary values and functors of a GlmLink are set.
Definition at line 83 of file utils/math/regression/link.hpp.
|
constexprnoexcept |
bool is_dir | ( | std::string const & | path | ) |
Return true iff the provided path is a directory.
Internally, this function simply return the value of dir_exists(), as this already does the needed check. Thus, it is an alias.
bool is_file | ( | std::string const & | path | ) |
Return true iff the provided path is a (readable) file.
Internally, this function simply returns the value of file_is_readable(), meaning that we also check that the file can actually be read. That is semantically a bit different from just stating that it is a file... But file system stuff in C++ pre-17 is hard, and this works for now.
|
constexprnoexcept |
bool is_gzip_compressed_file | ( | std::string const & | file_name | ) |
|
constexprnoexcept |
|
constexprnoexcept |
|
static |
Definition at line 51 of file utils/containers/dataframe/operators.cpp.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
bool genesis::utils::is_square | ( | Matrix< T > const & | data | ) |
Return whether a Matrix is a square matrix, that is, whether its number of rows and number of columns are idetical.
Definition at line 178 of file utils/containers/matrix/operators.hpp.
Strict subset.
Definition at line 94 of file utils/math/bitvector/operators.cpp.
Strict superset.
Definition at line 102 of file utils/math/bitvector/operators.cpp.
Subset or equal.
Definition at line 107 of file utils/math/bitvector/operators.cpp.
Superset or equal.
Definition at line 112 of file utils/math/bitvector/operators.cpp.
bool genesis::utils::is_symmetric | ( | Matrix< T > const & | data | ) |
Return whether a Matrix is symmetric, i.e., whether it is square and m[ i, j ] == m[ j, i ]
holds for all entries.
Definition at line 188 of file utils/containers/matrix/operators.hpp.
|
constexprnoexcept |
bool is_valid_filename | ( | std::string const & | filename | ) |
Check whether a file name is valid.
Validating filenames depends on the operating system and file system of the disk. Thus, this is usually not an easy task. This function only checks some basics and is meant to catch the most common problems.
The function is meant to be called on the file name itself, without the directory path leading to it. File extensions are allowed. Thus, you might need to call file_basename() before in order to get the file name without the path.
Invalid filenames are:
< > : " \ / | ? *
.This might be too converative for some system, or allow too much for others. It however should return true for filenames that work on most systems.
|
inline |
Return whether the given power can be stored within a size_t
.
Use int_pow() to calculate the actual value of the power.
Definition at line 211 of file common.hpp.
|
constexprnoexcept |
|
inline |
Definition at line 220 of file iterator_deletions.hpp.
|
inline |
Definition at line 249 of file iterator_insertions.hpp.
|
inline |
Definition at line 239 of file iterator_substitutions.hpp.
std::string genesis::utils::join | ( | C const & | container, |
std::string const & | delimiter = ", " |
||
) |
Return a string where the elements of a container v
are joined using the string delimiter
in between them.
Definition at line 740 of file string.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::join | ( | Interval< DataType, NumericalType, IntervalKind > const & | a, |
Interval< DataType, NumericalType, IntervalKind > const & | b | ||
) |
Creates a new Interval that contains both intervals and whatever is between.
The data of the newly created interval is default constructed.
Definition at line 127 of file utils/containers/interval_tree/functions.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::join | ( | Interval< DataType, NumericalType, IntervalKind > const & | a, |
Interval< DataType, NumericalType, IntervalKind > const & | b, | ||
DataType && | data | ||
) |
Creates a new Interval that contains both intervals and whatever is between.
The provided data
is moved to the new Interval.
Definition at line 162 of file utils/containers/interval_tree/functions.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::join | ( | Interval< DataType, NumericalType, IntervalKind > const & | a, |
Interval< DataType, NumericalType, IntervalKind > const & | b, | ||
DataType const & | data | ||
) |
Creates a new Interval that contains both intervals and whatever is between.
The provided data
is copied to the new Interval.
Definition at line 144 of file utils/containers/interval_tree/functions.hpp.
std::ostream & join | ( | std::ostream & | stream, |
C const & | container, | ||
std::string const & | delimiter = ", " |
||
) |
Print elements of the given container
to the output stream
, joining them with the delimiter
.
Print elements of the given container
to the output stream
, joining them with the delimiter
, for a container of signed or unsigned char.
The delimiter
is only printed in between elements, but not after the last. The container is iterated via its range based for loop, thus it needs to have begin() and end() functions. For turning the elements of the container into a string, their operator << is used. Thus, this function can used with all types that support this operator.
We need this specialization, as the unsigned chars are otherwise turned into their char (ASCII) equivalent, which we do not want. Instead, we want to output them here as plain numbers.
Definition at line 699 of file string.hpp.
double genesis::utils::kendalls_tau_correlation_coefficient | ( | InputIteratorA | first_a, |
InputIteratorA | last_a, | ||
InputIteratorB | first_b, | ||
InputIteratorB | last_b, | ||
KendallsTauMethod | method = KendallsTauMethod::kTauB |
||
) |
This function computes Kendall's tau, if requested accounting for ties, and using Knight's algorithm for speed.
Knight, W. (1966). "A Computer Method for Calculating Kendall's Tau with Ungrouped Data". Journal of the American Statistical Association. 61 (314): 436–439. doi:10.2307/2282833. JSTOR 2282833.
See kendalls_tau_correlation_coefficient_naive() for the naive, slow version.
Definition at line 229 of file correlation.hpp.
double kendalls_tau_correlation_coefficient | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
KendallsTauMethod | method = KendallsTauMethod::kTauB |
||
) |
Compute Kendall's Tau Correlation Coefficient.
This function computes Kendall's tau, if requested accounting for ties, and using Knight's algorithm for speed.
Knight, W. (1966). "A Computer Method for Calculating Kendall's Tau with Ungrouped Data". Journal of the American Statistical Association. 61 (314): 436–439. doi:10.2307/2282833. JSTOR 2282833.
See kendalls_tau_correlation_coefficient_naive() for the naive, slow version.
Definition at line 423 of file correlation.cpp.
double genesis::utils::kendalls_tau_correlation_coefficient_clean_ | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
KendallsTauMethod | method | ||
) |
Compute Kendall's Tau, expecting clean input without nan values, using Knight's algorithm.
Definition at line 359 of file correlation.cpp.
double kendalls_tau_correlation_coefficient_naive | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
KendallsTauMethod | method = KendallsTauMethod::kTauB |
||
) |
Compute a simple version of Kendall's Tau Correlation Coefficient.
This version uses a naive nested loop over the elements. It is mainly provided for testing the more advanced implementation, see kendalls_tau_correlation_coefficient() for details.
Definition at line 468 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_count_tau_c_m_ | ( | std::vector< double > const & | x, |
std::vector< double > const & | y | ||
) |
Helper function to count the number of unique values in both lists, using only those entris that are finite in both.
Definition at line 55 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_count_ties_ | ( | std::vector< T > const & | values | ) |
Helper function to count the number of tied pairs induced by equal values.
Definition at line 230 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_count_ties_sorted_ | ( | std::vector< double > const & | values | ) |
Helper function to count the number of tied pairs induced by equal values, on a sorted input list.
Definition at line 254 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_count_ties_sorted_pairs_rank_ | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
std::vector< size_t > const & | ranks | ||
) |
Helper function to count the number of tied pairs induced by equal values, on two input list with the sorting provided via a rank indexing list.
Definition at line 325 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_count_ties_sorted_rank_ | ( | std::vector< double > const & | values, |
std::vector< size_t > const & | ranks | ||
) |
Helper function to count the number of tied pairs induced by equal values, on a sorted input list with the sorting provided via a rank indexing list.
Definition at line 291 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_merge_count_ | ( | std::vector< double > & | data, |
std::vector< double > & | temp, | ||
size_t | left, | ||
size_t | mid, | ||
size_t | right | ||
) |
Helper function for kendalls_tau_correlation_coefficient() to do a merge sort that counts the number of inversions performed.
Definition at line 152 of file correlation.cpp.
double genesis::utils::kendalls_tau_method_ | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
size_t const | concordant, | ||
size_t const | discordant, | ||
size_t const | n, | ||
size_t const | n0, | ||
size_t const | n1, | ||
size_t const | n2, | ||
size_t const | n3, | ||
KendallsTauMethod | method | ||
) |
Given counts of concordant and discordant pairs, compute the final value, applying the requested adjustments.
We take all values as inputs, as in the presence of nan values, these better be computed correclty by the two algorithms directly, instead of inferring, e.g., n from the list size...
Definition at line 80 of file correlation.cpp.
size_t genesis::utils::kendalls_tau_sort_and_count_ | ( | std::vector< double > & | data, |
std::vector< double > & | temp, | ||
size_t | left, | ||
size_t | right | ||
) |
Helper function for kendalls_tau_correlation_coefficient() to sort a list using merge sort, while counting the number of inversions performed.
Definition at line 191 of file correlation.cpp.
double log_binomial_coefficient | ( | size_t | n, |
size_t | k | ||
) |
Compute the logarithm (base e) of the binomial coefficient, that is n
choose k
, for two integer numbers, for large numbers.
See binomial_coefficient() for details. This function here is used in the internal computatation, and offered for cases where working with binomials in log space is more convenient due to the handling of numbers with very large and very small exponents, such as in binomial_distribution().
Definition at line 497 of file binomial.cpp.
double log_binomial_distribution | ( | size_t | k, |
size_t | n, | ||
double | p | ||
) |
Compute the logarithm (base e) of the probability mass function for a binomial distribution.
See binomial_distribution() for details.
Definition at line 519 of file binomial.cpp.
double log_factorial | ( | size_t | n | ) |
Return the logarithm (base e) of the factorial of n
, that is log(n!)
.
This is implemented via a precise lookup table for n < 1024
, and uses Stirling's approximation for larger values, with a slight error in the order of less than 1/(360 * n^3), that is, less than 2.59e-12 for all n >= 1024
. See https://www.johndcook.com/blog/2010/08/16/how-to-compute-log-factorial/ for details.
Definition at line 445 of file binomial.cpp.
std::vector<double> genesis::utils::log_factorial_lookup_generator_ | ( | ) |
Helper function to generate above lookup table.
The function is not called from anywhere, but kept here for reference, in case we want to modify the above lookup table. Computes log(x!), which we do neatly in an iterative way: x! = (x-1)! * x ==> log(x!) = log((x-1)!) + log(x) See https://stackoverflow.com/a/37715980/4184258
Definition at line 386 of file binomial.cpp.
|
inline |
Hack function to make sure that the value arugment in LOG_PROG is only evaluated once.
Without this function, LOG_PROG would include two appearances of its variable value
, which means that a statement like
LOG_PROG(++i, n) << "of progress.";
would lead to a double evaluation of the increment statement ++i
. That is not intended, thus we need this hack function.
Definition at line 179 of file logging.hpp.
std::vector< bool > make_bool_vector_from_indices | ( | std::vector< size_t > const & | indices, |
size_t | size = 0 |
||
) |
Helper function to create a bool vector from a set of indices to be set to true
.
The function expectes a list of indices. It returns a bool vector with the size of the largest index, or the provided size
(if set to a value > 0), where all positions of these indices are true
, and all other positions are false
.
Definition at line 45 of file utils/math/bitvector/helper.cpp.
FilterIterator<PredicateFunctor, BaseIterator> genesis::utils::make_filter_iterator | ( | PredicateFunctor | unary_func, |
BaseIterator | begin, | ||
BaseIterator | end = BaseIterator{} |
||
) |
Construct a filtering iterator, given the filter predicate function as well as the underlying base iterator begin and end.
Caveat: Note that by default, we use a default-constructed end
iterator. This only works for containers where the default-constructed iterator is the end iterator! In particular, this does NOT work for many STL containers. For example, for a std::vector
, one needs to explicitly use vector.end()
here.
This constructor needs to be used for both the begin and end of the range that one wants to iterate, using the same filter function both times. See also make_filter_iterator() and make_filter_range() for helper functions to easily create an instance.
Definition at line 272 of file filter_iterator.hpp.
Range<FilterIterator<PredicateFunctor, BaseIterator> > genesis::utils::make_filter_range | ( | PredicateFunctor | unary_func, |
BaseIterator | begin, | ||
BaseIterator | end | ||
) |
Construct a filtering range, given the filter predicate function as well as the underlying base iterator begin and end.
Definition at line 285 of file filter_iterator.hpp.
Range<FilterIterator<PredicateFunctor, typename Container::iterator> > genesis::utils::make_filter_range | ( | PredicateFunctor | unary_func, |
Container & | container | ||
) |
Construct a filtering range, given the filter predicate function as well as a container, whose begin() and end() iterators are used, respectively.
Definition at line 301 of file filter_iterator.hpp.
Range<FilterIterator<PredicateFunctor, typename Container::const_iterator> > genesis::utils::make_filter_range | ( | PredicateFunctor | unary_func, |
Container const & | container | ||
) |
Construct a filtering range, given the filter predicate function as well as a const container, whose begin() and end() iterators are used, respectively.
Definition at line 320 of file filter_iterator.hpp.
std::unique_ptr< ColorNormalization > make_heatmap_color_norm | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 158 of file heat_map.cpp.
Matrix< Color > make_heatmap_matrix | ( | Matrix< double > const & | values, |
HeatmapParameters const & | parameters | ||
) |
Definition at line 189 of file heat_map.cpp.
|
inline |
Convenience function to create an Optional.
Definition at line 575 of file optional.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::make_safe_interval | ( | NumericalType | lhs, |
NumericalType | rhs | ||
) |
Creates a safe Interval that puts the lower bound left automatically.
The data of the newly created interval is default constructed.
Definition at line 58 of file utils/containers/interval_tree/functions.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::make_safe_interval | ( | NumericalType | lhs, |
NumericalType | rhs, | ||
DataType && | data | ||
) |
Creates a safe Interval that puts the lower bound left automatically.
The provided data
is moved to the new Interval.
Definition at line 103 of file utils/containers/interval_tree/functions.hpp.
Interval<DataType, NumericalType, IntervalKind> genesis::utils::make_safe_interval | ( | NumericalType | lhs, |
NumericalType | rhs, | ||
DataType const & | data | ||
) |
Creates a safe Interval that puts the lower bound left automatically.
The provided data
is copied to the new Interval.
Definition at line 80 of file utils/containers/interval_tree/functions.hpp.
SvgGroup make_svg_axis | ( | SvgAxisSettings const & | settings, |
std::map< double, std::string > const & | labels, | ||
std::string const & | name = "" |
||
) |
SvgGroup make_svg_axis | ( | SvgAxisSettings const & | settings, |
std::vector< Tickmarks::LabeledTick > const & | labels, | ||
std::string const & | name = "" , |
||
bool | round_labels = true |
||
) |
Simple helper to make an axis.
This overload of the function takes the result of the Tickmarks class when creating labels, and forwards it to the other overload that takes string labeles instead, for convenience. When using round_labels
(default true
), std::round
is called on the label values first, in order to print integer numbers.
std::pair< SvgGradientLinear, SvgGroup > make_svg_color_bar | ( | SvgColorBarSettings const & | settings, |
ColorMap const & | map, | ||
ColorNormalization const & | norm, | ||
std::string const & | id | ||
) |
Definition at line 325 of file color_bar.cpp.
|
static |
Definition at line 128 of file color_bar.cpp.
|
static |
Definition at line 64 of file color_bar.cpp.
|
static |
Definition at line 210 of file color_bar.cpp.
Definition at line 376 of file color_bar.cpp.
SvgGroup make_svg_color_list | ( | std::vector< Color > const & | colors, |
std::vector< std::string > const & | labels | ||
) |
Definition at line 389 of file color_bar.cpp.
void genesis::utils::make_svg_color_list_entry_ | ( | size_t | i, |
Color const & | color, | ||
std::string const & | label, | ||
SvgGroup & | group | ||
) |
Definition at line 366 of file color_bar.cpp.
SvgGroup make_svg_matrix | ( | Matrix< Color > const & | mat, |
SvgMatrixSettings | settings | ||
) |
Definition at line 147 of file formats/svg/matrix.cpp.
SvgGroup make_svg_matrix | ( | Matrix< Color > const & | mat, |
SvgMatrixSettings | settings, | ||
std::vector< std::string > const & | row_labels | ||
) |
Definition at line 137 of file formats/svg/matrix.cpp.
SvgGroup make_svg_matrix | ( | Matrix< Color > const & | mat, |
SvgMatrixSettings | settings, | ||
std::vector< std::string > const & | row_labels, | ||
std::vector< std::string > const & | col_labels | ||
) |
Definition at line 50 of file formats/svg/matrix.cpp.
SvgGroup make_svg_pie_chart | ( | std::vector< double > const & | values, |
std::vector< Color > const & | colors, | ||
double | radius = 1.0 , |
||
double | start_angle = - PI/2.0 , |
||
bool | clockwise = true |
||
) |
Make a pie chart in SVG.
The given values
are automatically re-scaled to fill the circle. If there are more colors
than values
, only the first ones needed are used; if given colors
have fewer entries thatn there are values
, an exception is thrown.
The radius
of the char defaults to 1.0, and the start_angle
to -pi/2
, so that the chart starts from the top (most typical). By default, we also draw the values clockwise
(that is, reversed form the mathematical direction).
Definition at line 51 of file pie_chart.cpp.
TransformIterator<TransformFunctor, BaseIterator> genesis::utils::make_transform_iterator | ( | TransformFunctor | unary_func, |
BaseIterator | iterator | ||
) |
Construct a transforming iterator, given the underlying base iterator and the transformation function.
This constructor needs to be used for both the begin and end of the range that one wants to iterate, using the same transformation function both times. See also make_transform_iterator() and make_transform_range() for helper functions to easily create an instance.
Definition at line 426 of file transform_iterator.hpp.
Range<TransformIterator<TransformFunctor, BaseIterator> > genesis::utils::make_transform_range | ( | TransformFunctor | unary_func, |
BaseIterator | begin, | ||
BaseIterator | end | ||
) |
Construct a transforming range, given the transformation function as well as the underlying base iterator begin and end.
Definition at line 438 of file transform_iterator.hpp.
Range<TransformIterator<TransformFunctor, typename Container::iterator> > genesis::utils::make_transform_range | ( | TransformFunctor | unary_func, |
Container & | container | ||
) |
Construct a transforming range, given the transformation function as well as a container, whose begin() and end() iterators are used, respectively.
Definition at line 454 of file transform_iterator.hpp.
Range<TransformIterator<TransformFunctor, typename Container::const_iterator> > genesis::utils::make_transform_range | ( | TransformFunctor | unary_func, |
Container const & | container | ||
) |
Construct a transforming range, given the transformation function as well as a const container, whose begin() and end() iterators are used, respectively.
Definition at line 473 of file transform_iterator.hpp.
std::unique_ptr<T> genesis::utils::make_unique | ( | Args &&... | args | ) |
Returns a std::unique_ptr for a given type.
Since this is not available in C++11, we need our own implementation. It is following http://herbsutter.com/gotw/_102/ When using this function, make sure to specify at least the utils
namespace, even from within that namespace, in order to avoid name overloads if compiled with C++17.
double genesis::utils::manhattan_distance | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b | ||
) |
Calculate the Manhattan norm (L1 norm) distance between two (mathematical) vectors.
The function is a more expressive version of p_norm_distance( ForwardIteratorA, ForwardIteratorA, ForwardIteratorB, ForwardIteratorB, double ) with p == 1.0
. See there for details.
Definition at line 353 of file distance.hpp.
|
inline |
Calculate the Manhattan norm (L1 norm) distance between two vectors of double
elements.
The function is a more expressive version of p_norm_distance( std::vector<double> const&, std::vector<double> const&, double ) with p == 1.0
. See there for details.
Definition at line 367 of file distance.hpp.
Calculate the pairwise manhatten distance matrix between the rows of a given matrix.
See p_norm_distance_matrix() for details. This function simply uses a fixed p == 1.0
for more expressive code.
Definition at line 105 of file distance.cpp.
double genesis::utils::manhattan_norm | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the Manhattan norm (L1 norm) of a range of numbers.
The function is a more expressive version of p_norm( ForwardIterator, ForwardIterator, double ) with p == 1.0
. See there for details.
Definition at line 131 of file distance.hpp.
|
inline |
Calculate the Manhattan norm (L1 norm) of a std::vector
of double
elements.
The function is a more expressive version of p_norm( std::vector<double> const&, double ) with p == 1.0
. See there for details.
Definition at line 142 of file distance.hpp.
bool match_wildcards | ( | std::string const & | str, |
std::string const & | pattern | ||
) |
Return whether a string is matched by a wildcard pattern containing ?
and *
for single and mutliple (0 or more) wildcard characters, respectively.
Definition at line 286 of file string.cpp.
Calculate the element-wise sum of two Matrices.
The two matrices need to have the same dimensions.
Definition at line 486 of file math/matrix.hpp.
Calculate the element-wise sum of a Matrix and a scalar.
Definition at line 505 of file math/matrix.hpp.
std::vector<MinMaxPair<T> > genesis::utils::matrix_col_minmax | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the column-wise min and max values of a Matrix.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_row_minmax() and matrix_minmax().
Definition at line 99 of file math/matrix.hpp.
std::vector<T> genesis::utils::matrix_col_sums | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the sum of each column and return the result as a vector.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_row_sums() and matrix_sum().
Definition at line 231 of file math/matrix.hpp.
MinMaxPair<T> genesis::utils::matrix_minmax | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the min and max values of a Matrix.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_col_minmax() and matrix_row_minmax().
Definition at line 55 of file math/matrix.hpp.
Calculate the product of two Matrices.
The two matrices need to have fitting dimensions, i.e., a[ l, m ] x b[ m, n ]
, which results in a Matrix of dimensions r[ l, n ]
.
Definition at line 548 of file math/matrix.hpp.
std::vector<T> genesis::utils::matrix_multiplication | ( | Matrix< A > const & | a, |
std::vector< B > const & | b | ||
) |
Calculate the product of a Matrices a
with a vector
b
, as if the vector was a Matrix with only one column.
Thus, the two arguments need to have fitting dimensions, i.e., a[ l, m ] x b[ m ]
. The resulting vector has size l
, which represent the rows of the result Matrix.
Definition at line 602 of file math/matrix.hpp.
Calculate the element-wise multiplication of a Matrix and a scalar.
Definition at line 622 of file math/matrix.hpp.
std::vector<T> genesis::utils::matrix_multiplication | ( | std::vector< A > const & | a, |
Matrix< B > const & | b | ||
) |
Calculate the product of a vector
a
with a Matrices b
, as if the vector was a Matrix with only one row.
Thus, the two arguments need to have fitting dimensions, i.e., a[ m ] x b[ m, n ]
. The resulting vector has size n
, which represent the columns of the result Matrix.
Definition at line 578 of file math/matrix.hpp.
std::vector<MinMaxPair<T> > genesis::utils::matrix_row_minmax | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the row-wise min and max values of a Matrix.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_col_minmax() and matrix_minmax().
Definition at line 145 of file math/matrix.hpp.
std::vector<T> genesis::utils::matrix_row_sums | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the sum of each row and return the result as a vector.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_col_sums() and matrix_sum().
Definition at line 209 of file math/matrix.hpp.
Sort rows and columns of a Matrix by the sum or the columns.
This is an operation for square matrices: It takes the row sum as sorting criterion, and sorts the rows and the columns according to that order. This is mostly useful for symmetric matrices, where m[ i, j ] == m[ j, i ]
. In those cases, the sorting is stable with respect to the symmetry.
See also matrix_sort_by_row_sum_symmetric(). In case of symmetric matrices, it should yield the same Matrix.
Definition at line 415 of file math/matrix.hpp.
Sort rows and columns of a Matrix by the sum or the rows.
This is an operation for square matrices: It takes the row sum as sorting criterion, and sorts the rows and the columns according to that order. This is mostly useful for symmetric matrices, where m[ i, j ] == m[ j, i ]
. In those cases, the sorting is stable with respect to the symmetry.
See also matrix_sort_by_col_sum_symmetric(). In case of symmetric matrices, it should yield the same Matrix.
Definition at line 384 of file math/matrix.hpp.
Sort a Matrix so that the highest entries are on the diagonal.
The Matrix is sorted by moving the row and col with the highest entry to [ 0, 0 ]
, and then applying this operation to the rest of the matrix (that is, excluding the first row and col) iteratievly. The Matrix does not have to be symmetrical, but sorting keeps rows and columns intact.
Definition at line 443 of file math/matrix.hpp.
Calculate the element-wise difference of two Matrices.
The two matrices need to have the same dimensions.
Definition at line 522 of file math/matrix.hpp.
T genesis::utils::matrix_sum | ( | Matrix< T > const & | data, |
bool | ignore_non_finite_values = true |
||
) |
Calculate the sum of all elements in a Matrix.
If ignore_non_finite_values
is true
(default), non-finite values are ignored. See also matrix_col_sums() and matrix_row_sums().
Definition at line 190 of file math/matrix.hpp.
size_t max_bin | ( | const Histogram & | h | ) |
Definition at line 63 of file utils/math/histogram/stats.cpp.
double max_value | ( | const Histogram & | h | ) |
Definition at line 53 of file utils/math/histogram/stats.cpp.
double genesis::utils::maximum_distance | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b | ||
) |
Calculate the Maximum norm (infinity norm) distance between two (mathematical) vectors.
The function is a more expressive version of p_norm_distance( ForwardIteratorA, ForwardIteratorA, ForwardIteratorB, ForwardIteratorB, double ) with p
== std::numeric_limits<double>::infinity(). See there for details.
Definition at line 410 of file distance.hpp.
|
inline |
Calculate the Maximum norm (infinity norm) distance between two vectors of double
elements.
The function is a more expressive version of p_norm_distance( std::vector<double> const&, std::vector<double> const&, double ) with p
== std::numeric_limits<double>::infinity(). See there for details.
Definition at line 428 of file distance.hpp.
Calculate the pairwise maximum distance matrix between the rows of a given matrix.
See p_norm_distance_matrix() for details. This function simply uses a fixed p
== std::numeric_limits<double>::infinity() more expressive code.
Definition at line 115 of file distance.cpp.
double genesis::utils::maximum_norm | ( | ForwardIterator | first, |
ForwardIterator | last | ||
) |
Calculate the Maximum norm (infinity norm) of a range of numbers.
The function is a more expressive version of p_norm( ForwardIterator, ForwardIterator, double ) with p
== std::numeric_limits<double>::infinity(). See there for details.
Definition at line 178 of file distance.hpp.
|
inline |
Calculate the Maximum norm (infinity norm) of a std::vector
of double
elements.
The function is a more expressive version of p_norm( std::vector<double> const&, double ) with p
== std::numeric_limits<double>::infinity(). See there for details.
Definition at line 190 of file distance.hpp.
double mean | ( | const Histogram & | h | ) |
Compute the bin-weighted arithmetic mean.
The histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. The accuracy of the result is limited by the bin width.
Definition at line 91 of file utils/math/histogram/stats.cpp.
double genesis::utils::mean_squared_error | ( | ForwardIteratorA | first_x, |
ForwardIteratorA | last_x, | ||
ForwardIteratorB | first_y, | ||
ForwardIteratorB | last_y, | ||
LinearFunction | lin_fct | ||
) |
Calculate the mean squared error obtained from a linear fit of the input variables.
The error per data point (x,y)
is calculated as the squared differences between y
and the prediction given by the linear function lin_fct
for x
. The function returns the mean of the errors for all data points.
MeanStddevPair genesis::utils::mean_stddev | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
double | epsilon = -1.0 |
||
) |
Calculate the arithmetic mean and standard deviation of a range of double
elements.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. The function then calculates the arithmetic mean and standard deviation of all finite elements in the range. If no elements are finite, or if the range is empty, both returned values are 0.0
. Non-finite numbers are ignored.
If the resulting standard deviation is below the given epsilon
(e.g, 0.0000001
), it is "corrected" to be 1.0
instead. This is an inelegant (but usual) way to handle near-zero values, which for some use cases would cause problems like a division by zero later on. By default, epsilon
is -1.0
, which deactivates this check.
std::vector
. Definition at line 358 of file statistics.hpp.
|
inline |
Calculate the mean and standard deviation of a std::vector
of double
elements.
Definition at line 413 of file statistics.hpp.
double median | ( | const Histogram & | h | ) |
Definition at line 68 of file utils/math/histogram/stats.cpp.
double genesis::utils::median | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Calculate the median value of a sorted range of double
values.
The iterators are as usual: first
points to the first element of the range, last
to the past-the-end element.
The median of an odd sized range is its middle element; the median of an even sized range is the arithmetic mean (average) of its two middle elements.
Definition at line 1014 of file statistics.hpp.
|
inline |
Calculate the median value of a vector
of double
.
The vector has to be sorted.
Definition at line 1050 of file statistics.hpp.
size_t min_bin | ( | const Histogram & | h | ) |
Definition at line 58 of file utils/math/histogram/stats.cpp.
double min_value | ( | const Histogram & | h | ) |
Definition at line 48 of file utils/math/histogram/stats.cpp.
TableLayout minimal_layout | ( | ) |
Definition at line 439 of file utils/text/table.cpp.
std::pair<T, T> genesis::utils::minmax_value | ( | T const & | a, |
T const & | b | ||
) |
Returns the lowest and the greatest of the given values, by value.
The function differs from std::minmax
in its return value. Instead of references, it returns by value, which is useful for integers and the like.
Definition at line 128 of file algorithm.hpp.
std::pair<T, T> genesis::utils::minmax_value | ( | T const & | a, |
T const & | b, | ||
Compare | comp | ||
) |
Returns the lowest and the greatest of the given values, by value.
The function differs from std::minmax
in its return value. Instead of references, it returns by value, which is useful for integers and the like.
Definition at line 137 of file algorithm.hpp.
|
static |
Definition at line 120 of file strict_fstream.cpp.
Matrix< double > multi_dimensional_scaling | ( | Matrix< double > const & | distances, |
Matrix< double > const & | initial_values, | ||
size_t | dimensions = 2 , |
||
size_t | iterations = 100 , |
||
MdsAlgorithm | algorithm = MdsAlgorithm::kUcf |
||
) |
Multi-Dimensional Scaling (MDS).
The function expectes a square distances
matrix as well as a set of initial embedding values. See multi_dimensional_scaling() for a version that uses randomly initialized embedding values. The function then runs multi-dimensional scaling (MDS) for a given number of dimensions
, and optimizes the embeddings in iterations
. It offers two choices for the MDS algorithm
, of which we recommend the default one, see MdsAlgorithm.
The implementation is based on the SimpleMatrix library by Quan Wang, with his explicit permission to use this code here. The copyright (C) of the implementation is held by Quan Wang, 2013. We adapted the implementation to our Matrix class and changed the error reporting mechanism to exceptions. For further details, see the Acknowledgements.
Matrix< double > multi_dimensional_scaling | ( | Matrix< double > const & | distances, |
size_t | dimensions = 2 , |
||
size_t | iterations = 100 , |
||
MdsAlgorithm | algorithm = MdsAlgorithm::kUcf |
||
) |
Multi-Dimensional Scaling (MDS).
Run MDS with randomly initialized embedding values.
std::vector< size_t > multinomial_distribution | ( | std::vector< double > const & | p, |
size_t | n | ||
) |
Select a random sample following a multinomial distribution.
This overload accepts a std::vector<double>
, and checks that all values are finite and non-negative. Otherwise the same.
Definition at line 158 of file distribution.cpp.
std::vector< size_t > multinomial_distribution | ( | std::vector< size_t > const & | p, |
size_t | n | ||
) |
Select a random sample following a multinomial distribution.
This function computes a random sample formed by n
trials from an underlying distribution p
. The values in have
to be non-negative, and are taken as weights of each category; they do not need to be normalized to sum to 1. The function models drawing from multiple categories, each with probability as given in p
, with replacement. See multivariate_hypergeometric_distribution() for the equivalent distribution to draw without replacement instead.
See https://en.wikipedia.org/wiki/Multinomial_distribution for a description of the distribution. See https://www.gnu.org/software/gsl/doc/html/randist.html#the-multinomial-distribution for details on the distribution and the used algorithm, which follows C.S. Davis, "The computer generation of multinomial random variates", Comp. Stat. Data Anal. 16 (1993) 205–217.
Definition at line 153 of file distribution.cpp.
std::vector<size_t> genesis::utils::multinomial_distribution_ | ( | std::vector< T > const & | p, |
size_t | n | ||
) |
Definition at line 114 of file distribution.cpp.
std::vector< size_t > multivariate_hypergeometric_distribution | ( | std::vector< size_t > const & | p, |
size_t | n | ||
) |
Select a random sample following a multivariate hypergeometric distribution.
This function computes a random sample formed by n
trials from an underlying distribution p
. The values in have
to be non-negative, and are taken as weights of each category; they do not need to be normalized to sum to 1. The function models drawing from multiple categories, each with weights as given in p
, without replacement. See multinomial_distribution() for the equivalent distribution to draw with replacement instead.
Definition at line 517 of file distribution.cpp.
std::vector<T> genesis::utils::n_first_elements | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
size_t | n, | ||
Comp | comp = std::less<T>{} |
||
) |
Return the n
first elements of a given input range in sorting order.
The function uses comp
for the comparison, and returns a vector of the first n
elements of the input as sorted by comp
, in their correct order. For instance, when using std::greater, the largest n
elements are returned, with the largest one first, decending after that.
Definition at line 342 of file ranking.hpp.
void normalize | ( | Histogram & | h, |
double | total | ||
) |
Definition at line 61 of file operations.cpp.
std::vector< MinMaxPair< double > > normalize_cols | ( | Matrix< double > & | data | ) |
Normalize the columns of a Matrix so that all values are in the range [ 0.0, 1.0 ]
.
The Matrix is manipulated inline. For each column, the new values of the Matrix are calculated as \( x_{new} = \frac{ x - x_{min} }{ x_{max} - x_{min} } \).
The function returns a vector containing the min
and max
values of the columns before normalization, see matrix_col_minmax().
data | Input data Matrix; normalization is done inline. |
Definition at line 52 of file math/matrix.cpp.
std::vector< MinMaxPair< double > > normalize_rows | ( | Matrix< double > & | data | ) |
Normalize the rows of a Matrix so that all values are in the range [ 0.0, 1.0 ]
.
The Matrix is manipulated inline. For each row, the new values of the Matrix are calculated as \( x_{new} = \frac{ x - x_{min} }{ x_{max} - x_{min} } \).
The function returns a vector containing the min
and max
values of the rows before normalization, see matrix_row_minmax().
data | Input data Matrix; normalization is done inline. |
Definition at line 71 of file math/matrix.cpp.
void offset | ( | Histogram & | h, |
double | value | ||
) |
Definition at line 47 of file operations.cpp.
bool genesis::utils::operator!= | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
bool genesis::utils::operator!= | ( | JsonDocument const & | v, |
std::nullptr_t | |||
) |
Definition at line 432 of file optional.hpp.
Definition at line 426 of file optional.hpp.
Definition at line 380 of file optional.hpp.
|
inline |
Definition at line 502 of file optional.hpp.
bool genesis::utils::operator!= | ( | std::nullptr_t | , |
JsonDocument const & | v | ||
) |
|
inline |
Definition at line 508 of file optional.hpp.
Definition at line 271 of file bitvector.cpp.
|
inlineconstexprnoexcept |
And-operator to check whether a SkipWhitespace is set.
Typical usage:
SkipWhitespace option; if( option & SkipWhitespace::kTrailing ) { // Do stuff... }
See SkipWhitespace for more information.
Definition at line 97 of file scanner.hpp.
bool genesis::utils::operator< | ( | const JsonDocument::ValueType | lhs, |
const JsonDocument::ValueType | rhs | ||
) |
Returns an ordering that is similar to Python:
Definition at line 859 of file json/document.cpp.
bool genesis::utils::operator< | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
bool genesis::utils::operator< | ( | JsonDocument::const_reference | lhs, |
JsonDocument::const_reference | rhs | ||
) |
Compares whether one JSON value lhs is less than another JSON value rhs according to the following rules:
<
operator.Definition at line 793 of file json/document.cpp.
Definition at line 444 of file optional.hpp.
Definition at line 438 of file optional.hpp.
Definition at line 386 of file optional.hpp.
|
inline |
Definition at line 514 of file optional.hpp.
|
inline |
Definition at line 520 of file optional.hpp.
std::ostream & operator<< | ( | std::ostream & | os, |
Color const & | color | ||
) |
Write a textual representation of the Color the a stream, in the format "(r, g, b, a)".
Definition at line 129 of file utils/color/functions.cpp.
std::ostream & operator<< | ( | std::ostream & | os, |
const Histogram & | h | ||
) |
Definition at line 45 of file utils/math/histogram/operators.cpp.
std::ostream & operator<< | ( | std::ostream & | os, |
const HistogramAccumulator & | h | ||
) |
Definition at line 59 of file utils/math/histogram/operators.cpp.
std::ostream & operator<< | ( | std::ostream & | os, |
const Matrix< signed char > & | matrix | ||
) |
Template specialization for signed char
, in order to print nicely.
Definition at line 89 of file utils/containers/matrix/operators.cpp.
std::ostream& genesis::utils::operator<< | ( | std::ostream & | os, |
const Matrix< T > & | matrix | ||
) |
Print the elements of a Matrix to a stream, using operator <<
for each element.
Definition at line 211 of file utils/containers/matrix/operators.hpp.
std::ostream & operator<< | ( | std::ostream & | os, |
const Matrix< unsigned char > & | matrix | ||
) |
Template specialization for unsigned char
, in order to print nicely.
Definition at line 96 of file utils/containers/matrix/operators.cpp.
std::ostream & operator<< | ( | std::ostream & | os, |
GeoCoordinate const & | coord | ||
) |
Definition at line 344 of file utils/tools/geodesy/functions.cpp.
|
inline |
std::ostream & operator<< | ( | std::ostream & | s, |
Bitvector const & | bv | ||
) |
Insertion operator that outputs a Bitvector as a string of '0's and '1's.
Definition at line 161 of file utils/math/bitvector/operators.cpp.
std::ostream & operator<< | ( | std::ostream & | out, |
Style const & | style | ||
) |
Print the properties of a Style object to a stream.
The application of Styles is usually done by invoking its operator(). However, in order to be able to show its properties at a glance, this operator instead prints them:
Style s( "blue" ); std::cout << s;
will print this information instead of a stylized text.
std::ostream & operator<< | ( | std::ostream & | out, |
Table const & | table | ||
) |
Definition at line 255 of file utils/text/table.cpp.
std::ostream& genesis::utils::operator<< | ( | std::ostream & | out, |
TableLayout::Binder const & | binder | ||
) |
Definition at line 405 of file utils/text/table.cpp.
bool genesis::utils::operator<= | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
Definition at line 456 of file optional.hpp.
Definition at line 450 of file optional.hpp.
Definition at line 398 of file optional.hpp.
|
inline |
Definition at line 526 of file optional.hpp.
|
inline |
Definition at line 532 of file optional.hpp.
bool genesis::utils::operator== | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
bool genesis::utils::operator== | ( | JsonDocument const & | v, |
std::nullptr_t | |||
) |
bool genesis::utils::operator== | ( | JsonDocument::const_reference | lhs, |
JsonDocument::const_reference | rhs | ||
) |
Compares two JSON values for equality according to the following rules:
f1
and f2
are considered equal if neither f1 > f2
nor f2 > f1
holds.Definition at line 730 of file json/document.cpp.
Definition at line 420 of file optional.hpp.
Definition at line 414 of file optional.hpp.
Definition at line 374 of file optional.hpp.
|
inline |
Definition at line 490 of file optional.hpp.
bool genesis::utils::operator== | ( | std::nullptr_t | , |
JsonDocument const & | v | ||
) |
|
inline |
Definition at line 496 of file optional.hpp.
bool genesis::utils::operator> | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
Definition at line 468 of file optional.hpp.
Definition at line 462 of file optional.hpp.
Definition at line 392 of file optional.hpp.
|
inline |
Definition at line 538 of file optional.hpp.
|
inline |
Definition at line 544 of file optional.hpp.
bool genesis::utils::operator>= | ( | JsonDocument const & | lhs, |
JsonDocument const & | rhs | ||
) |
Definition at line 480 of file optional.hpp.
Definition at line 474 of file optional.hpp.
Definition at line 404 of file optional.hpp.
|
inline |
Definition at line 550 of file optional.hpp.
|
inline |
Definition at line 556 of file optional.hpp.
std::istream & operator>> | ( | std::istream & | in, |
Bitvector & | bv | ||
) |
Extraction operator that inputs a Bitvector from a string of '0's and '1's, and stops at the first char that is not '0' or '1'.
Definition at line 169 of file utils/math/bitvector/operators.cpp.
Definition at line 285 of file bitvector.cpp.
Definition at line 278 of file bitvector.cpp.
double genesis::utils::p_norm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
double | p = 2.0 |
||
) |
Calculate the p-norm of a range of numbers.
The iterators first
and last
need to point to a range of double
values, with last
being the past-the-end element. The parameter p
has to be >= 1.0. In order to get the maximum norm (or infinity norm), p
can also be set to positive infinity, that is, std::numeric_limits<double>::infinity()
. Default is p == 2.0
, which is the Euclidean norm.
p
, in order to make code more expressive. Definition at line 70 of file distance.hpp.
|
inline |
Calculate the p-norm of a std::vector
of double
elements.
Definition at line 119 of file distance.hpp.
double genesis::utils::p_norm_distance | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b, | ||
double | p = 2.0 |
||
) |
Calculate the p-norm distance between two (mathematical) vectors.
The iterators first_a
, last_a
, first_b
, and last_b
need to point to a range of double
values, with last_a
and last_b
being the past-the-end elements. The parameter p
has to be >= 1.0. In order to get the maximum norm distance (or infinity norm distance), p
can also be set to positive infinity, that is, std::numeric_limits<double>::infinity()
. Default is p == 2.0
, which is the Euclidean distance.
See https://en.wikipedia.org/wiki/Distance#Distance_in_Euclidean_space for details.
p
, in order to make code more expressive. Definition at line 287 of file distance.hpp.
|
inline |
Calculate the p-norm distance between two vectors of double
elements.
Definition at line 339 of file distance.hpp.
Calculate the pairwise distance matrix between the rows of a given matrix.
The function uses p_norm_distance() to calculate the distances, see there for details. Each row of the matrix is considered a vector with the length of the columns of the matrix. Hence, the resulting quadratic distance matrix has dimensions r * r
, with r
being the number of rows of the input matrix.
p
for more expressive code. Definition at line 48 of file distance.cpp.
MultiFuture<R> genesis::utils::parallel_block | ( | T1 | begin, |
T2 | end, | ||
F && | body, | ||
std::shared_ptr< ThreadPool > | thread_pool = nullptr , |
||
size_t | num_blocks = 0 , |
||
bool | auto_wait = true |
||
) |
Parallel block over a range of elements, breaking the range into blocks for which the body
function is executed individually.
The function takes a begin
index and an end
(past-the-end) index, and executes the body
in num_blocks
many blocks, by submitting tasks to the thread_pool
, aiming to equally distribute the work across the range begin
to end
. In other words, it is equivalent to for( T i = begin; i < end; ++i )
.
The body
function to loop through is called once per block. It should take two arguments: the first index in the block and the index after the last index in the block, e.g.:
The thread_pool
defaults to using the Options::get().global_thread_pool(). This requires to call Options::get().init_global_thread_pool() first.
The num_blocks
determines the number of blocks to split the loop body into. Default is to use the number of threads in the pool.
By default, auto_wait
is set to true
, meaning that the function blocks until the results are ready. This is meant as a convenience and safety mechanism, as otherwise the user might forget to wait, and continue with other things while the thread pool is still working on the blocks.
The function returns a MultiFuture that can be used to obtian the results for all the blocks. If auto_wait == false
, this also can be used to call wait() on the returned MultiFuture to wait for all blocks to finish.
If the loop body returns a value, the MultiFuture can also be used to obtain the values returned by each block, for example:
This is useful for example for aggregating values, such as a parallel sum.
Definition at line 143 of file thread_functions.hpp.
MultiFuture<void> genesis::utils::parallel_for | ( | T1 | begin, |
T2 | end, | ||
F && | body, | ||
std::shared_ptr< ThreadPool > | thread_pool = nullptr , |
||
size_t | num_blocks = 0 , |
||
bool | auto_wait = true |
||
) |
Parallel for
over a range of positions, breaking the range into blocks for which the body
function is executed individually.
This is almost the same as parallel_block(), but intended to be used with for
loops that do not need to compute per-block return values. The function signature of F
is hence simply expected to be void F( size_t i )
, and is called for every position in the processed range.
This makes it a convenience function; see also parallel_for_each() for container-based data.
By default, auto_wait
is set to true
, meaning that the function first waits for all results to be ready, and only returns afterwards. Then, the returned future is ready immediately. This ensures that the user cannot accidentally forget to wait for the result, making this function behave more intuitively like an #pragma omp parallel for
or the like.
Definition at line 259 of file thread_functions.hpp.
MultiFuture<void> genesis::utils::parallel_for_each | ( | T & | container, |
F && | body, | ||
std::shared_ptr< ThreadPool > | thread_pool = nullptr , |
||
size_t | num_blocks = 0 , |
||
bool | auto_wait = true |
||
) |
Parallel for each
over a container, processing it in blocks for which the body
function is executed individually.
Expects a random access container that supports size()
as well as operator[]
to access individual elements, and a body
that takes one element of that container to process.
This makes it a convenience function.
By default, auto_wait
is set to true
, meaning that the function first waits for all results to be ready, and only returns afterwards. Then, the returned future is ready immediately. This ensures that the user cannot accidentally forget to wait for the result, making this function behave more intuitively like an #pragma omp parallel for
or the like.
Definition at line 369 of file thread_functions.hpp.
MultiFuture<void> genesis::utils::parallel_for_each | ( | T const | begin, |
T const | end, | ||
F && | body, | ||
std::shared_ptr< ThreadPool > | thread_pool = nullptr , |
||
size_t | num_blocks = 0 , |
||
bool | auto_wait = true |
||
) |
Parallel for each
over a container, processing it in blocks for which the body
function is executed individually.
This is almost the same as parallel_for(), but intended to be used with containers. The function signature of F
is hence simply expected to be void F( T& element )
or void F( T const& element )
, and is called for every element in the container.
This makes it a convenience function.
By default, auto_wait
is set to true
, meaning that the function first waits for all results to be ready, and only returns afterwards. Then, the returned future is ready immediately. This ensures that the user cannot accidentally forget to wait for the result, making this function behave more intuitively like an #pragma omp parallel for
or the like.
Definition at line 306 of file thread_functions.hpp.
T genesis::utils::parse_float | ( | utils::InputStream & | source | ) |
Read a floating point number from a stream and return it.
The number is expected to be in the following format:
[+-][123][.456][eE[+-]789]
It furthermore supports signed nan
, inf
, and infinity
as special strings, case insensitive. The function stops reading at the first non-fitting character. It throws an std::overflow_error
or underflow_error
in case that the exponent (the part after the 'E') does not fit into integer value range.
Definition at line 176 of file parser.hpp.
T genesis::utils::parse_integer | ( | utils::InputStream & | source | ) |
Alias for parse_signed_integer().
Definition at line 154 of file parser.hpp.
std::string parse_number_string | ( | utils::InputStream & | source | ) |
Read a general number string from an input stream.
The function reads from the input as long as it is a valid number of the format
[+-][123][.456][eE[+-]789]
and returns this string. This is useful for intermediately parsing a number and then checking whether it is valid. Use parse_float() to turn such a number string into an actual float/double.
Definition at line 479 of file parser.cpp.
std::string parse_quoted_string | ( | utils::InputStream & | source, |
bool | use_escapes = true , |
||
bool | use_twin_quotes = false , |
||
bool | include_qmarks = false |
||
) |
Read a string in quotation marks from a stream and return it.
The first char of the stream is considered to be the opening quotation mark. Everything up until the closing quotation mark (the same char again, whatever it is) is then read. The stream is then pointing to the char right after the closing quotation mark.
If the string ends prematurely, i.e., without the closing quotation mark, or right after a backslash if use_escapes
is used, the function throws an std::runtime_error
.
source | Stream to read from. |
use_escapes | If this optional parameter is set to true , chars preceeded by a backslash \ are considered to be "escaped". If the char following the backslash is any of r , n or t , it is turned into its respective white space equivalent, while all other chars are copied verbatim to the return string. Thus, by escaping it, a the string can also include the quotation mark itself. Default of this parameter is true . |
use_twin_quotes | If this optional parameter is set to true , the quotation mark itself can be escaped using two consecutive quotation marks. This works in addition to escaping it with a backslash (when use_escapes is used). |
include_qmarks | The optional parameter include_qmarks demtermines whether the quotation marks are included in the output or not. Default is false . |
Definition at line 547 of file parser.cpp.
T genesis::utils::parse_signed_integer | ( | utils::InputStream & | source | ) |
Read a signed integer from a stream and return it.
The function expects a sequence of digits, possibly with a leading +
or -
. The first char after that has to be a digit, otherwise the function throws std::runtime_error
. It stops reading at the first non-digit. In case the value range is too small, the function throws std::overflow_error
, or underflow_error
, respectively.
Definition at line 101 of file parser.hpp.
T genesis::utils::parse_unsigned_integer | ( | utils::InputStream & | source | ) |
Read an unsigned integer from a stream and return it.
The function expects a sequence of digits. The current char in the stream has to be a digit, otherwise the function throws std::runtime_error
. It stops reading at the first non-digit. In case the value range is too small, the function throws std::overflow_error
.
Definition at line 68 of file parser.hpp.
size_t genesis::utils::parse_unsigned_integer_naive_ | ( | utils::InputStream & | source | ) |
Naive parsing that simply loops over chars.
Definition at line 401 of file parser.cpp.
size_t parse_unsigned_integer_size_t | ( | utils::InputStream & | source | ) |
Parse the input source
as an unsigned int into a size_t.
This is the basic parsing function that we use internally for the function templates parse_unsigned_integer() and parse_signed_integer(). That means, our internal int size cannot exceed 64 bits. That should be okay.
Definition at line 453 of file parser.cpp.
bool path_exists | ( | std::string const & | path | ) |
|
inlinestatic |
Definition at line 53 of file random.cpp.
double genesis::utils::pearson_correlation_coefficient | ( | ForwardIteratorA | first_a, |
ForwardIteratorA | last_a, | ||
ForwardIteratorB | first_b, | ||
ForwardIteratorB | last_b | ||
) |
Calculate the Pearson Correlation Coefficient between two ranges of double
.
Both ranges need to have the same length. Then, the function calculates the PCC between the pairs of entries of both ranges. It skipes entries where any of the two values is not finite.
If each pair of entries in the ranges contains at leat one non-finite value, that is, if there are no pairs of finite values, a quiet_NaN
is returned. Furtheremore, if one of the ranges has a standard deviation of 0.0
, e.g., because all its entries are 0.0
themselves, a division by 0 occurs, leading to a NaN
as well.
Definition at line 71 of file correlation.hpp.
|
inline |
Calculate the Pearson Correlation Coefficient between the entries of two vectors.
Both ranges need to have the same length. Then, the function calculates the PCC between the pairs of entries of both ranges. It skipes entries where any of the two values is not finite.
If each pair of entries in the ranges contains at leat one non-finite value, that is, if there are no pairs of finite values, a quiet_NaN
is returned. Furtheremore, if one of the ranges has a standard deviation of 0.0
, e.g., because all its entries are 0.0
themselves, a division by 0 occurs, leading to a NaN
as well.
Definition at line 123 of file correlation.hpp.
uint32_t permuted_congruential_generator | ( | ) |
Fast random number generator for 32bit integers.
See https://en.wikipedia.org/wiki/Permuted_congruential_generator for details. See permuted_congruential_generator_init() to set the seed.
Definition at line 58 of file random.cpp.
uint32_t permuted_congruential_generator | ( | uint32_t | max | ) |
Fast random number generator for 32bit integers, for numbers in the range [0, max]
.
Note that the interval is closed, i.e., max
is inclusive.
Definition at line 68 of file random.cpp.
uint32_t permuted_congruential_generator | ( | uint32_t | min, |
uint32_t | max | ||
) |
Fast random number generator for 32bit integers, for numbers in the range [min, max]
.
Note that the interval is closed, i.e., max
is inclusive.
Definition at line 73 of file random.cpp.
bool permuted_congruential_generator_bool | ( | ) |
Fast random number generator for 32bit integers, for bool with 0.5 probability.
Definition at line 84 of file random.cpp.
bool permuted_congruential_generator_bool | ( | uint32_t | chance_one_in | ) |
Fast random number generator for 32bit integers, for bool with a given chance.
This is returning a random bool, with a 1 in chance_one_in
possibility to be true
. For instance, calling the function with chance_one_in == 5
means a 1 in 5 chance, or probability of 0.2 for a true
result.
Definition at line 89 of file random.cpp.
void permuted_congruential_generator_init | ( | uint64_t | seed | ) |
Set the seed for permuted_congruential_generator().
Definition at line 99 of file random.cpp.
PcaData principal_component_analysis | ( | Matrix< double > const & | data, |
size_t | components = 0 , |
||
PcaStandardization | standardization = PcaStandardization::kCorrelation |
||
) |
Perfom a Principal Component Analysis on a given data
Matrix.
Principal Components Analysis or the Karhunen-Loeve expansion is a classical method for dimensionality reduction or exploratory data analysis. One reference among many is: F. Murtagh and A. Heck, Multivariate Data Analysis, Kluwer Academic, Dordrecht, 1987.
data | Matrix with the data, samples in rows, features in columns. |
components | Intended number of PCA components to calculate. If 0 (default), all PCA components are calculated, i.e., as many components as data has columns. |
standardization | Indicate the standardization algorithm to perfom on the data before calculating the PCA components, see PcaStandardization. |
std::string genesis::utils::print | ( | Matrix< T > const & | matrix, |
size_t | rows = 10 , |
||
size_t | cols = 10 |
||
) |
Print a Matrix to a std::string
.
If rows
== 0, all rows are printed. Otherwise, only the given number of rows is printed, followed by an ellipsis (...
). The same applies to the columns, using cols
.
See also print( std::ostream&, Matrix<T> const&, size_t, size_t ).
Definition at line 285 of file utils/containers/matrix/operators.hpp.
void genesis::utils::print | ( | std::ostream & | out, |
Matrix< T > const & | matrix, | ||
size_t | rows = 10 , |
||
size_t | cols = 10 |
||
) |
Print a Matrix to an out stream. See print( Matrix<T> const&, size_t, size_t ) for details.
Definition at line 242 of file utils/containers/matrix/operators.hpp.
void genesis::utils::print_byte_matrix_ | ( | std::ostream & | os, |
const Matrix< T > & | matrix, | ||
size_t | width | ||
) |
Local helper function to avoid code duplication.
Definition at line 75 of file utils/containers/matrix/operators.cpp.
|
inline |
Calculate the quartile_coefficient_of_dispersion.
The quartile coefficient of dispersion is defined as ( Q3 - Q1 ) / ( Q3 + Q1 )
. See quartiles() to caculate those values. See https://en.wikipedia.org/wiki/Quartile_coefficient_of_dispersion for details.
Definition at line 1175 of file statistics.hpp.
|
inline |
Calculate the quartile_coefficient_of_dispersion.
The quartile coefficient of dispersion is defined as ( Q3 - Q1 ) / ( Q3 + Q1 )
. See quartiles() to caculate those values. See https://en.wikipedia.org/wiki/Quartile_coefficient_of_dispersion for details.
Definition at line 1183 of file statistics.hpp.
Quartiles genesis::utils::quartiles | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Calculate the Quartiles of a sorted range of double
values.
The iterators are as usual: first
points to the first element of the range, last
to the past-the-end element.
Definition at line 1066 of file statistics.hpp.
|
inline |
Calculate the Quartiles of a vector
of double
.
The vector has to be sorted.
Definition at line 1108 of file statistics.hpp.
std::vector<size_t> genesis::utils::ranking_dense | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Return the ranking of the values in the given range, using Dense ranking ("1223" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 169 of file ranking.hpp.
|
inline |
Return the ranking of the values in the given range, using Dense ranking ("1223" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 201 of file ranking.hpp.
std::vector<double> genesis::utils::ranking_fractional | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Return the ranking of the values in the given range, using Fractional ranking ("1 2.5 2.5 4" ranking).
See https://en.wikipedia.org/wiki/Ranking for details. This is the only raking method that returns float values instead of integer values.
Definition at line 262 of file ranking.hpp.
|
inline |
Return the ranking of the values in the given range, using Fractional ranking ("1 2.5 2.5 4" ranking).
See https://en.wikipedia.org/wiki/Ranking for details. This is the only raking method that returns float values instead of integer values.
Definition at line 321 of file ranking.hpp.
std::vector<size_t> genesis::utils::ranking_modified | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Return the ranking of the values in the given range, using Modified competition ranking ("1334" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 112 of file ranking.hpp.
|
inline |
Return the ranking of the values in the given range, using Modified competition ranking ("1334" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 151 of file ranking.hpp.
std::vector<size_t> genesis::utils::ranking_ordinal | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Return the ranking of the values in the given range, using Ordinal ranking ("1234" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 219 of file ranking.hpp.
|
inline |
Return the ranking of the values in the given range, using Ordinal ranking ("1234" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 242 of file ranking.hpp.
std::vector<size_t> genesis::utils::ranking_standard | ( | RandomAccessIterator | first, |
RandomAccessIterator | last | ||
) |
Return the ranking of the values in the given range, using Standard competition ranking ("1224" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 61 of file ranking.hpp.
|
inline |
Return the ranking of the values in the given range, using Standard competition ranking ("1224" ranking).
See https://en.wikipedia.org/wiki/Ranking for details.
Definition at line 93 of file ranking.hpp.
|
inline |
Lexing function that reads a single char from the stream and checks whether it equals the provided one.
If not, the function throws std::runtime_error
. The stream is advanced by one position and the char is returned. For a similar function that checks the value of the current char but does not advance in the stream, see affirm_char_or_throw().
Using the parameter skip_ws
, it is possible to skip leading and/or trailing whitespaces before/after treating the criterion
char. See SkipWhitespace for more information.
Definition at line 299 of file scanner.hpp.
|
inline |
Lexing function that reads a single char from the stream and checks whether it fulfills the provided criterion.
If not, the function throws std::runtime_error
. The stream is advanced by one position and the char is returned. For a similar function that checks the value of the current char but does not advance in the stream, see affirm_char_or_throw().
Using the parameter skip_ws
, it is possible to skip leading and/or trailing whitespaces before/after treating the criterion
char. See SkipWhitespace for more information.
Definition at line 340 of file scanner.hpp.
size_t genesis::utils::read_id_from_file_ | ( | std::string const & | filename | ) |
|
inline |
Lexing function that reads until the end of the line (i.e., to the new line char), and returns the read chars (excluding the new line char).
The stream is left at the new line char. If the stream is already at its last line, this function reads to the end of the stream.
Definition at line 134 of file scanner.hpp.
|
inline |
Lexing function that reads from the stream until its current char equals the provided one. The read chars are returned.
Definition at line 254 of file scanner.hpp.
|
inline |
Lexing function that reads from the stream until its current char fulfills the provided criterion. The read chars are returned.
Definition at line 271 of file scanner.hpp.
|
inline |
Lexing function that reads from the stream while its current char equals the provided one. The read chars are returned.
Definition at line 216 of file scanner.hpp.
|
inline |
Lexing function that reads from the stream while its current char fulfills the provided criterion. The read chars are returned.
Definition at line 233 of file scanner.hpp.
|
static |
std::string real_path | ( | std::string const & | path, |
bool | resolve_link = true |
||
) |
Return the real path of a file or directory, similar to realpath().
The function behaves similar to realpath(), but (hopefully) offers better protability and error handling (long paths etc).
As this function changes the directory in the process, it is not thread safe.
|
static |
|
static |
|
static |
TridiagonalDecompositionData reduce_to_tridiagonal_matrix | ( | Matrix< double > & | data | ) |
Triangular decomposition of a symmetric matrix.
This function performs an intermediate step that is usually followed by an execution of the tridiagonal_ql_algorithm().
It uses the Householder reduction of matrix a to tridiagonal form, according to
Martin et al., Num. Math. 11, 181-195, 1968. Ref: Smith et al., Matrix Eigensystem Routines -- EISPACK Guide Springer-Verlag, 1976, pp. 489-494. W H Press et al., Numerical Recipes in C, Cambridge U P, 1988, pp. 373-374.
There, the function is called tred2()
.
The implementation of this function is largely borrowed from http://www.classification-society.org/csna/mda-sw/pca.c and http://ftp.uni-bayreuth.de/math/statlib/multi/pca.c published as Public Domain by Fionn Murtagh.
data | Input data matrix. Operations are performed inline, that is, the matrix is changed during execution of the function. |
|
static |
std::string remove_all | ( | std::string const & | text, |
std::string const & | search | ||
) |
Return a copy of a string, where all occurrences of a search string are removed.
Definition at line 761 of file string.cpp.
std::string remove_all_chars | ( | std::string const & | text, |
std::string const & | search_chars | ||
) |
Remove all occurrences of the search_chars
in text
.
Definition at line 782 of file string.cpp.
std::string genesis::utils::remove_all_chars_pred | ( | std::string const & | text, |
UnaryPredicate | predicate | ||
) |
Remove all occurrences characters for which predicate
is true
in text
.
Definition at line 430 of file string.hpp.
std::string remove_all_non_alnum | ( | std::string const & | text | ) |
Remove all non-alphanumerical characters from a string.
Definition at line 794 of file string.cpp.
std::string repeat | ( | std::string const & | word, |
size_t | times | ||
) |
Take a string and repeat it a given number of times.
Definition at line 1001 of file string.cpp.
std::string replace_all | ( | std::string const & | text, |
std::string const & | search, | ||
std::string const & | replace | ||
) |
Return a copy of a string, where all occurrences of a search string are replaced by a replace string.
Definition at line 727 of file string.cpp.
std::string replace_all_chars | ( | std::string const & | text, |
std::string const & | search_chars, | ||
char | replace | ||
) |
Replace all occurrences of the search_chars
in text
by the replace
char.
Definition at line 768 of file string.cpp.
std::string genesis::utils::replace_all_chars_pred | ( | std::string const & | text, |
UnaryPredicate | predicate, | ||
char | replace | ||
) |
Replace all occurrences of characters for which predicate
is true
in text
by the replace
char.
Definition at line 404 of file string.hpp.
Color resolve_color_string | ( | std::string const & | color_str | ) |
Resolve a string representing a color.
The string can either be a hex color as accepted by color_from_hex(), e.g., "#003366[ff]", or one of the named colors, see is_color_name() and color_from_name().
Definition at line 138 of file utils/color/functions.cpp.
|
inline |
Retun the value of x
, rounded to the decimal digit given by accuracy_order
.
Definition at line 175 of file common.hpp.
std::string sanitize_filename | ( | std::string const & | filename | ) |
Remove or replace all invalid parts of a filename.
Similar to is_valid_filename(), this function is not meant to be an ultimate solution to valid filenames. See there for details.
The function is meant to be called on the file name itself, without the directory path leading to it. File extensions are allowed. Thus, you might need to call file_basename() before in order to get the file name without the path.
This function does the following:
If after this procedure the filename is empty, an exception is thrown. This is meant to save the user from checking this, or from running into trouble when trying to write to this "file" - because an empty filename will point to a directory name.
std::string sanitize_geo_coordinate | ( | std::string const & | coordinate, |
bool | two_components = true |
||
) |
Replace non-ascii symbols used in geographic coordinates by their ascii equivalents.
The function replaces symbols such as degrees, primes, double primes by simple letters ('dms') that serve the same function.
Furthermore, if two_components
is true
(default), the function assumes that the given coordinate contains two components (North/South and East/West). In that case, if there is exaclty one comma in the input, it is replaced by a slash. This is meant to avoid ambiguity in parsing of a coordinate that uses commas as decimal separator. Hence, when sanitizing a coordinate with only one component, two_components
needs to be set to false
in order to avoid replacing a single decimal separator comma by a slash.
Definition at line 198 of file utils/tools/geodesy/functions.cpp.
void scale | ( | Histogram & | h, |
double | factor | ||
) |
Definition at line 54 of file operations.cpp.
std::vector< size_t > select_without_replacement | ( | size_t | k, |
size_t | n | ||
) |
Select k
many unique numbers out of the range [ 0, n )
.
In other words, select k
numbers out of the sequence of n
numbers, without replacement.
The implementation is based on Algorithm 3.4.2S of Knuth's book Seminumeric Algorithms.
k | Desired sample size. |
n | Total population size. |
k
unique numbers out of the range [ 0, n )
. Definition at line 108 of file random.cpp.
Definition at line 84 of file utils/math/bitvector/operators.cpp.
double sigma | ( | const Histogram & | h | ) |
Compute the bin-weighted standard deviation.
The histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. The accuracy of the result is limited by the bin width.
Definition at line 114 of file utils/math/histogram/stats.cpp.
|
inlineconstexpr |
Get the sign of a value, which is either -1, 0, or 1.
Works for all numerical types. We use two tagged implementations for signed and unsigned types in order to avoid compiler warnings. See http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c for details.
Definition at line 133 of file common.hpp.
|
inlineconstexpr |
Implementation of signum(T x) for unsigned types. See there for details.
Definition at line 104 of file common.hpp.
|
inlineconstexpr |
Implementation of signum(T x) for signed types. See there for details.
Definition at line 116 of file common.hpp.
TableLayout simple_frame | ( | bool | condensed | ) |
Definition at line 483 of file utils/text/table.cpp.
TableLayout simple_grid | ( | bool | condensed | ) |
Definition at line 464 of file utils/text/table.cpp.
TableLayout simple_layout | ( | bool | condensed | ) |
Definition at line 445 of file utils/text/table.cpp.
LinearFunction genesis::utils::simple_linear_regression | ( | ForwardIteratorA | first_x, |
ForwardIteratorA | last_x, | ||
ForwardIteratorB | first_y, | ||
ForwardIteratorB | last_y | ||
) |
Simple linear regression, for predicting the dependent variable y
given the independent variable x
, using ordinary least squares regression.
See https://en.wikipedia.org/wiki/Simple_linear_regression for an explanation.
|
inline |
Lexing function that advances the stream to the end of the line, i.e., to the new line char.
If the stream is already at its last line, this function moves to the end of the stream.
Definition at line 118 of file scanner.hpp.
|
inline |
Lexing function that advances the stream until its current char equals the provided one.
Definition at line 184 of file scanner.hpp.
|
inline |
Lexing function that advances the stream until its current char fulfills the provided criterion.
Definition at line 198 of file scanner.hpp.
|
inline |
Lexing function that advances the stream while its current char equals the provided one.
Definition at line 153 of file scanner.hpp.
|
inline |
Lexing function that advances the stream while its current char fulfills the provided criterion.
Definition at line 167 of file scanner.hpp.
|
inline |
Get the indices to the sorted order of the given range.
This function returns a list of indices into the given range, so that their order gives the sorted content of the elements in [ first, last )
, using std::less
for comparisons.
For example,
for( auto i: sort_indices(v) ) { cout << *( first + i ) << endl; }
outputs the elements in the range in sorted order, without actually moving any elements in the range. This is useful if the same sorting order needs to be applied to some other container.
There is also an overload of this function that takes an additional parameter comparator
. It can be used to specify the function for comparing two values of the range.
Furthermore, there are variants that use std::stable_sort
instead, see stable_sort_indices().
Definition at line 224 of file algorithm.hpp.
|
inline |
Get the indices to the sorted order of the given range.
This function returns a list of indices into the given range, so that their order gives the sorted content of the elements in [ first, last )
, using std::less
for comparisons.
For example,
for( auto i: sort_indices(v) ) { cout << *( first + i ) << endl; }
outputs the elements in the range in sorted order, without actually moving any elements in the range. This is useful if the same sorting order needs to be applied to some other container.
There is also an overload of this function that takes an additional parameter comparator
. It can be used to specify the function for comparing two values of the range.
Furthermore, there are variants that use std::stable_sort
instead, see stable_sort_indices().
Definition at line 182 of file algorithm.hpp.
|
inline |
Sort a range of std::string (or convertible to std::string) elements, using natural sorting; see compare_natural().
Definition at line 246 of file string.hpp.
double genesis::utils::spearmans_rank_correlation_coefficient | ( | RandomAccessIteratorA | first_a, |
RandomAccessIteratorA | last_a, | ||
RandomAccessIteratorB | first_b, | ||
RandomAccessIteratorB | last_b | ||
) |
Calculate Spearman's Rank Correlation Coefficient between two ranges of double
.
Both ranges need to have the same length. Then, the function calculates Spearmans's Rho between the pairs of entries of both vectors. Ranking is done via fractional ranking. Pairs of entries which contain non-finite values are skipped.
Definition at line 145 of file correlation.hpp.
|
inline |
Calculate Spearman's Rank Correlation Coefficient between the entries of two vectors.
Both ranges need to have the same length. Then, the function calculates Spearmans's Rho between the pairs of entries of both vectors. Ranking is done via fractional ranking. Pairs of entries which contain non-finite values are skipped.
Definition at line 166 of file correlation.hpp.
std::vector< std::string > split | ( | std::string const & | str, |
char | delimiter = '\t' , |
||
const bool | trim_empty = true |
||
) |
Spilt a string
into parts, given a delimiter
char.
The string
is split using the delimiter
char, and returned as a vector of strings. If trim_empty
is set, empty strings resulting from adjacent delimiter chars are excluded from the output.
Definition at line 575 of file string.cpp.
std::vector< std::string > split | ( | std::string const & | str, |
std::function< bool(char)> | delimiter_predicate, | ||
const bool | trim_empty = true |
||
) |
Spilt a string
into parts, given a delimiter_predicate
that returns true
for delimiters chars.
The string
is split using any of the chars for which delimiter_predicate
is true
, and returned as a vector of strings. If trim_empty
is set, empty strings resulting from adjacent delimiter chars are excluded from the output.
Definition at line 598 of file string.cpp.
std::vector< std::string > split | ( | std::string const & | str, |
std::string const & | delimiters, | ||
const bool | trim_empty = true |
||
) |
Spilt a string
into parts, given a delimiters
set of chars.
The string
is split using any of the chars in delimiters
, and returned as a vector of strings. If trim_empty
is set, empty strings resulting from adjacent delimiter chars are excluded from the output.
Definition at line 583 of file string.cpp.
|
static |
Local function that does the work for the split cuntions.
Definition at line 539 of file string.cpp.
std::vector< std::string > split_at | ( | std::string const & | str, |
std::string const & | delimiter, | ||
const bool | trim_empty = true |
||
) |
Spilt a string
into parts, given a delimiter
string.
The string
is split where the whole delimiter
string is found, and returned as a vector of strings. If trim_empty
is set, empty strings resulting from adjacent delimiters are excluded from the output.
Definition at line 621 of file string.cpp.
std::vector< size_t > split_range_list | ( | std::string const & | str | ) |
Split a string containing positive interger numbers into its parts and resolve ranges.
For example, the string 1, 3, 5-7, 10
results in a vector of all listed numbers and the ranges in between, that is 1, 3, 5, 6, 7, 10
. Whitespace is ignored; the range is sorted.
Definition at line 636 of file string.cpp.
|
inlineconstexpr |
Square of a number.
Simply \( x^2 \), but faster than std::pow
for the low exponent. Meant as an abbreviation where the argument is not already a variable, e.g., squared( x - 1.0 )
, without the need to store the intermediate argument term.
Definition at line 223 of file common.hpp.
|
inline |
Get the indices to the stable sorted order of the given range.
This function returns a list of indices into the given range, so that their order gives the stable sorted content of the elements in [ first, last )
, using std::less
for comparisons.
For example,
for( auto i: stable_sort_indices(v) ) { cout << *( first + i ) << endl; }
outputs the elements in the range in stable sorted order, without actually moving any elements in the range. This is useful if the same sorting order needs to be applied to some other container.
There is also an overload of this function that takes an additional parameter comparator
. It can be used to specify the function for comparing two values of the range.
Furthermore, there are variants that use normal std::sort
instead, see sort_indices().
Definition at line 281 of file algorithm.hpp.
|
inline |
Get the indices to the stable sorted order of the given range.
This function returns a list of indices into the given range, so that their order gives the stable sorted content of the elements in [ first, last )
, using std::less
for comparisons.
For example,
for( auto i: stable_sort_indices(v) ) { cout << *( first + i ) << endl; }
outputs the elements in the range in stable sorted order, without actually moving any elements in the range. This is useful if the same sorting order needs to be applied to some other container.
There is also an overload of this function that takes an additional parameter comparator
. It can be used to specify the function for comparing two values of the range.
Furthermore, there are variants that use normal std::sort
instead, see sort_indices().
Definition at line 239 of file algorithm.hpp.
std::vector< MeanStddevPair > standardize_cols | ( | Matrix< double > & | data, |
bool | scale_means = true , |
||
bool | scale_std = true |
||
) |
Standardize the columns of a Matrix by subtracting the mean and scaling to unit variance.
The function performs a column-wise z-transformation on the given data.
The function returns a vector containing the mean and standard deviation of the columns before standardization, see MeanStddevPair. If both scale_means
and scale_std
are set to false
, the original data is not manipulated, while the returned vector still contains the means and standard deviations. See also matrix_col_mean_stddev().
data | Input data Matrix; standardizing is done inline. |
scale_means | If true (default), center the data by subtracting the mean per column. |
scale_std | If true (default), scale the data to unit variance (or equivalently, unit standard deviation) per column. |
Definition at line 94 of file math/matrix.cpp.
std::vector< MeanStddevPair > standardize_rows | ( | Matrix< double > & | data, |
bool | scale_means = true , |
||
bool | scale_std = true |
||
) |
Standardize the rows of a Matrix by subtracting the mean and scaling to unit variance.
The function performs a row-wise z-transformation on the given data.
The function returns a vector containing the mean and standard deviation of the rows before standardization, see MeanStddevPair. If both scale_means
and scale_std
are set to false
, the original data is not manipulated, while the returned vector still contains the means and standard deviations. See also matrix_row_mean_stddev().
data | Input data Matrix; standardizing is done inline. |
scale_means | If true (default), center the data by subtracting the mean per column. |
scale_std | If true (default), scale the data to unit variance (or equivalently, unit standard deviation) per column. |
Definition at line 124 of file math/matrix.cpp.
bool starts_with | ( | std::string const & | text, |
std::string const & | prefix | ||
) |
Return whether a string starts with another string, i.e., check for a prefix
.
Definition at line 136 of file string.cpp.
bool starts_with | ( | std::string const & | text, |
std::string const & | prefix, | ||
std::string & | suffix | ||
) |
Return whether a string starts with another string, i.e., check for a prefix
.
This version of the function then stores the suffix
of the matched text
, containing all remaining characters that did not match the prefix
pattern. If there is no match, the suffix
is left unchanged.
Definition at line 144 of file string.cpp.
bool starts_with_ci | ( | std::string const & | text, |
std::string const & | prefix | ||
) |
Return whether a string starts with another string, i.e., check for a prefix
, case insensitive.
Definition at line 154 of file string.cpp.
bool starts_with_ci | ( | std::string const & | text, |
std::string const & | prefix, | ||
std::string & | suffix | ||
) |
Return whether a string starts with another string, i.e., check for a prefix
, case insensitive.
This version of the function then stores the suffix
of the matched text
, containing all remaining characters that did not match the prefix
pattern. If there is no match, the suffix
is left unchanged.
Definition at line 160 of file string.cpp.
bool starts_with_ci_alnum | ( | std::string const & | text, |
std::string const & | prefix | ||
) |
Return whether a string starts with another string (prefix), comparing case-independent, and ignoring all non-alphanumerical characters.
For example, "REF_CNT.S2-1.sorted:1"
starts with "[ref-cnt]"
, according to this function.
Definition at line 170 of file string.cpp.
bool starts_with_ci_alnum | ( | std::string const & | text, |
std::string const & | prefix, | ||
std::string & | suffix, | ||
bool | trim_suffix = false |
||
) |
Return whether a string starts with another string (prefix), comparing case-independent, and ignoring all non-alphanumerical characters.
For example, "REF_CNT.S2-1.sorted:1"
starts with "[ref-cnt]"
, according to this function.
This version of the function then stores the suffix
of the matched text
, containing all remaining characters that did not match the prefix
pattern. If there is no match, the suffix
is left unchanged.
If additionally trim_suffix
is set, all leading non-alphanumerical characters of the suffix
are removed. For example, "REF_CNT.S2-1.sorted:1"
starts with "[ref-cnt]"
, and then contains the suffix ".S2-1.sorted:1"
- with trim_suffix
, this is reduced to "S2-1.sorted:1"
instead.
Definition at line 177 of file string.cpp.
int strcasecmp | ( | char const * | s1, |
char const * | s2 | ||
) |
Compares two strings, ignoring case differences.
Compares the null-terminated strings s1
and s2
, returning -1, 0, or 1 if s1
is lexicographically less than, equal to, or greater than s2
over those characters, respectively.
This is equivalent to the POSIX function of the same name, found in strings.h
, but included here for portability.
Definition at line 84 of file string.cpp.
|
static |
Overload of error-reporting function, to enable use with VS.
Ref: http://stackoverflow.com/a/901316/717706
Definition at line 87 of file strict_fstream.cpp.
int strncasecmp | ( | char const * | s1, |
char const * | s2, | ||
size_t | n | ||
) |
Compares up to n
chars of two strings, ignoring case differences.
Compares up to n
chars of the null-terminated strings s1
and s2
, returning -1, 0, or 1 if s1
is lexicographically less than, equal to, or greater than s2
over those characters, respectively.
This is equivalent to the POSIX function of the same name, found in strings.h
, but included here for portability.
Definition at line 90 of file string.cpp.
double sum | ( | const Histogram & | h | ) |
Definition at line 140 of file utils/math/histogram/stats.cpp.
std::string summarize_column | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 266 of file utils/containers/dataframe/operators.cpp.
std::string summarize_column | ( | Dataframe const & | df, |
std::string const & | col_name | ||
) |
Definition at line 298 of file utils/containers/dataframe/operators.cpp.
std::string genesis::utils::summarize_column_common_ | ( | Dataframe const & | df, |
size_t | col_index, | ||
std::string const & | description | ||
) |
Definition at line 216 of file utils/containers/dataframe/operators.cpp.
std::string genesis::utils::summarize_column_double_ | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 222 of file utils/containers/dataframe/operators.cpp.
std::string genesis::utils::summarize_column_int_ | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 243 of file utils/containers/dataframe/operators.cpp.
std::string genesis::utils::summarize_column_string_ | ( | Dataframe const & | df, |
size_t | col_index | ||
) |
Definition at line 254 of file utils/containers/dataframe/operators.cpp.
std::string summarize_columns | ( | Dataframe const & | df | ) |
Definition at line 304 of file utils/containers/dataframe/operators.cpp.
Calculate the Sums of Squares and Cross Products Matrix (SSCP Matrix).
Definition at line 225 of file math/matrix.cpp.
std::string svg_arc | ( | double | center_x, |
double | center_y, | ||
double | radius, | ||
double | start_angle, | ||
double | end_angle, | ||
bool | wedge = false |
||
) |
Create an arc to use in an SvgPath.
Example:
SvgPath( { svg_arc( 0, 0, 10, start_a, end_a ) }, stroke );
The angles are measured in radians, and always drawn clockwise from start to end. If wedge
is given, the path is drawn including segments to the circle center; otherwise, the path position is moved to the beginning of the arc first, and left at its end.
Definition at line 50 of file utils/formats/svg/helper.cpp.
std::string genesis::utils::svg_attribute | ( | std::string const & | name, |
T const & | value, | ||
std::string const & | unit = "" |
||
) |
Definition at line 229 of file utils/formats/svg/helper.hpp.
Compute the bounding box of a set of points.
Definition at line 87 of file utils/formats/svg/helper.cpp.
SvgBox svg_bounding_box | ( | std::vector< SvgPoint > const & | points, |
SvgTransform const & | transform | ||
) |
Compute the bounding box of a set of points, including their transformation.
Definition at line 112 of file utils/formats/svg/helper.cpp.
|
inline |
Definition at line 223 of file utils/formats/svg/helper.hpp.
|
inline |
Definition at line 239 of file utils/formats/svg/helper.hpp.
|
inline |
Definition at line 629 of file blocking_concurrent_queue.hpp.
|
inlinenoexcept |
Definition at line 3914 of file concurrent_queue.hpp.
|
inlinenoexcept |
Definition at line 3924 of file concurrent_queue.hpp.
Definition at line 47 of file histogram.cpp.
|
inline |
Definition at line 154 of file accumulator.hpp.
|
inline |
Definition at line 566 of file optional.hpp.
|
inlinenoexcept |
Definition at line 3919 of file concurrent_queue.hpp.
|
inlinenoexcept |
Definition at line 3930 of file concurrent_queue.hpp.
void genesis::utils::swap_cols | ( | Matrix< T > & | data, |
size_t | col_a, | ||
size_t | col_b | ||
) |
Swap (interchange) two columns of a Matrix, given their indices.
Definition at line 316 of file utils/containers/matrix/operators.hpp.
void genesis::utils::swap_rows | ( | Matrix< T > & | data, |
size_t | row_a, | ||
size_t | row_b | ||
) |
Swap (interchange) two rows of a Matrix, given their indices.
Definition at line 300 of file utils/containers/matrix/operators.hpp.
|
static |
Definition at line 89 of file utils/math/bitvector/operators.cpp.
std::string tail | ( | std::string const & | text, |
size_t | lines | ||
) |
Return the last lines of the text.
Definition at line 505 of file string.cpp.
std::vector<std::tm> genesis::utils::time_to_tm | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
bool | use_local_time = false , |
||
size_t | size = 0 |
||
) |
Convert a list of std::time_t
objects to a std::vector
of std::tm
objects.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
If the size
of the list is known, this can be given to reserve that much memory first.
Definition at line 123 of file date_time.hpp.
std::tm time_to_tm | ( | std::time_t const & | time, |
bool | use_local_time = false |
||
) |
Convert std::time_t
object to a std::tm
object.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
Definition at line 147 of file date_time.cpp.
std::vector< std::tm > time_to_tm | ( | std::vector< std::time_t > const & | times, |
bool | use_local_time = false |
||
) |
Convert a std::vector
of std::time_t
objects to a std::vector
of std::tm
objects.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
Definition at line 170 of file date_time.cpp.
std::string tm_date_to_string | ( | std::tm const & | time | ) |
Print the given std::tm
object as a std::string
containing only the date, using the ISO 8601 extended format.
The format is %Y-%m-%d
, for example 2020-04-17.
Definition at line 213 of file date_time.cpp.
std::string tm_time_to_string | ( | std::tm const & | time | ) |
Print the given std::tm
object as a std::string
containing only the time, using the ISO 8601 extended format.
The format is %H:%M:%S
, for example 00:27:58.
Definition at line 218 of file date_time.cpp.
std::string tm_to_string | ( | std::tm const & | time | ) |
Print the given std::tm
object as a std::string
, using the ISO 8601 extended format.
The format is %Y-%m-%dT%H:%M:%S
, for example 2020-04-17T00:27:58.
Definition at line 208 of file date_time.cpp.
std::string tm_to_string | ( | std::tm const & | time, |
std::string const & | format | ||
) |
Print the given std::tm
object as a std::string
, using the format
.
If the format
uses locale-depended qualifiers, the "C" locale is used.
Definition at line 203 of file date_time.cpp.
std::string tm_to_string | ( | std::tm const & | time, |
std::string const & | format, | ||
std::string const & | locale | ||
) |
Print the given std::tm
object as a std::string
, using the format
and locale
.
For a list of the available format
parameters, see https://en.cppreference.com/w/cpp/io/manip/get_time or http://www.cplusplus.com/reference/ctime/strftime/
The available locale
strings depend on the operating system and user settings. Typically, on Unix/Linux/POSIX/MacOS machines, the command locale -a
should give a valid list.
Definition at line 179 of file date_time.cpp.
std::vector<std::time_t> genesis::utils::tm_to_time | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
bool | use_local_time = false , |
||
size_t | size = 0 |
||
) |
Convert a list of std::tm
objects to a std::vector
of std::time_t
objects.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
If the size
of the list is known, this can be given to reserve that much memory first.
Definition at line 80 of file date_time.hpp.
std::time_t tm_to_time | ( | std::tm | time, |
bool | use_local_time = false |
||
) |
Convert std::tm
object to a std::time_t
object.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
Definition at line 108 of file date_time.cpp.
std::vector< std::time_t > tm_to_time | ( | std::vector< std::tm > const & | times, |
bool | use_local_time = false |
||
) |
Convert a std::vector
of std::tm
objects to a std::vector
of std::time_t
objects.
By default, we use Coordinated Universal Time (UTC), so that results are reproducible. If local time is needed instead, set use_local_time
to true
.
Definition at line 142 of file date_time.cpp.
|
inline |
Return the bit representation of an unsigned int.
For example, to_bit_string(5) yields "0...0101". Optionally, the chars to use for zero
and one
can be set, as well as a flag whether to put spaces in between individual bytes of the output.
Definition at line 659 of file string.hpp.
|
inline |
Obtain an output target for writing to a file.
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
If compression_level
is set to a compression level other than GzipCompressionLevel::kNoCompression, the output is compressed using gzip. We recommend to use GzipCompressionLevel::kDefaultCompression%.
Furthermore, if auto_adjust_filename
is set to true
(default), the file name is adjusted according to the compression setting: If compression is used, the file name is appended by the .gz
extension, if this is not alreay present. (For completeness, the oppositve also works: If the file name ends in .gz
, but no compression is chosen, the .gz
extension is removed.)
If the file cannot be written to, the function throws an exception. Also, by default, if the file already exists, an exception is thrown. See Options::allow_file_overwriting() to change this behaviour.
See also to_gzip_block_file() for a version that offers multithreaded gzip compression using blocks of compressed data.
Definition at line 81 of file output_target.hpp.
|
inline |
Obtain an output target for writing to a file, using a specific output mode.
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
This version of the function allows to explicitly set the openmode
, which is for example useful to append to an existing file, or to open it in binary mode.
Definition at line 117 of file output_target.hpp.
|
inline |
Obtain an output target for writing gzip block compressed data to a file.
This output target uses multithreaded gzip compression by block-compressing chunks of data. See GzipBlockOStream for an explanation and more details on this technique and the parameters offered here.
For general details on using this output target for writing data, see to_file().
Definition at line 151 of file output_target.hpp.
|
inline |
Obtain an output target for writing to a gzip-compressed file.
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
Definition at line 132 of file output_target.hpp.
|
constexprnoexcept |
|
inline |
Return an all-lowercase copy of the given string, locale-aware.
Definition at line 478 of file string.hpp.
std::string to_lower_ascii | ( | std::string const & | str | ) |
Return an all-lowercase copy of the given string, ASCII-only.
Definition at line 895 of file string.cpp.
void to_lower_ascii_inplace | ( | std::string & | str | ) |
Turn the given string to all-lowercase, ASCII-only.
Definition at line 878 of file string.cpp.
|
inline |
Turn the given string to all-lowercase, locale-aware.
Definition at line 492 of file string.hpp.
std::string to_nucleic_acids | ( | TwobitVector const & | vec | ) |
Turn a TwobitVector into its string representation of nucleic acids.
Definition at line 107 of file utils/math/twobit_vector/functions.cpp.
|
inline |
Obtain an output target for writing to standard error (i.e., stderr or cerr).
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
Definition at line 232 of file output_target.hpp.
|
inline |
Obtain an output target for writing to standard output (i.e., stdout or cout).
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
Definition at line 222 of file output_target.hpp.
|
inline |
Obtain an output target for writing to a stream.
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
If compression_level
is set to a compression level other than GzipCompressionLevel::kNoCompression (which is the default, which means, no compression by default), the output is compressed using gzip. In that case, it is recommended that the target_stream
uses std::ios_base::binary
when opening the stream.
Definition at line 203 of file output_target.hpp.
|
inline |
Obtain an output target for writing to a string.
The output target returned from this function can be used in the writer classes, e.g., placement::JplaceWriter or sequence::FastaWriter.
Definition at line 186 of file output_target.hpp.
std::string to_string_byte_format | ( | size_t | value | ) |
Produce a human readable formatting of a size in bytes, using the appropriate suffix.
For instance, this function produces 123MB
.
Definition at line 1047 of file string.cpp.
std::string to_string_leading_zeros | ( | size_t | value, |
size_t | length = 6 |
||
) |
Return a string representation of a size_t
value
with a fixed length, that is, by adding leading zeros.
If value
is already longer than length
, the result will also be longer.
Definition at line 1014 of file string.cpp.
std::string genesis::utils::to_string_nice | ( | T const & | v | ) |
Return a string representation of a given value.
This function template is a drop-in replacement for std::to_string, with the difference that it treats floating point numbers more nicely: Instead of printing a fixed amount of digits, it only prints digits without trailing zeros.
If you also want to round the value, or need more precision, see to_string_precise() and to_string_rounded().
As it uses operator << on the given value, it is suitable for any class or value for which this stream operator is available. Thus, this function can also be used for conveniently returning a string where otherwise some stream operations would have been necessary.
Definition at line 637 of file string.hpp.
std::string to_string_precise | ( | double | value, |
int | precision = 6 |
||
) |
Return a precise string representation of the input value, using the provided precision value (determining its decimal places).
This function rounds the value to the given precision, and then returns its string representation with possible trailing zeros. Thus, it uses fixed precision. This is useful for e.g., output in a table format.
For a version of this function that truncates trailing zeros, see to_string_rounded(). Also, see to_string() if you simply want to output a string representation of a double.
Definition at line 1021 of file string.cpp.
std::string to_string_rounded | ( | double | value, |
int | precision = 6 |
||
) |
Return a string representation of the input value, using the provided precision value (determining its decimal places) to round, and truncate trailing zeros.
This function rounds the value to the given precision, and then returns its string representation without trailing zeros. This is useful for output that keeps a certain amount of significant decimal digits, while making the output as short as possible.
If you want to round, but also keep trailing zeros, see to_string_precise(). Also, see to_string() if you simply want to output a string representation of a double.
Definition at line 1029 of file string.cpp.
|
constexprnoexcept |
|
inline |
Return an all-uppercase copy of the given string, locale-aware.
Definition at line 502 of file string.hpp.
std::string to_upper_ascii | ( | std::string const & | str | ) |
Return an all-uppercase copy of the given string, ASCII-only.
Definition at line 919 of file string.cpp.
void to_upper_ascii_inplace | ( | std::string & | str | ) |
Turn the given string to all-uppercase, ASCII-only, inline.
Uses AVX2 if available.
Definition at line 902 of file string.cpp.
|
inline |
Turn the given string to all-uppercase, locale-aware.
Definition at line 514 of file string.hpp.
TwobitVector::ValueType translate_from_nucleic_acid | ( | char | site | ) |
Translate a char into TwobitVector::ValueType.
Valid chars are A
, C
, G
, T
, and their lower case variants.
Definition at line 49 of file utils/math/twobit_vector/functions.cpp.
char translate_to_nucleic_acid | ( | TwobitVector::ValueType | value | ) |
Translate a TwobitVector::ValueType into its char representation.
This gives one of the values A
, C
, G
and T
.
Definition at line 78 of file utils/math/twobit_vector/functions.cpp.
Transpose a Matrix.
Definition at line 127 of file utils/containers/matrix/operators.hpp.
void transpose_inplace | ( | Matrix< T > & | mat | ) |
Transpose a Matrix inplace, without allocating a new Matrix.
Only needs additional storage for 1 bit per element of the matrix, compared to the full reallocation of the transpose() function. It is however somewhat slower (4-5x more time in our debug build).
Definition at line 146 of file utils/containers/matrix/operators.hpp.
size_t triangular_index | ( | size_t | i, |
size_t | j, | ||
size_t | n | ||
) |
Given indices i
and j
in a quadratic Matrix, find the corresponding linear index.
See triangular_indices() for the opposite function, which also explains the details, and triangular_size() to calculate the maximal k
that will occur in a trian Matrix of a given size n
.
i,j | Indices of the Matrix for which to calculate the linear index k . |
n | Size of the quadratic Matrix, i.e., the row/column length. |
k
for the given i
and j
. Definition at line 56 of file utils/containers/matrix/operators.cpp.
std::pair< size_t, size_t > triangular_indices | ( | size_t | k, |
size_t | n | ||
) |
Given a linear index in a upper triangular Matrix, find the corresponding Matrix indices.
Given an upper triangle Matrix of size n == 5
0 k0 k1 k2 k3 0 0 k4 k5 k6 0 0 0 k7 k8 0 0 0 0 k9 0 0 0 0 0
and given a k
(like above), find the corresponding indices i
and j
for this k
, e.g.,
k == 0 --> i == 0, j == 1 k == 5 --> i == 1, j == 3 k == 9 --> i == 3, j == 4 ...
Because the calculation involves solving triangular numbers, the function internally operates on double
values. This is a bit smelly, but seems to work (tested with n == 100,000
).
See also triangular_index() for the opposite function, and triangular_size() to calculate the maximal k
that will occur in a trian Matrix of a given size n
.
k | Linear index in the upper triangle of a quadratic Matrix. |
n | Size of the quadratic Matrix, i.e., the row/column length. |
( i, j )
of the indices for the given k
. Definition at line 44 of file utils/containers/matrix/operators.cpp.
size_t triangular_size | ( | size_t | n | ) |
Calculate the number of linear indices needed for a triangular Matrix of size n
.
Given an upper triangle Matrix of size n == 5
0 k0 k1 k2 k3 0 0 k4 k5 k6 0 0 0 k7 k8 0 0 0 0 k9 0 0 0 0 0
we need 10
indices k == 0..9
to linearly describe the positions in the triangle. This function returns this number of indices for a given n
.
See also triangular_indices() for calculating the Matrix indices i
and j
for a given k
.
n | Size of the quadratic Matrix, i.e., the row/column length. |
k
to describe a triangle of the Matrix. Definition at line 62 of file utils/containers/matrix/operators.cpp.
void tridiagonal_ql_algorithm | ( | Matrix< double > & | data, |
TridiagonalDecompositionData & | tri, | ||
size_t | max_iterations = 1000 |
||
) |
Reduce a symmetric matrix to a symmetric tridiagonal matrix.
Uses the data and the intermediate result after executing reduce_to_tridiagonal_matrix() in order to run the algorithm. See there for details.
Both parameters are modified during the algorithm. After it is finished, tri.eigenvalues
contains the eigenvalus and data
the associated eigenvectors of the original data.
The implementation of this function is largely borrowed from http://www.classification-society.org/csna/mda-sw/pca.c published as Public Domain by Fionn Murtagh.
data | Input data matrix. Operations are performed inline, that is, the matrix is changed during execution of the function. |
tri | Tridiagonal matrix coming from reduce_to_tridiagonal_matrix(). |
max_iterations | Maximum number of iterations to perform, default is 1000. If set to 0, the algorithm continues until convergence. As convergence is not given for all data, this might result in an infinite loop. |
std::string trim | ( | std::string const & | s, |
std::string const & | delimiters | ||
) |
Return a copy of the input string, with trimmed white spaces (or any other delimiters
).
Definition at line 827 of file string.cpp.
std::string trim_left | ( | std::string const & | s, |
std::string const & | delimiters | ||
) |
Return a copy of the input string, with right trimmed white spaces (or any other delimiters
).
Definition at line 815 of file string.cpp.
std::string trim_right | ( | std::string const & | s, |
std::string const & | delimiters | ||
) |
Return a copy of the input string, with left trimmed white spaces (or any other delimiters
).
Definition at line 803 of file string.cpp.
std::vector<double> genesis::utils::udu_transpose_ | ( | size_t | M, |
std::vector< double > const & | U, | ||
double | scale | ||
) |
std::vector<double> genesis::utils::udvdu_transpose_ | ( | size_t | M, |
std::vector< double > const & | U, | ||
std::vector< double > const & | V, | ||
double | scale | ||
) |
bool validate | ( | Dataframe const & | df | ) |
Located in genesis/utils/containers/dataframe/operators.hpp
Definition at line 404 of file utils/containers/dataframe/operators.cpp.
double genesis::utils::weighted_arithmetic_mean | ( | ForwardIterator | first_value, |
ForwardIterator | last_value, | ||
ForwardIterator | first_weight, | ||
ForwardIterator | last_weight | ||
) |
Calculate the weighted arithmetic mean of a range of double
values.
The iterators first_value
and last_value
, as well as first_weight
and last_weight
, need to point to ranges of double
values, with last_value
and last_weight
being the past-the-end elements. Both ranges need to have the same size. The function then calculates the weighted arithmetic mean of all finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored. The weights have to be non-negative.
std::vector
. Definition at line 496 of file statistics.hpp.
|
inline |
Calculate the weighted arithmetic mean of a std::vector
of double
elements.
Definition at line 547 of file statistics.hpp.
double genesis::utils::weighted_geometric_mean | ( | ForwardIterator | first_value, |
ForwardIterator | last_value, | ||
ForwardIterator | first_weight, | ||
ForwardIterator | last_weight | ||
) |
Calculate the weighted geometric mean of a range of positive numbers.
The iterators first_value
and last_value
, as well as first_weight
and last_weight
, need to point to ranges of double
values, with last_value
and last_weight
being the past-the-end elements. Both ranges need to have the same size. The function then calculates the weighted geometric mean of all positive finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored. If finite non-positive numbers (zero or negative) are found, an exception is thrown. The weights have to be non-negative.
For a set of values \( v \) and a set of weights \( w \), the weighted geometric mean \( g \) is calculated following [1]:
\( g = \exp \left( \frac{ \sum w \cdot \log v }{ \sum w } \right) \)
That is, if all weights are 1.0
, the formula yields the standard geometric mean.
[1] J. D. Silverman, A. D. Washburne, S. Mukherjee, and L. A. David, "A phylogenetic transform enhances analysis of compositional microbiota data," Elife, vol. 6, p. e21887, Feb. 2017. https://elifesciences.org/articles/21887
std::vector
. Definition at line 649 of file statistics.hpp.
|
inline |
Calculate the weighted geometric mean of a std::vector
of double
elements.
Definition at line 706 of file statistics.hpp.
double genesis::utils::weighted_harmonic_mean | ( | ForwardIterator | first_value, |
ForwardIterator | last_value, | ||
ForwardIterator | first_weight, | ||
ForwardIterator | last_weight, | ||
HarmonicMeanZeroPolicy | zero_policy = HarmonicMeanZeroPolicy::kThrow |
||
) |
Calculate the weighted harmonic mean of a range of positive numbers.
The iterators first_value
and last_value
, as well as first_weight
and last_weight
, need to point to ranges of double
values, with last_value
and last_weight
being the past-the-end elements. Both ranges need to have the same size. The function then calculates the weighted harmonic mean of all non-negative or positive (depending on the zero_policy
) finite elements in the range. If no elements are finite, or if the range is empty, the returned value is 0.0
. Non-finite numbers are ignored. If finite negative numbers are found, an exception is thrown. Zero values are treated according to the zero_policy
. The weights have to be non-negative, and elements with non-finite weights are skipped.
For a set of values \( v \) and a set of weights \( w \), the weighted harmonic mean \( g \) is calculated following [1]:
\( h = \frac{ \sum w }{ \sum \frac{ w }{ v } } \)
That is, if all weights are 1.0
, the formula yields the standard harmonic mean.
std::vector
. Definition at line 884 of file statistics.hpp.
|
inline |
Calculate the weighted harmonic mean of a std::vector
of double
elements.
Definition at line 988 of file statistics.hpp.
double weighted_inner_product | ( | std::vector< double > const & | x_input, |
std::vector< double > const & | y_input, | ||
std::vector< double > const & | weights = std::vector< double >{} |
||
) |
(Weighted) inner product of two vectors.
The weights
can be empty, in which case the simple inner product of x_input
and y_input
is returned.
Definition at line 322 of file utils/math/regression/helper.cpp.
GlmFreedom weighted_mean_centering | ( | std::vector< double > const & | y_input, |
std::vector< double > const & | weights, | ||
std::vector< size_t > const & | strata, | ||
bool | with_intercept, | ||
bool | centering, | ||
std::vector< double > & | y_output | ||
) |
(Weighted) mean and centering.
If centering
is false
, write y_output
to contain the (strata) (weighted) means. If centering
is true
, center the input y_input
around these means, i.e., calculaute either the "fitted value" or the residual from a model in which only strata are fitted.
The weights
and strata
can be empty. y_input
and y_output
can be the same vector.
Definition at line 71 of file utils/math/regression/helper.cpp.
double weighted_residuals | ( | std::vector< double > const & | x_input, |
std::vector< double > const & | y_input, | ||
std::vector< double > const & | weights, | ||
std::vector< double > & | y_output | ||
) |
Calculate the residuals from (weighted) regression through the origin.
The weights
can be empty. The results are written to y_output
. y_input
and y_output
can be the same vector. Returns the regression coefficient.
Definition at line 221 of file utils/math/regression/helper.cpp.
double weighted_sum | ( | std::vector< double > const & | x_input, |
std::vector< double > const & | weights = std::vector< double >{} |
||
) |
(Weighted) sum of a vector of values.
The weights
can be empty, in which case the simple sum of x_input
is returned.
Definition at line 364 of file utils/math/regression/helper.cpp.
double weighted_sum_of_squares | ( | std::vector< double > const & | x_input, |
std::vector< double > const & | weights = std::vector< double >{} |
||
) |
(Weighted) sum of squares.
The weights
can be empty, in which case the simple sum of squares of x_input
is returned.
Definition at line 290 of file utils/math/regression/helper.cpp.
std::string wrap | ( | std::string const & | text, |
size_t | line_length | ||
) |
Wrap a text
at a given line_length
.
Definition at line 680 of file string.cpp.
std::string genesis::utils::xml_attribute | ( | std::string const & | name, |
T const & | value | ||
) |
Definition at line 52 of file utils/formats/xml/helper.hpp.
std::string xml_comment | ( | std::string const & | content | ) |
Definition at line 70 of file utils/formats/xml/helper.cpp.
std::string xml_deescape | ( | std::string const & | txt | ) |
De-escape special XML characters.
Definition at line 59 of file utils/formats/xml/helper.cpp.
std::string xml_escape | ( | std::string const & | txt | ) |
Escape special XML characters.
Definition at line 45 of file utils/formats/xml/helper.cpp.
const XmlComment * xml_value_to_comment | ( | const XmlValue * | v | ) |
Converts a pointer to an XmlValue to XmlComment if appropriate.
Throws if the dynamic type of the object is not actually an XmlComment object.
Definition at line 47 of file xml/document.cpp.
const XmlElement * xml_value_to_element | ( | const XmlValue * | v | ) |
Converts a pointer to an XmlValue to XmlElement if appropriate.
Throws if the dynamic type of the object is not actually an XmlElement object.
Definition at line 77 of file xml/document.cpp.
Converts a pointer to an XmlValue to XmlMarkup if appropriate.
Throws if the dynamic type of the object is not actually an XmlMarkup object.
Definition at line 62 of file xml/document.cpp.
using DefaultIntervalNumericalType = int |
Default numerical type to use in an Interval.
Definition at line 61 of file interval.hpp.
using InputReader = AsynchronousReader |
Alias for the either AsynchronousReader or SynchronousReader.
This typedef is an alias for AsynchronousReader. We use it in order to be able to easily switch to using SynchronousReader, by aliasing that instead. However, as of now, we always use the AsynchronousReader throughout all reading functionality, for efficiency reasons.
Definition at line 61 of file input_reader.hpp.
using KahanSum = CompensatedSum<KahanSummation> |
Typedef shorthand for a Kahan sum.
Definition at line 69 of file compensated_sum.hpp.
using KleinSum = CompensatedSum<KleinSummation> |
Typedef shorthand for a Kahan Babushka Klein sum.
Definition at line 79 of file compensated_sum.hpp.
using NamedColorList = std::vector<std::pair<std::string, ColorBytes> > |
using NeumaierSum = CompensatedSum<NeumaierSummation> |
Typedef shorthand for a Kahan Babushka Neumaier sum.
Definition at line 74 of file compensated_sum.hpp.
|
strong |
Enumerator | |
---|---|
kBrbg | |
kPiyg | |
kPrgn | |
kPuor | |
kRdbu | |
kRdgy | |
kRdylbu | |
kRdylgn | |
kSpectral |
Definition at line 136 of file list_diverging.hpp.
|
strong |
Enumerator | |
---|---|
kNextstrain |
Definition at line 91 of file list_misc.hpp.
|
strong |
Enumerator | |
---|---|
kAccent | |
kDark2 | |
kPaired | |
kPastel1 | |
kPastel2 | |
kSet1 | |
kSet2 | |
kSet3 |
Definition at line 127 of file list_qualitative.hpp.
|
strong |
Enumerator | |
---|---|
kBupubk | |
kBlues | |
kBugn | |
kBupu | |
kGnbu | |
kGreens | |
kGreys | |
kOranges | |
kOrrd | |
kPubu | |
kPubugn | |
kPurd | |
kPurples | |
kRdpu | |
kReds | |
kYlgn | |
kYlgnbu | |
kYlorbr | |
kYlorrd | |
kHeat | |
kMagma | |
kInferno | |
kPlasma | |
kViridis |
Definition at line 262 of file list_sequential.hpp.
|
strong |
Local helper enum that indicates which component of a coordinate we are dealing with.
Enumerator | |
---|---|
kLatitude | |
kLongitude |
Definition at line 57 of file utils/tools/geodesy/functions.cpp.
|
strong |
List of possible compression levels used for GzipOStream.
The compression levels are handed over to zlib for compression, which currently allows all values between 1 (best speed) and 9 (best compression), with the special case 0 (no compression), as well as -1 for the default compression. Currently, the zlib default compression level corresponds to level 6, as this is a good compromise between speed and compression (it forms the "elbow" of the curve), hence we also use this as our default level.
The enum only lists those four special levels. However, we use a fixed enum here (with the underlying type int
), meaning that all values in between 1 and 9 are also allowed to be used. Values outside of the range [-1, 9] will lead to an exception being thrown when used in GzipOStream.
Enumerator | |
---|---|
kDefaultCompression | |
kNoCompression | |
kBestSpeed | |
kBestCompression |
Definition at line 100 of file gzip_stream.hpp.
|
strong |
Select a policy on how to treat zeroes in the computation of harmonic_mean() and weighted_harmonic_mean().
Enumerator | |
---|---|
kThrow | Throw an exception when a zero value is encountered in the data. |
kIgnore | Ignore any zero values. |
kReturnZero | If any zero value is encountered in the data, simply return zero as the harmonic mean. This is for example the interpretation of using the harmonic mean to compute the average resistance of a set of resistors in parallel, where one zero-resistance resistor would lead to the whole set having zero resistance. |
kCorrection | Apply a zero-value correction. The correction is computed as \( \mu_h = \frac{N_T - N_0}{\sum^{N_T - N_0}_{i=1} \frac{1}{x_i}} \times \frac{N_T - N_0} {N_T} \) where \( \mu_h \) is harmonic mean, \( x_i \) are the non-zero values of the data only, \( N_T \) is the (total) sample size, and \( N_0 \) is the number of zero values. This follows the EPA (Environmental Protection Agency) program DFLOW, see https://www.epa.gov/ceam/dflow and https://rdrr.io/cran/lmomco/man/harmonic.mean.html |
Definition at line 721 of file statistics.hpp.
|
strong |
List of the currently implemented hashing functions.
This is useful in order to select the used hashing function at runtime for some algorithms.
Enumerator | |
---|---|
kMD5 | Use MD5 for hashing. |
kSHA1 | Use SHA1 for hashing. |
kSHA256 | Use SHA256 for hashing. |
Definition at line 53 of file utils/tools/hash/functions.hpp.
|
strong |
Method for computing Kendall's Tau.
See kendalls_tau_correlation_coefficient() for the function that uses this. See https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient and https://docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.stats.kendalltau.html#scipy.stats.kendalltau for details on the different methods.
Enumerator | |
---|---|
kTauA | Compute Tau-a, which does not make any adjustment for ties. |
kTauB | Compute Tau-b, which does adjustments for ties. |
kTauC | Compute Tau-c, (also called Stuart-Kendall Tau-c). |
Definition at line 187 of file correlation.hpp.
|
strong |
Enum of the initialization strategies offered by the Kmeans implementation.
Enumerator | |
---|---|
kRandomAssignments | |
kRandomCentroids | |
kKmeansPlusPlus | |
kNone |
Definition at line 64 of file utils/math/kmeans.hpp.
|
strong |
Choice of algorithm to use for Multi-Dimensional Scaling (MDS).
Enumerator | |
---|---|
kUcf | Use the UCF implementation (recommended). This is a re-implementation of Laurens van der Maaten's MDS in his Matlab Toolbox for Dimensionality Reduction. |
kSmacof | Use the SMACOF implementation. This is a re-implementation of Michael Bronstein's SMACOF in his Matlab Toolbox for Surface Comparison and Analysis. |
|
strong |
Setting for principal_component_analysis() to determine which form of standardization of the data to use prior to perfoming the PCA.
Enumerator | |
---|---|
kCorrelation | Standardize the mean and variance of the data before performing the PCA. Best to use when the data has widely varying scales in between the columns, i.e., if the columns present data from different domains. Also, see correlation_matrix(). |
kCovariance | Standardize the mean, but not the variance of the data before performing the PCA. Best to use when the data has similar scales in between the columns, i.e., if the columns present data from the same domain. Also, see covariance_matrix(). |
kSSCP | Do not perform any standardization prior to performing the PCA. Not recommended. Also, see sums_of_squares_and_cross_products_matrix(). |
|
strong |
Definition for Red-Black Tree coloring.
Used in IntervalTree and IntervalTreeNode.
Enumerator | |
---|---|
kInvalid | |
kRed | |
kBlack | |
kKDoubleBlack |
Definition at line 65 of file utils/containers/interval_tree/node.hpp.
|
strong |
Option to determine how to treat surrounding whitespace when scanning an input stream.
This helper enum is used in the input stream scanner functions read_char_or_throw() and affirm_char_or_throw() in order to indicate how they treat whitespace while looking for chars.
For checking whether a partcular option is set, it is possible to use the binary and operator &
:
if( option & SkipWhitespace::kTrailing ) { // ... }
Of course, simply comparing the values also works.
Definition at line 62 of file scanner.hpp.
|
static |
List of all ASCII names.
We use this for extra clear user output, in order to make sure that the symbols can be understood when a parser finds an unexpected char.
List from "ASCII / ISO 8859-1 (Latin-1) Table with HTML Entity Names", see https://cs.stanford.edu/people/miles/iso8859.html
|
static |
List of all ASCII symbols.
Actually, we only need that for the non-printable characters. All printable ones are prepresented by their ASCII code directly. But as there is the "DEL" symbol at the end, using this list is easier than introducing a special case for that.
|
static |
Definition at line 47 of file base64.cpp.
|
static |
Definition at line 49 of file base64.cpp.
const std::vector<Color> color_list_accent_ |
Definition at line 56 of file list_qualitative.cpp.
const std::vector<Color> color_list_blues_ |
Definition at line 69 of file list_sequential.cpp.
const std::vector<Color> color_list_brbg_ |
Definition at line 56 of file list_diverging.cpp.
const std::vector<Color> color_list_bugn_ |
Definition at line 81 of file list_sequential.cpp.
const std::vector<Color> color_list_bupu_ |
Definition at line 93 of file list_sequential.cpp.
const std::vector<Color> color_list_bupubk_ |
Our own color list used for visualizing trees.
Definition at line 50 of file list_sequential.cpp.
const std::vector<Color> color_list_dark2_ |
Definition at line 67 of file list_qualitative.cpp.
const std::vector<Color> color_list_gnbu_ |
Definition at line 105 of file list_sequential.cpp.
const std::vector<Color> color_list_greens_ |
Definition at line 117 of file list_sequential.cpp.
const std::vector<Color> color_list_greys_ |
Definition at line 129 of file list_sequential.cpp.
const std::vector<Color> color_list_heat_ |
Definition at line 294 of file list_sequential.cpp.
const std::vector<Color> color_list_inferno_ |
Definition at line 601 of file list_sequential.cpp.
const NamedColorList color_list_lego_ |
Struct that stores a static const map of named LEGO colors.
The map stores the color names of the LEGO colors from https://rebrickable.com/downloads/ as of 2024-06-17.
const std::vector<Color> color_list_magma_ |
Definition at line 330 of file list_sequential.cpp.
|
static |
Definition at line 197 of file list_misc.cpp.
const std::vector<Color> color_list_oranges_ |
Definition at line 141 of file list_sequential.cpp.
const std::vector<Color> color_list_orrd_ |
Definition at line 153 of file list_sequential.cpp.
const std::vector<Color> color_list_paired_ |
Definition at line 78 of file list_qualitative.cpp.
const std::vector<Color> color_list_pastel1_ |
Definition at line 93 of file list_qualitative.cpp.
const std::vector<Color> color_list_pastel2_ |
Definition at line 105 of file list_qualitative.cpp.
const std::vector<Color> color_list_piyg_ |
Definition at line 70 of file list_diverging.cpp.
const std::vector<Color> color_list_plasma_ |
Definition at line 872 of file list_sequential.cpp.
const std::vector<Color> color_list_prgn_ |
Definition at line 84 of file list_diverging.cpp.
const std::vector<Color> color_list_pubu_ |
Definition at line 165 of file list_sequential.cpp.
const std::vector<Color> color_list_pubugn_ |
Definition at line 177 of file list_sequential.cpp.
const std::vector<Color> color_list_puor_ |
Definition at line 98 of file list_diverging.cpp.
const std::vector<Color> color_list_purd_ |
Definition at line 189 of file list_sequential.cpp.
const std::vector<Color> color_list_purples_ |
Definition at line 201 of file list_sequential.cpp.
const std::vector<Color> color_list_rdbu_ |
Definition at line 112 of file list_diverging.cpp.
const std::vector<Color> color_list_rdgy_ |
Definition at line 126 of file list_diverging.cpp.
const std::vector<Color> color_list_rdpu_ |
Definition at line 213 of file list_sequential.cpp.
const std::vector<Color> color_list_rdylbu_ |
Definition at line 140 of file list_diverging.cpp.
const std::vector<Color> color_list_rdylgn_ |
Definition at line 154 of file list_diverging.cpp.
const std::vector<Color> color_list_reds_ |
Definition at line 225 of file list_sequential.cpp.
const std::vector<Color> color_list_set1_ |
Definition at line 116 of file list_qualitative.cpp.
const std::vector<Color> color_list_set2_ |
Definition at line 128 of file list_qualitative.cpp.
const std::vector<Color> color_list_set3_ |
Definition at line 139 of file list_qualitative.cpp.
const std::vector<Color> color_list_spectral_ |
Definition at line 168 of file list_diverging.cpp.
const std::vector<Color> color_list_viridis_ |
Definition at line 1143 of file list_sequential.cpp.
const NamedColorList color_list_web_ |
const NamedColorList color_list_xkcd_ |
Struct that stores a static const map of named xkcd colors.
They were published under Public Domain, http://creativecommons.org/publicdomain/zero/1.0/. See https://xkcd.com/color/rgb/ and https://blog.xkcd.com/2010/05/03/color-survey-results/ for details.
const std::vector<Color> color_list_ylgn_ |
Definition at line 237 of file list_sequential.cpp.
const std::vector<Color> color_list_ylgnbu_ |
Definition at line 249 of file list_sequential.cpp.
const std::vector<Color> color_list_ylorbr_ |
Definition at line 261 of file list_sequential.cpp.
const std::vector<Color> color_list_ylorrd_ |
Definition at line 273 of file list_sequential.cpp.
|
static |
Definition at line 58 of file list_misc.cpp.
|
constexpr |
Earth is not flat!
Definition at line 49 of file utils/tools/geodesy/functions.hpp.
|
static |
Definition at line 231 of file date_time.cpp.
|
static |
Definition at line 54 of file logging.cpp.
|
static |
Default buffer size for all gzip (de)compression buffers.
Definition at line 116 of file gzip_stream.hpp.
|
static |
Definition at line 228 of file date_time.cpp.
|
static |
Log-factorial log(x!) lookup table for fast computation of binomial coefficients. See binomial_coefficient_approx() for usage, and see log_factorial_lookup_generator_() for the generator function.
Definition at line 78 of file binomial.cpp.
const nullopt_t nullopt((nullopt_t::init())) |
Optional to indicate an empty value.
|
static |
Definition at line 51 of file random.cpp.
|
static |
Definition at line 50 of file random.cpp.
|
static |
Definition at line 49 of file random.cpp.
|
constexpr |
Make the world go round.
Definition at line 55 of file common.hpp.
|
static |
The std::localtime and std::gmtime functions are not thread safe, due to their shared internal state. Make sure that we can use them from multiple threads.
Caveat: Currently, this file is the only place where we use std::localtime and std::gmtime. If this changes later, we might want to move this mutex to be available for other usages as well.
Definition at line 62 of file date_time.cpp.