A toolkit for working with phylogenetic data.
v0.22.1
genesis::utils Namespace Reference

Classes

class  ArrowOperatorProxy
 Proxy class to hold an element accessible via arrow operator. More...
 
class  BaseInputSource
 Abstract base class for reading byte data from input sources. More...
 
class  Bitvector
 
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  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
 
class  EuclideanKmeans
 
class  FileInputSource
 Input source for reading byte data from a file. 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  GzipInputSource
 Input source for reading byte data from a gzip/zlib-compressed source. More...
 
class  Histogram
 Histogram class for accumulating and summarizing data. More...
 
class  HistogramAccumulator
 Histogram helper class that collects data and builds a fitting Histogram. More...
 
class  InputBuffer
 
class  InputStream
 Stream interface for reading data from an InputSource, that keeps track of line and column counters. 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...
 
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...
 
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  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  MruCache
 Most Recently Used Cache. More...
 
class  NexusBlock
 
class  NexusDocument
 
class  NexusTaxa
 
class  NexusTrees
 
class  NexusWriter
 
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...
 
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  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  StringInputSource
 Input source for reading byte data from a string. More...
 
class  Style
 Simple text style class for colorized and bold output to a terminal. More...
 
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
 
struct  Tickmarks
 Helper class to find "nice" tickmark intervals for creating scales and axes. 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...
 
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)
 Take the bitwise and of two Bitvectors of potentially different size. More...
 
Bitvector bitwise_or (Bitvector const &lhs, Bitvector const &rhs)
 Take the bitwise or of two Bitvectors of potentially different size. More...
 
Bitvector bitwise_xor (Bitvector const &lhs, Bitvector const &rhs)
 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)
 
bool char_is_digit (const char c)
 Return whether a char is a digit (0-9). More...
 
bool char_is_number_part (char const c)
 Return whether a char is valid in a number, i.e., a digit, a dot, plus, minus, or 'e'/'E'. More...
 
bool char_is_sign (const char c)
 Return whether a char is a sign (+-). More...
 
bool char_match_ci (const char c1, const char c2)
 Return whether two chars are the same, case insensitive. More...
 
std::string char_to_hex (char c, bool full=false)
 Return the hex representation of a char. More...
 
static std::string chdir_getcwd_ (std::string const &dir)
 
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_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_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_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_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_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< Colorcolor_palette_web ()
 
std::vector< Colorcolor_palette_xkcd ()
 
std::map< double, Colorcolor_stops (ColorMap const &map, ColorNormalization const &norm)
 
std::map< double, Colorcolor_stops (ColorMap const &map, ColorNormalizationLinear const &norm)
 
std::map< double, Colorcolor_stops (ColorMap const &map, ColorNormalizationLogarithmic const &norm)
 
std::map< double, Colorcolor_stops (ColorMap const &map, ColorNormalizationDiverging const &norm)
 
std::map< double, Colorcolor_stops (ColorMap const &map, ColorNormalizationBoundary const &norm)
 
std::map< double, std::string > color_tickmarks (ColorNormalization 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::map< double, std::string > color_tickmarks (ColorNormalizationDiverging const &norm, size_t num_ticks)
 
std::map< double, std::string > color_tickmarks (ColorNormalizationBoundary 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...
 
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...
 
template<class C >
bool contains_duplicates (C const &v)
 Return whether a container contains duplicates. More...
 
GeoCoordinate convert_geo_coordinate (std::string const &latitude, std::string const &longitude)
 Parse strings of geographic coordinates. More...
 
GeoCoordinate convert_geo_coordinate (std::string const &coordinate)
 Parse a string 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...
 
bool convert_to_bool (std::string const &str)
 
template<typename ForwardIterator >
std::vector< bool > convert_to_bool (ForwardIterator first, ForwardIterator last, size_t size=0)
 
void convert_to_bool (Dataframe &df, size_t col_index)
 
void convert_to_bool (Dataframe &df, std::string const &col_name)
 
double convert_to_double (std::string const &str)
 
template<typename ForwardIterator >
std::vector< double > convert_to_double (ForwardIterator first, ForwardIterator last, size_t size=0)
 
void convert_to_double (Dataframe &df, size_t col_index)
 
void convert_to_double (Dataframe &df, std::string const &col_name)
 
static std::vector< Colorconvert_to_palette_ (NamedColorList const &list)
 Local helper function to convert a list of byte colors into a proper Color vector. 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)
 
Matrix< double > correlation_matrix (Matrix< double > const &data)
 Calculate the correlation Matrix of a given data Matrix. 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...
 
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...
 
std::string deescape (std::string const &text)
 Return a string where backslash-escaped characters are transformed into their respective string form. More...
 
char deescape (char c)
 Return the de-escaped char for a backslash-escaped char. More...
 
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 &regex="")
 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 &regex, 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 &regex="")
 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 &regex="")
 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...
 
std::vector< Color > const & diverging_color_list (DivergingColorList palette)
 
std::vector< Color > const & diverging_color_list (std::string const &palette)
 
std::vector< std::string > diverging_color_list_names ()
 
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 &ending)
 Return whether a string ends with another string. 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...
 
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)
 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...
 
bool file_exists (std::string const &filename)
 Return true iff the file exists. 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...
 
void file_output_stream (std::string const &filename, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out)
 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)
 Return the contents of a file as a string. More...
 
std::vector< std::string > file_read_lines (std::string const &filename)
 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)
 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 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< BaseInputSourcefrom_file (std::string const &file_name, bool detect_compression=true)
 Obtain an input source for reading from a file. 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< BaseInputSourcefrom_stream (std::istream &input_stream)
 Obtain an input source for reading from a stream. More...
 
std::shared_ptr< BaseInputSourcefrom_string (std::string const &input_string)
 Obtain an input sources for reading from a string. 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...
 
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...
 
Matrix< double > glm_convert_dataframe (Dataframe const &df, std::vector< std::string > row_order)
 
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, GlmFamily const &family, GlmLink const &link, 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, 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, GlmExtras const &extras={}, GlmControl const &control={})
 Fit a Generalized Linear Model (GLM) using a linear gaussian model. 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, T const &reference_level, std::vector< std::string > const &row_names={})
 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, std::vector< std::string > const &row_names={})
 Turn a GlmFactor into a set of (dummy) indicator variables to be used in regression. 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, std::string &report)
 
Dataframe glm_prepare_dataframe (Dataframe const &df)
 
Color gradient (std::map< double, Color > const &ranges, double value)
 Returns a Color that is created using a color gradient. 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...
 
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...
 
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...
 
bool is_canonical_link (GlmFamily const &family, GlmLink const &link)
 
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_web_color_name() and is_xkcd_color_name(). 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)
 
bool is_convertible_to_bool (std::string const &str)
 
template<typename ForwardIterator >
bool is_convertible_to_bool (ForwardIterator first, ForwardIterator last)
 
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)
 
bool is_convertible_to_double (std::string const &str)
 
template<typename ForwardIterator >
bool is_convertible_to_double (ForwardIterator first, ForwardIterator last)
 
bool is_defined (GlmLink const &link)
 Check whether all necessary values and functors of a GlmLink are set. More...
 
bool is_defined (GlmFamily const &family)
 Check whether all necessary values and functors of a GlmFamily are set. 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 file. More...
 
bool is_gzip_compressed_file (std::string const &file_name)
 
static bool is_numerical_type_ (Dataframe const &df, size_t col_index)
 
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...
 
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...
 
bool is_web_color_name (std::string const &name)
 Return true iff the given name is a named web color. More...
 
bool is_xkcd_color_name (std::string const &name)
 Return true iff the given name is a named xkcd color. More...
 
utils::Range< IteratorDeletionsiterate_deletions (TwobitVector const &vector)
 
utils::Range< IteratorInsertionsiterate_insertions (TwobitVector const &vector)
 
utils::Range< IteratorSubstitutionsiterate_substitutions (TwobitVector const &vector)
 
template<typename T >
std::string join (T const &v, std::string const &delimiter=", ")
 Return a string where the elements of a container v are joined using the string delimiter in between them. 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::pair< SvgGradientLinear, SvgGroupmake_svg_color_bar (SvgColorBarSettings const &settings, ColorMap const &map, ColorNormalization const &norm, std::string const &id)
 
static std::pair< SvgGradientLinear, SvgGroupmake_svg_color_bar_discrete_ (SvgColorBarSettings const &settings, std::map< double, Color > const &stops)
 
static std::pair< SvgGradientLinear, SvgGroupmake_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_matrix (Matrix< Color > const &mat, SvgMatrixSettings settings, std::vector< std::string > const &row_labels, std::vector< std::string > const &col_labels)
 
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...
 
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 (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 = 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 >
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 >
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 ForwardIterator >
double maximum (ForwardIterator first, ForwardIterator last)
 Return the maximum of a range of double values. More...
 
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 ForwardIterator >
double minimum (ForwardIterator first, ForwardIterator last)
 Return the minimum of a range of double values. More...
 
template<class ForwardIterator >
MinMaxPair< double > minimum_maximum (ForwardIterator first, ForwardIterator last)
 Return the minimum and the maximum of a range of double values. More...
 
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...
 
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...
 
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...
 
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)
 
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!= (NexusTaxa const &lhs, NexusTaxa const &rhs)
 
bool operator!= (JsonDocument const &lhs, JsonDocument const &rhs)
 
bool operator!= (JsonDocument const &v, std::nullptr_t)
 
bool operator!= (std::nullptr_t, JsonDocument const &v)
 
bool operator!= (Color const &lhs, Color const &rhs)
 
Bitvector operator& (Bitvector const &lhs, Bitvector const &rhs)
 
Bitvector operator& (Bitvector const &lhs, Bitvector const &rhs)
 
bool operator& (SkipWhitespace lhs, SkipWhitespace rhs)
 And-operator to check whether a SkipWhitespace is set. More...
 
bool operator< (JsonDocument const &lhs, JsonDocument const &rhs)
 
bool operator< (JsonDocument::const_reference lhs, JsonDocument::const_reference rhs)
 
bool operator< (const JsonDocument::ValueType lhs, const JsonDocument::ValueType rhs)
 
std::ostream & operator<< (std::ostream &os, const Histogram &h)
 
std::ostream & operator<< (std::ostream &os, const HistogramAccumulator &h)
 
std::ostream & operator<< (std::ostream &os, NexusBlock const &block)
 
template<>
std::ostream & operator<< (std::ostream &os, const Matrix< signed char > &matrix)
 Template specialization for signed char, in order to print nicely. 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, 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 &out, Bitvector const &bv)
 Insertion operator that outputs a Bitvector as a string of '0's and '1's. 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...
 
std::ostream & operator<< (std::ostream &out, Table const &table)
 
std::ostream & operator<< (std::ostream &os, GeoCoordinate const &coord)
 
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, TableLayout::Binder const &binder)
 
bool operator<= (JsonDocument const &lhs, JsonDocument const &rhs)
 
bool operator== (NexusTaxa const &lhs, NexusTaxa const &rhs)
 
bool operator== (JsonDocument const &lhs, JsonDocument const &rhs)
 
bool operator== (JsonDocument const &v, std::nullptr_t)
 
bool operator== (std::nullptr_t, JsonDocument const &v)
 
bool operator== (Color const &lhs, Color const &rhs)
 
bool operator== (JsonDocument::const_reference lhs, JsonDocument::const_reference rhs)
 
bool operator> (JsonDocument const &lhs, JsonDocument const &rhs)
 
bool operator>= (JsonDocument const &lhs, JsonDocument const &rhs)
 
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<class T >
parse_float (utils::InputStream &source)
 Read a floating point number from a stream and return it. More...
 
template<class 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 >
parse_signed_integer (utils::InputStream &source)
 Read a signed integer from a stream and return it. More...
 
template<class T >
parse_unsigned_integer (utils::InputStream &source)
 Read an unsigned integer from a stream and return it. More...
 
bool path_exists (std::string const &path)
 Return whether a path exists, i.e., is a file or directory. More...
 
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...
 
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 >
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 >
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_byte_matrix_ (std::ostream &os, const Matrix< T > &matrix, size_t width)
 Local helper function to avoid code duplication. More...
 
std::vector< Color > const & qualitative_color_list (QualitativeColorList palette)
 
std::vector< Color > const & qualitative_color_list (std::string const &palette)
 
std::vector< std::string > qualitative_color_list_names ()
 
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...
 
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 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...
 
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...
 
std::vector< Color > const & sequential_color_list (SequentialColorList palette)
 
std::vector< Color > const & sequential_color_list (std::string const &palette)
 
std::vector< std::string > sequential_color_list_names ()
 
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, 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...
 
template<typename T >
constexpr int signum (T x)
 Get the sign of a value, which is either -1, 0, or 1. 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 , 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 >
std::vector< size_t > sort_indices (RandomAccessIterator first, RandomAccessIterator last)
 Get the indices to the sorted order of the given range. 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, std::string const &delimiters=" ", const bool trim_empty=true)
 Spilt a string into parts, given a delimiters set of chars. 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...
 
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...
 
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...
 
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...
 
std::vector< MeanStddevPairstandardize_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< MeanStddevPairstandardize_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 &start)
 Return whether a string starts with another string. More...
 
double sum (const Histogram &h)
 
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)
 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="")
 
std::string svg_comment (std::string const &content)
 
void swap (Histogram &lhs, Histogram &rhs)
 
void swap (HistogramAccumulator &lhs, HistogramAccumulator &rhs)
 
void swap (Style &lhs, Style &rhs)
 
void swap (Color &lhs, Color &rhs)
 
void swap (NexusTaxa &lhs, NexusTaxa &rhs)
 
void swap (NexusTrees &lhs, NexusTrees &rhs)
 
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...
 
std::string to_lower (std::string const &str)
 Return an all-lowercase copy of the given string, locale-aware. More...
 
char to_lower_ascii (char c)
 Return the lower case of a given char, ascii-only. 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...
 
template<typename T >
std::string to_string (T const &v)
 Return a string representation of a given value. 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...
 
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...
 
std::string to_upper (std::string const &str)
 Return an all-uppercase copy of the given string, locale-aware. More...
 
char to_upper_ascii (char c)
 Return the upper case of a given char, ascii-only. 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. 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 &data)
 Transpose a 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=" \\\\\")
 Return a copy of the input string, with trimmed white spaces. More...
 
std::string trim_left (std::string const &s, std::string const &delimiters=" \\\\\")
 Return a copy of the input string, with right trimmed white spaces. More...
 
std::string trim_right (std::string const &s, std::string const &delimiters=" \\\\\")
 Return a copy of the input string, with left trimmed white spaces. More...
 
bool validate (Dataframe const &df)
 Merge two Dataframes by appending the columns of the second one (appendix) to the first one (target). More...
 
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...
 
double weighted_inner_product (std::vector< double > const &x_input, std::vector< double > const &y_input, std::vector< double > const &weights={})
 (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={})
 (Weighted) sum of a vector of values. More...
 
double weighted_sum_of_squares (std::vector< double > const &x_input, std::vector< double > const &weights={})
 (Weighted) sum of squares. More...
 
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 XmlCommentxml_value_to_comment (const XmlValue *v)
 Converts a pointer to an XmlValue to XmlComment if appropriate. More...
 
const XmlElementxml_value_to_element (const XmlValue *v)
 Converts a pointer to an XmlValue to XmlElement if appropriate. More...
 
const XmlMarkupxml_value_to_markup (const XmlValue *v)
 Converts a pointer to an XmlValue to XmlMarkup if appropriate. More...
 

Enumerations

enum  DivergingColorList {
  kBrbg, kPiyg, kPrgn, kPuor,
  kRdbu, kRdgy, kRdylbu, kRdylgn,
  kSpectral
}
 
enum  GeoCoordinateComponent { kLatitude, kLongitude }
 Local helper enum that indicates which component of a coordinate we are dealing with. More...
 
enum  HashingFunctions { kMD5, kSHA1, kSHA256 }
 List of the currently implemented hashing functions. 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  QualitativeColorList {
  kAccent, kDark2, kPaired, kPastel1,
  kPastel2, kSet1, kSet2, kSet3
}
 
enum  SequentialColorList {
  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  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 InputReader = SynchronousReader
 Alias for the either AsynchronousReader or SynchronousReader, depending on the threading setting. More...
 
using NamedColorList = std::vector< std::pair< std::string, ColorBytes > >
 

Variables

const std::vector< Colorcolor_list_accent_
 
const std::vector< Colorcolor_list_blues_
 
const std::vector< Colorcolor_list_brbg_
 
const std::vector< Colorcolor_list_bugn_
 
const std::vector< Colorcolor_list_bupu_
 
const std::vector< Colorcolor_list_bupubk_
 Our own color list used for visualizing trees. More...
 
const std::vector< Colorcolor_list_dark2_
 
const std::vector< Colorcolor_list_gnbu_
 
const std::vector< Colorcolor_list_greens_
 
const std::vector< Colorcolor_list_greys_
 
const std::vector< Colorcolor_list_heat_
 
const std::vector< Colorcolor_list_inferno_
 
const std::vector< Colorcolor_list_magma_
 
const std::vector< Colorcolor_list_oranges_
 
const std::vector< Colorcolor_list_orrd_
 
const std::vector< Colorcolor_list_paired_
 
const std::vector< Colorcolor_list_pastel1_
 
const std::vector< Colorcolor_list_pastel2_
 
const std::vector< Colorcolor_list_piyg_
 
const std::vector< Colorcolor_list_plasma_
 
const std::vector< Colorcolor_list_prgn_
 
const std::vector< Colorcolor_list_pubu_
 
const std::vector< Colorcolor_list_pubugn_
 
const std::vector< Colorcolor_list_puor_
 
const std::vector< Colorcolor_list_purd_
 
const std::vector< Colorcolor_list_purples_
 
const std::vector< Colorcolor_list_rdbu_
 
const std::vector< Colorcolor_list_rdgy_
 
const std::vector< Colorcolor_list_rdpu_
 
const std::vector< Colorcolor_list_rdylbu_
 
const std::vector< Colorcolor_list_rdylgn_
 
const std::vector< Colorcolor_list_reds_
 
const std::vector< Colorcolor_list_set1_
 
const std::vector< Colorcolor_list_set2_
 
const std::vector< Colorcolor_list_set3_
 
const std::vector< Colorcolor_list_spectral_
 
const std::vector< Colorcolor_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< Colorcolor_list_ylgn_
 
const std::vector< Colorcolor_list_ylgnbu_
 
const std::vector< Colorcolor_list_ylorbr_
 
const std::vector< Colorcolor_list_ylorrd_
 
constexpr double EARTH_MEAN_RADIUS = 6371.0
 Earth is not flat! More...
 
constexpr double MDS_EPSILON = 0.0000001
 
constexpr double PI = 3.141592653589793238463
 Make the world go round. More...
 

Function Documentation

◆ abs_diff()

constexpr T genesis::utils::abs_diff ( T const &  lhs,
T const &  rhs 
)
inline

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 72 of file common.hpp.

◆ affirm_char_or_throw() [1/2]

void genesis::utils::affirm_char_or_throw ( InputStream source,
char  criterion,
SkipWhitespace  skip_ws = SkipWhitespace::kNone 
)
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 380 of file scanner.hpp.

◆ affirm_char_or_throw() [2/2]

void genesis::utils::affirm_char_or_throw ( InputStream source,
std::function< bool(char)>  criterion,
SkipWhitespace  skip_ws = SkipWhitespace::kNone 
)
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 415 of file scanner.hpp.

◆ aitchison_norm() [1/2]

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

See also
p_norm(), euclidean_norm(), manhattan_norm(), and maximum_norm() for some standard norms.

Definition at line 216 of file distance.hpp.

◆ aitchison_norm() [2/2]

double genesis::utils::aitchison_norm ( std::vector< double > const &  vec)
inline

Calculate the Aitchison norm of a std::vector of double elements.

See also
aitchison_norm( ForwardIterator, ForwardIterator ) for details.

Definition at line 262 of file distance.hpp.

◆ almost_equal_relative()

bool genesis::utils::almost_equal_relative ( double  lhs,
double  rhs,
double  max_rel_diff = std::numeric_limits<double>::epsilon() 
)
inline

Check whether two doubles are almost equal, using a relative epsilon to compare them.

Definition at line 118 of file common.hpp.

◆ arithmetic_mean() [1/2]

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.

See also
arithmetic_mean( std::vector<double> const& ) for a version for std::vector.
mean_stddev() for a function that also calculates the standard deviation.
geometric_mean() for a function that calculates the geometric mean.
weighted_arithmetic_mean() for a function that calculates the weighted arithmetic mean.

Definition at line 406 of file statistics.hpp.

◆ arithmetic_mean() [2/2]

double genesis::utils::arithmetic_mean ( std::vector< double > const &  vec)
inline

Calculate the arithmetic mean of a std::vector of double elements.

See also
arithmetic_mean( ForwardIterator first, ForwardIterator last ) for details.
mean_stddev() for a function that simultaneously calculates the standard deviation.
geometric_mean() for a function that calculates the geometric mean.

Definition at line 440 of file statistics.hpp.

◆ bitstring() [1/2]

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.

◆ bitstring() [2/2]

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.

◆ bitwise_and()

Bitvector bitwise_and ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Take the bitwise and of two Bitvectors of potentially different size.

The function is the same as normal and, but operates only on the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m ) with m = min( lhs.size(), rhs.size() ).

Definition at line 86 of file utils/math/bitvector/operators.cpp.

◆ bitwise_or()

Bitvector bitwise_or ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Take the bitwise or of two Bitvectors of potentially different size.

The function is the same as normal or, but operates only on the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m ) with m = min( lhs.size(), rhs.size() ).

Definition at line 99 of file utils/math/bitvector/operators.cpp.

◆ bitwise_xor()

Bitvector bitwise_xor ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Take the bitwise xor of two Bitvectors of potentially different size.

The function is the same as normal xor, but operates only on the number of bits of the shorter Bitvector, that is, it operates on bits [ 0 , m ) with m = min( lhs.size(), rhs.size() ).

Definition at line 112 of file utils/math/bitvector/operators.cpp.

◆ build_path_base_swap_()

static void genesis::utils::build_path_base_swap_ ( std::string &  path,
const std::string &  newbase 
)
static

Definition at line 496 of file fs.cpp.

◆ char_is_digit()

bool genesis::utils::char_is_digit ( const char  c)
inline

Return whether a char is a digit (0-9).

Definition at line 49 of file char.hpp.

◆ char_is_number_part()

bool genesis::utils::char_is_number_part ( char const  c)
inline

Return whether a char is valid in a number, i.e., a digit, a dot, plus, minus, or 'e'/'E'.

Definition at line 65 of file char.hpp.

◆ char_is_sign()

bool genesis::utils::char_is_sign ( const char  c)
inline

Return whether a char is a sign (+-).

Definition at line 57 of file char.hpp.

◆ char_match_ci()

bool genesis::utils::char_match_ci ( const char  c1,
const char  c2 
)
inline

Return whether two chars are the same, case insensitive.

Definition at line 73 of file char.hpp.

◆ char_to_hex()

std::string genesis::utils::char_to_hex ( char  c,
bool  full = false 
)
inline

Return the hex representation of a char.

By default, just the two-byte hex presentation is returned (e.g., 4e for N). If full is true, a text-representation is returned instead, using the form

'N' (0x4e)

instead.

Definition at line 104 of file char.hpp.

◆ chdir_getcwd_()

static std::string genesis::utils::chdir_getcwd_ ( std::string const &  dir)
static

Definition at line 436 of file fs.cpp.

◆ circumference()

double genesis::utils::circumference ( double  radius)
inline

Definition at line 56 of file common.hpp.

◆ closure() [1/2]

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 256 of file statistics.hpp.

◆ closure() [2/2]

void genesis::utils::closure ( std::vector< double > &  vec)
inline

Calculate the closure of a std::vector of double elements.

See also
closure( ForwardIterator first, ForwardIterator last ) for details.

Definition at line 298 of file statistics.hpp.

◆ coefficient_of_variation() [1/2]

double genesis::utils::coefficient_of_variation ( MeanStddevPair const &  ms)
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 787 of file statistics.hpp.

◆ coefficient_of_variation() [2/2]

std::vector<double> genesis::utils::coefficient_of_variation ( std::vector< MeanStddevPair > const &  ms)
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 795 of file statistics.hpp.

◆ color_from_bytes()

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/tools/color/functions.cpp.

◆ color_from_hex()

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/tools/color/functions.cpp.

◆ color_from_name()

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().

Definition at line 1240 of file names.cpp.

◆ color_from_name_web()

Color color_from_name_web ( std::string const &  name)

Retrieve a named web color by name.

Names are filtered so that spaces, underscores and the letter case are ignored. If the color name does not exist, an std::invalid_argument exception is thrown.

Definition at line 1261 of file names.cpp.

◆ color_from_name_xkcd()

Color color_from_name_xkcd ( std::string const &  name)

Retrieve a named xkcd color by name.

Names are filtered so that spaces, underscores and the letter case are 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.

Definition at line 1286 of file names.cpp.

◆ color_list_accent()

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 qualitative_lists.cpp.

◆ color_list_blues()

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 sequential_lists.cpp.

◆ color_list_brbg()

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 diverging_lists.cpp.

◆ color_list_bugn()

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 sequential_lists.cpp.

◆ color_list_bupu()

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 sequential_lists.cpp.

◆ color_list_bupubk()

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 sequential_lists.cpp.

◆ color_list_dark2()

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 qualitative_lists.cpp.

◆ color_list_gnbu()

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 sequential_lists.cpp.

◆ color_list_greens()

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 sequential_lists.cpp.

◆ color_list_greys()

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 sequential_lists.cpp.

◆ color_list_heat()

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 sequential_lists.cpp.

◆ color_list_inferno()

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 sequential_lists.cpp.

◆ color_list_magma()

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 sequential_lists.cpp.

◆ color_list_oranges()

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 sequential_lists.cpp.

◆ color_list_orrd()

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 sequential_lists.cpp.

◆ color_list_paired()

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 qualitative_lists.cpp.

◆ color_list_pastel1()

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 qualitative_lists.cpp.

◆ color_list_pastel2()

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 qualitative_lists.cpp.

◆ color_list_piyg()

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 diverging_lists.cpp.

◆ color_list_plasma()

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 sequential_lists.cpp.

◆ color_list_prgn()

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 diverging_lists.cpp.

◆ color_list_pubu()

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 sequential_lists.cpp.

◆ color_list_pubugn()

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 sequential_lists.cpp.

◆ color_list_puor()

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 diverging_lists.cpp.

◆ color_list_purd()

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 sequential_lists.cpp.

◆ color_list_purples()

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 sequential_lists.cpp.

◆ color_list_rdbu()

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 diverging_lists.cpp.

◆ color_list_rdgy()

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 diverging_lists.cpp.

◆ color_list_rdpu()

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 sequential_lists.cpp.

◆ color_list_rdylbu()

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 diverging_lists.cpp.

◆ color_list_rdylgn()

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 diverging_lists.cpp.

◆ color_list_reds()

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 sequential_lists.cpp.

◆ color_list_set1()

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 qualitative_lists.cpp.

◆ color_list_set2()

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 qualitative_lists.cpp.

◆ color_list_set3()

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 qualitative_lists.cpp.

◆ color_list_spectral()

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 diverging_lists.cpp.

◆ color_list_viridis()

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 sequential_lists.cpp.

◆ color_list_ylgn()

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 sequential_lists.cpp.

◆ color_list_ylgnbu()

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 sequential_lists.cpp.

◆ color_list_ylorbr()

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 sequential_lists.cpp.

◆ color_list_ylorrd()

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 sequential_lists.cpp.

◆ color_palette_web()

std::vector< Color > color_palette_web ( )

Definition at line 1272 of file names.cpp.

◆ color_palette_xkcd()

std::vector< Color > color_palette_xkcd ( )

Definition at line 1297 of file names.cpp.

◆ color_stops() [1/5]

std::map< double, Color > color_stops ( ColorMap const &  map,
ColorNormalization const &  norm 
)

Definition at line 52 of file helpers.cpp.

◆ color_stops() [2/5]

std::map< double, Color > color_stops ( ColorMap const &  map,
ColorNormalizationLinear const &  norm 
)

Definition at line 77 of file helpers.cpp.

◆ color_stops() [3/5]

std::map< double, Color > color_stops ( ColorMap const &  map,
ColorNormalizationLogarithmic const &  norm 
)

Definition at line 88 of file helpers.cpp.

◆ color_stops() [4/5]

std::map< double, Color > color_stops ( ColorMap const &  map,
ColorNormalizationDiverging const &  norm 
)

Definition at line 93 of file helpers.cpp.

◆ color_stops() [5/5]

std::map< double, Color > color_stops ( ColorMap const &  map,
ColorNormalizationBoundary const &  norm 
)

Definition at line 137 of file helpers.cpp.

◆ color_tickmarks() [1/5]

std::map< double, std::string > color_tickmarks ( ColorNormalization const &  norm,
size_t  num_ticks 
)

Definition at line 156 of file helpers.cpp.

◆ color_tickmarks() [2/5]

std::map< double, std::string > color_tickmarks ( ColorNormalizationLinear const &  norm,
size_t  num_ticks 
)

Definition at line 181 of file helpers.cpp.

◆ color_tickmarks() [3/5]

std::map< double, std::string > color_tickmarks ( ColorNormalizationLogarithmic const &  norm,
size_t  num_ticks 
)

Definition at line 192 of file helpers.cpp.

◆ color_tickmarks() [4/5]

std::map< double, std::string > color_tickmarks ( ColorNormalizationDiverging const &  norm,
size_t  num_ticks 
)

Definition at line 214 of file helpers.cpp.

◆ color_tickmarks() [5/5]

std::map< double, std::string > color_tickmarks ( ColorNormalizationBoundary const &  norm,
size_t  num_ticks 
)

Definition at line 261 of file helpers.cpp.

◆ color_to_hex()

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/tools/color/functions.cpp.

◆ contains()

bool genesis::utils::contains ( const C &  v,
const T &  x 
)
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 58 of file algorithm.hpp.

◆ contains_ci()

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 49 of file string.cpp.

◆ contains_duplicates()

bool genesis::utils::contains_duplicates ( C const &  v)
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 70 of file algorithm.hpp.

◆ convert_geo_coordinate() [1/2]

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.

◆ convert_geo_coordinate() [2/2]

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.

◆ convert_single_geo_coordinate_()

static double genesis::utils::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 
)
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.

◆ convert_to_bool() [1/4]

bool genesis::utils::convert_to_bool ( std::string const &  str)
inline

Definition at line 50 of file convert.hpp.

◆ convert_to_bool() [2/4]

std::vector<bool> genesis::utils::convert_to_bool ( ForwardIterator  first,
ForwardIterator  last,
size_t  size = 0 
)

Definition at line 69 of file convert.hpp.

◆ convert_to_bool() [3/4]

void convert_to_bool ( Dataframe df,
size_t  col_index 
)

Definition at line 152 of file utils/containers/dataframe/operators.cpp.

◆ convert_to_bool() [4/4]

void convert_to_bool ( Dataframe df,
std::string const &  col_name 
)

Definition at line 182 of file utils/containers/dataframe/operators.cpp.

◆ convert_to_double() [1/4]

double genesis::utils::convert_to_double ( std::string const &  str)
inline

Definition at line 116 of file convert.hpp.

◆ convert_to_double() [2/4]

std::vector<double> genesis::utils::convert_to_double ( ForwardIterator  first,
ForwardIterator  last,
size_t  size = 0 
)

Definition at line 138 of file convert.hpp.

◆ convert_to_double() [3/4]

void convert_to_double ( Dataframe df,
size_t  col_index 
)

Definition at line 188 of file utils/containers/dataframe/operators.cpp.

◆ convert_to_double() [4/4]

void convert_to_double ( Dataframe df,
std::string const &  col_name 
)

Definition at line 202 of file utils/containers/dataframe/operators.cpp.

◆ convert_to_palette_()

static std::vector<Color> genesis::utils::convert_to_palette_ ( NamedColorList const &  list)
static

Local helper function to convert a list of byte colors into a proper Color vector.

Definition at line 1212 of file names.cpp.

◆ convert_to_type_() [1/2]

void genesis::utils::convert_to_type_ ( Dataframe df,
size_t  col_index 
)

Definition at line 107 of file utils/containers/dataframe/operators.cpp.

◆ convert_to_type_() [2/2]

void genesis::utils::convert_to_type_ ( Dataframe df,
size_t  col_index 
)

Definition at line 119 of file utils/containers/dataframe/operators.cpp.

◆ correlation_matrix()

Matrix< double > correlation_matrix ( Matrix< double > const &  data)

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.

◆ count_substring_occurrences()

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 116 of file string.cpp.

◆ covariance_matrix()

Matrix< double > covariance_matrix ( Matrix< double > const &  data)

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.

◆ current_date()

std::string current_date ( )

Returns the current date as a string in the format "2014-12-31".

Definition at line 39 of file date_time.cpp.

◆ current_path()

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.

Definition at line 397 of file fs.cpp.

◆ current_path_getcwd_()

static std::string genesis::utils::current_path_getcwd_ ( )
static

Definition at line 275 of file fs.cpp.

◆ current_path_unix_()

static std::string genesis::utils::current_path_unix_ ( )
static

Definition at line 306 of file fs.cpp.

◆ current_time()

std::string current_time ( )

Returns the current time as a string in the format "13:37:42".

Definition at line 51 of file date_time.cpp.

◆ deescape() [1/2]

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 373 of file string.cpp.

◆ deescape() [2/2]

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 395 of file string.cpp.

◆ dir_create()

void dir_create ( std::string const &  path,
bool  with_parents = true 
)

Create a directory.

If the directory already exists, nothing happens. If the path exists, but is not a directory, a std::runtime_error is thrown. If the creation fails for some other reason, also a std::runtime_error is thrown.

Definition at line 166 of file fs.cpp.

◆ dir_exists()

bool dir_exists ( std::string const &  dir)

Return true iff the directory exists.

Definition at line 148 of file fs.cpp.

◆ dir_list_contents()

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.

Definition at line 240 of file fs.cpp.

◆ dir_list_contents_()

static std::vector<std::string> genesis::utils::dir_list_contents_ ( std::string const &  dir,
bool  full_path,
std::string const &  regex,
std::function< bool(std::string const &)>  condition 
)
static

Definition at line 199 of file fs.cpp.

◆ dir_list_directories()

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.

Definition at line 261 of file fs.cpp.

◆ dir_list_files()

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.

Definition at line 251 of file fs.cpp.

◆ dir_normalize_path()

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.

Definition at line 194 of file fs.cpp.

◆ diverging_color_list() [1/2]

std::vector< Color > const & diverging_color_list ( DivergingColorList  palette)

Definition at line 249 of file diverging_lists.cpp.

◆ diverging_color_list() [2/2]

std::vector< Color > const & diverging_color_list ( std::string const &  palette)

Definition at line 282 of file diverging_lists.cpp.

◆ diverging_color_list_names()

std::vector< std::string > diverging_color_list_names ( )

Definition at line 317 of file diverging_lists.cpp.

◆ double_frame()

TableLayout double_frame ( bool  condensed)

Definition at line 573 of file utils/text/table.cpp.

◆ double_grid()

TableLayout double_grid ( bool  condensed)

Definition at line 554 of file utils/text/table.cpp.

◆ earth_movers_distance()

double earth_movers_distance ( const Histogram h1,
const Histogram h2,
bool  norm 
)

Definition at line 48 of file utils/math/histogram/distances.cpp.

◆ ends_with()

bool ends_with ( std::string const &  text,
std::string const &  ending 
)

Return whether a string ends with another string.

Definition at line 82 of file string.cpp.

◆ equal_ranges()

bool equal_ranges ( Histogram const &  lhs,
Histogram const &  rhs 
)

Definition at line 55 of file histogram.cpp.

◆ equals_ci()

bool equals_ci ( std::string const &  lhs,
std::string const &  rhs 
)

Compare two strings case insensitive.

Definition at line 60 of file string.cpp.

◆ erase_if()

void genesis::utils::erase_if ( Container &  c,
UnaryPredicate  p 
)
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.

Parameters
cThe container to modify.
pThe predicate to satisfy.

Definition at line 91 of file algorithm.hpp.

◆ escape()

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 361 of file string.cpp.

◆ euclidean_distance() [1/2]

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 375 of file distance.hpp.

◆ euclidean_distance() [2/2]

double genesis::utils::euclidean_distance ( std::vector< double > const &  vec_a,
std::vector< double > const &  vec_b 
)
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 389 of file distance.hpp.

◆ euclidean_distance_matrix()

Matrix< double > euclidean_distance_matrix ( Matrix< double > const &  data)

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.

◆ euclidean_norm() [1/2]

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.

◆ euclidean_norm() [2/2]

double genesis::utils::euclidean_norm ( std::vector< double > const &  vec)
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.

◆ extended_frame()

TableLayout extended_frame ( bool  condensed)

Definition at line 523 of file utils/text/table.cpp.

◆ extended_grid()

TableLayout extended_grid ( bool  condensed)

Definition at line 504 of file utils/text/table.cpp.

◆ file_append()

void file_append ( std::string const &  content,
std::string const &  filename 
)

Append the content of a string to a file.

If the file is not writable, the function throws std::runtime_error.

Definition at line 127 of file fs.cpp.

◆ file_basename()

std::string file_basename ( std::string const &  filename)

Remove directory name from file name if present.

Definition at line 661 of file fs.cpp.

◆ file_exists()

bool file_exists ( std::string const &  filename)

Return true iff the file exists.

Definition at line 76 of file fs.cpp.

◆ file_extension()

std::string file_extension ( std::string const &  filename)

Return the extension name of a file.

Also see file_filename().

Definition at line 683 of file fs.cpp.

◆ 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.

Definition at line 672 of file fs.cpp.

◆ file_info()

std::unordered_map< std::string, std::string > file_info ( std::string const &  filename)

Return information about a file.

Definition at line 629 of file fs.cpp.

◆ file_output_stream()

void genesis::utils::file_output_stream ( std::string const &  filename,
std::ofstream &  out_stream,
std::ios_base::openmode  mode = std::ios_base::out 
)
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 file 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.

Parameters
[in]filenamePath to the file to write to.
[out]out_streamReference 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]modeMode flag as used by std::ostream.
See also
Options::allow_file_overwriting( bool )

Definition at line 67 of file output_stream.hpp.

◆ file_path()

std::string file_path ( std::string const &  filename)

Return the path leading to a file.

Does not resolve the path. Simply splits at the last directory separator. If there is no directory separator, it returns an empty string.

Definition at line 649 of file fs.cpp.

◆ file_read()

std::string file_read ( std::string const &  filename)

Return the contents of a file as a string.

If the file is not readable, the function throws std::runtime_error.

Definition at line 88 of file fs.cpp.

◆ file_read_lines()

std::vector< std::string > file_read_lines ( std::string const &  filename)

Return the contents of a file as a vector of strings, one entry for each line.

If the file is not readable, the function throws std::runtime_error.

Definition at line 106 of file fs.cpp.

◆ file_size()

size_t file_size ( std::string const &  filename)

Return the size of a file.

Definition at line 642 of file fs.cpp.

◆ file_write()

void file_write ( std::string const &  content,
std::string const &  filename 
)

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.

Definition at line 118 of file fs.cpp.

◆ filter_constant_columns()

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.

Parameters
[in,out]dataMatrix to filter inplace.
[in]epsilonMaximum deviation for what is considered constant.
Returns
List of original column indices that are kept (not filtered).

Definition at line 158 of file math/matrix.cpp.

◆ finite_pairs()

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 189 of file common.hpp.

◆ fisher_transformation() [1/2]

double genesis::utils::fisher_transformation ( double  correlation_coefficient)
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 971 of file statistics.hpp.

◆ fisher_transformation() [2/2]

std::vector<double> genesis::utils::fisher_transformation ( std::vector< double > const &  correlation_coefficients)
inline

Apply Fisher z-transformation to a vector of correlation coefficients.

See fisher_transformation( double ) for details.

Definition at line 991 of file statistics.hpp.

◆ for_each_finite_pair()

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 223 of file common.hpp.

◆ fraction_of_variance_unexplained()

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.

See also
simple_linear_regression() for calculating such a fit.

Definition at line 155 of file slr.hpp.

◆ from_file()

std::shared_ptr<BaseInputSource> genesis::utils::from_file ( std::string const &  file_name,
bool  detect_compression = true 
)
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.

See also
from_files(), from_string(), from_strings(), and from_stream() for similar helper functions for other types of input sources.

Definition at line 68 of file input_source.hpp.

◆ from_files()

std::vector<std::shared_ptr<BaseInputSource> > genesis::utils::from_files ( std::vector< std::string > const &  file_names,
bool  detect_compression = true 
)
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().

See also
from_file(), from_string(), from_strings(), and from_stream() for similar helper functions for other types of input sources.

Definition at line 91 of file input_source.hpp.

◆ from_nucleic_acids()

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.

◆ from_stream()

std::shared_ptr<BaseInputSource> genesis::utils::from_stream ( std::istream &  input_stream)
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.

See also
from_file(), from_files(), from_string(), and from_strings() for similar helper functions for other types of input sources.

Definition at line 144 of file input_source.hpp.

◆ from_string()

std::shared_ptr<BaseInputSource> genesis::utils::from_string ( std::string const &  input_string)
inline

Obtain an input sources 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.

See also
from_file(), from_files(), from_strings(), and from_stream() for similar helper functions for other types of input sources.

Definition at line 111 of file input_source.hpp.

◆ from_strings()

std::vector<std::shared_ptr<BaseInputSource> > genesis::utils::from_strings ( std::vector< std::string > const &  input_strings)
inline

Obtain a set of input sources for reading from strings.

See from_string() and from_files() for details.

See also
from_file(), from_files(), from_string(), and from_stream() for similar helper functions for other types of input sources.

Definition at line 125 of file input_source.hpp.

◆ geo_distance()

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.

◆ geometric_mean() [1/2]

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.

See also
geometric_mean( std::vector<double> const& ) for a version for std::vector.
weighted_geometric_mean() for a weighted version.
arithmetic_mean() for a function that calculates the arithmetic mean.

Definition at line 532 of file statistics.hpp.

◆ geometric_mean() [2/2]

double genesis::utils::geometric_mean ( std::vector< double > const &  vec)
inline

Calculate the geometric mean of a std::vector of double elements.

See also
geometric_mean( ForwardIterator first, ForwardIterator last ) for details.
arithmetic_mean() for a function that calculates the arithmetic mean.

Definition at line 570 of file statistics.hpp.

◆ get_attribute_string_()

static std::string genesis::utils::get_attribute_string_ ( Style const &  s)
static

Internal helper function that returns the attribute string of a Style based on its properties.

Definition at line 193 of file style.cpp.

◆ get_background_color_iterator()

static std::array<std::pair<std::string, std::string>, 17>::const_iterator genesis::utils::get_background_color_iterator ( std::string  name)
static

Internal helper function that returns an iterator into the background color list.

Definition at line 69 of file style.cpp.

◆ get_color_list_iterator_()

static NamedColorList::const_iterator genesis::utils::get_color_list_iterator_ ( NamedColorList const &  list,
std::string  name 
)
static

Internal helper function.

Returns an iterator into the vector if the given name is a named color or an iterator to the end of the color map if it is not a named color.

Definition at line 1187 of file names.cpp.

◆ get_foreground_color_iterator()

static std::array<std::pair<std::string, std::string>, 17>::const_iterator genesis::utils::get_foreground_color_iterator ( std::string  name)
static

Internal helper function that returns an iterator into the foreground color list.

Definition at line 51 of file style.cpp.

◆ glm_convert_dataframe()

Matrix< double > glm_convert_dataframe ( Dataframe const &  df,
std::vector< std::string >  row_order 
)

Definition at line 142 of file dataframe.cpp.

◆ glm_factor()

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.

◆ glm_factor_summary()

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 166 of file factor.hpp.

◆ glm_family_binomial()

GlmFamily genesis::utils::glm_family_binomial ( )
inline

Binomial family functions.

The canonical link for binomial is logit, see glm_link_logit().

Definition at line 120 of file family.hpp.

◆ glm_family_gamma()

GlmFamily genesis::utils::glm_family_gamma ( )
inline

Gamma family functions.

The canonical link for gamma is identity, see glm_link_gamma().

Definition at line 266 of file family.hpp.

◆ glm_family_gaussian()

GlmFamily genesis::utils::glm_family_gaussian ( )
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.

◆ glm_family_poisson()

GlmFamily genesis::utils::glm_family_poisson ( )
inline

Poisson family functions.

The canonical link for poisson is log, see glm_link_log().

Definition at line 181 of file family.hpp.

◆ glm_fit() [1/3]

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.

Definition at line 355 of file glm.cpp.

◆ glm_fit() [2/3]

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.

Definition at line 519 of file glm.cpp.

◆ glm_fit() [3/3]

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.

Definition at line 532 of file glm.cpp.

◆ glm_gaussian_()

static void genesis::utils::glm_gaussian_ ( Matrix< double > const &  x_predictors,
std::vector< double > const &  y_response,
GlmExtras const &  extras,
GlmControl const &  control,
GlmFreedom const &  freedom,
GlmOutput result 
)
static

Definition at line 264 of file glm.cpp.

◆ glm_indicator_variables() [1/2]

Dataframe genesis::utils::glm_indicator_variables ( GlmFactor< T > const &  factor,
T const &  reference_level,
std::vector< std::string > const &  row_names = {} 
)

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 187 of file factor.hpp.

◆ glm_indicator_variables() [2/2]

Dataframe genesis::utils::glm_indicator_variables ( GlmFactor< T > const &  factor,
std::vector< std::string > const &  row_names = {} 
)

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 267 of file factor.hpp.

◆ glm_irls_()

static void genesis::utils::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 
)
static

Definition at line 81 of file glm.cpp.

◆ glm_link_identity()

GlmLink genesis::utils::glm_link_identity ( )
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.

◆ glm_link_inverse()

GlmLink genesis::utils::glm_link_inverse ( )
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.

◆ glm_link_log()

GlmLink genesis::utils::glm_link_log ( )
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.

◆ glm_link_logit()

GlmLink genesis::utils::glm_link_logit ( )
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.

◆ glm_prepare_dataframe() [1/2]

Dataframe glm_prepare_dataframe ( Dataframe const &  df,
std::string &  report 
)

Definition at line 50 of file dataframe.cpp.

◆ glm_prepare_dataframe() [2/2]

Dataframe glm_prepare_dataframe ( Dataframe const &  df)

Definition at line 136 of file dataframe.cpp.

◆ gradient()

Color gradient ( std::map< double, Color > const &  ranges,
double  value 
)

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/tools/color/functions.cpp.

◆ hash_hex()

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.

◆ head()

std::string head ( std::string const &  text,
size_t  lines 
)

Return the first lines of the text.

Definition at line 94 of file string.cpp.

◆ heat_gradient()

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/tools/color/functions.cpp.

◆ indent()

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 270 of file string.cpp.

◆ index_of_dispersion() [1/2]

double genesis::utils::index_of_dispersion ( MeanStddevPair const &  ms)
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 813 of file statistics.hpp.

◆ index_of_dispersion() [2/2]

std::vector<double> genesis::utils::index_of_dispersion ( std::vector< MeanStddevPair > const &  ms)
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 821 of file statistics.hpp.

◆ insert_sorted() [1/2]

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 136 of file algorithm.hpp.

◆ insert_sorted() [2/2]

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 150 of file algorithm.hpp.

◆ int_pow()

size_t genesis::utils::int_pow ( size_t  base,
size_t  exp 
)
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 152 of file common.hpp.

◆ interpolate()

Color interpolate ( Color const &  color1,
Color const &  color2,
double  fraction 
)

Linearily interpolate between two Colors.

Definition at line 154 of file utils/tools/color/functions.cpp.

◆ is_canonical_link()

bool genesis::utils::is_canonical_link ( GlmFamily const &  family,
GlmLink const &  link 
)
inline

Definition at line 106 of file family.hpp.

◆ is_color_name()

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_web_color_name() and is_xkcd_color_name().

Definition at line 1229 of file names.cpp.

◆ is_convertible_to_bool() [1/4]

bool is_convertible_to_bool ( Dataframe const &  df,
size_t  col_index 
)

Definition at line 57 of file utils/containers/dataframe/operators.cpp.

◆ is_convertible_to_bool() [2/4]

bool is_convertible_to_bool ( Dataframe const &  df,
std::string const &  col_name 
)

Definition at line 74 of file utils/containers/dataframe/operators.cpp.

◆ is_convertible_to_bool() [3/4]

bool genesis::utils::is_convertible_to_bool ( std::string const &  str)
inline

Definition at line 86 of file convert.hpp.

◆ is_convertible_to_bool() [4/4]

bool genesis::utils::is_convertible_to_bool ( ForwardIterator  first,
ForwardIterator  last 
)

Definition at line 97 of file convert.hpp.

◆ is_convertible_to_double() [1/4]

bool is_convertible_to_double ( Dataframe const &  df,
size_t  col_index 
)

Definition at line 80 of file utils/containers/dataframe/operators.cpp.

◆ is_convertible_to_double() [2/4]

bool is_convertible_to_double ( Dataframe const &  df,
std::string const &  col_name 
)

Definition at line 96 of file utils/containers/dataframe/operators.cpp.

◆ is_convertible_to_double() [3/4]

bool genesis::utils::is_convertible_to_double ( std::string const &  str)
inline

Definition at line 155 of file convert.hpp.

◆ is_convertible_to_double() [4/4]

bool genesis::utils::is_convertible_to_double ( ForwardIterator  first,
ForwardIterator  last 
)

Definition at line 169 of file convert.hpp.

◆ is_defined() [1/2]

bool genesis::utils::is_defined ( GlmLink const &  link)
inline

Check whether all necessary values and functors of a GlmLink are set.

Definition at line 83 of file utils/math/regression/link.hpp.

◆ is_defined() [2/2]

bool genesis::utils::is_defined ( GlmFamily const &  family)
inline

Check whether all necessary values and functors of a GlmFamily are set.

Definition at line 101 of file family.hpp.

◆ is_dir()

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.

Definition at line 143 of file fs.cpp.

◆ is_file()

bool is_file ( std::string const &  path)

Return true iff the provided path is a file.

Internally, this function simply return the value of file_exists(), as this already does the needed check. Thus, it is an alias.

Definition at line 71 of file fs.cpp.

◆ is_gzip_compressed_file()

bool is_gzip_compressed_file ( std::string const &  file_name)

Definition at line 47 of file gzip.cpp.

◆ is_numerical_type_()

static bool genesis::utils::is_numerical_type_ ( Dataframe const &  df,
size_t  col_index 
)
static

Definition at line 47 of file utils/containers/dataframe/operators.cpp.

◆ is_square()

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 142 of file utils/containers/matrix/operators.hpp.

◆ is_strict_subset()

bool is_strict_subset ( Bitvector const &  sub,
Bitvector const &  super 
)

Strict subset.

Definition at line 135 of file utils/math/bitvector/operators.cpp.

◆ is_strict_superset()

bool is_strict_superset ( Bitvector const &  super,
Bitvector const &  sub 
)

Strict superset.

Definition at line 140 of file utils/math/bitvector/operators.cpp.

◆ is_subset()

bool is_subset ( Bitvector const &  sub,
Bitvector const &  super 
)

Subset or equal.

Definition at line 145 of file utils/math/bitvector/operators.cpp.

◆ is_superset()

bool is_superset ( Bitvector const &  super,
Bitvector const &  sub 
)

Superset or equal.

Definition at line 150 of file utils/math/bitvector/operators.cpp.

◆ is_symmetric()

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 152 of file utils/containers/matrix/operators.hpp.

◆ is_valid_filename()

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:

  • Those with spaces at the beginning or end, or only consisting of spaces (or empty).
  • Those which contain any of the chars < > : " \ / | ? *.
  • Those which contain any non-printable character, as determined via isprint().

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.

Definition at line 698 of file fs.cpp.

◆ is_valid_int_pow()

bool genesis::utils::is_valid_int_pow ( size_t  base,
size_t  exp 
)
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 172 of file common.hpp.

◆ is_web_color_name()

bool is_web_color_name ( std::string const &  name)

Return true iff the given name is a named web color.

Names are filtered so that spaces, underscores and the letter case are ignored.

Definition at line 1256 of file names.cpp.

◆ is_xkcd_color_name()

bool is_xkcd_color_name ( std::string const &  name)

Return true iff the given name is a named xkcd color.

Names are filtered so that spaces, underscores and the letter case are ignored. See color_from_name_xkcd() for details on this color list.

Definition at line 1281 of file names.cpp.

◆ iterate_deletions()

utils::Range< IteratorDeletions > genesis::utils::iterate_deletions ( TwobitVector const &  vector)
inline

Definition at line 220 of file iterator_deletions.hpp.

◆ iterate_insertions()

utils::Range< IteratorInsertions > genesis::utils::iterate_insertions ( TwobitVector const &  vector)
inline

Definition at line 249 of file iterator_insertions.hpp.

◆ iterate_substitutions()

utils::Range< IteratorSubstitutions > genesis::utils::iterate_substitutions ( TwobitVector const &  vector)
inline

Definition at line 239 of file iterator_substitutions.hpp.

◆ join()

std::string genesis::utils::join ( T const &  v,
std::string const &  delimiter = ", " 
)

Return a string where the elements of a container v are joined using the string delimiter in between them.

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.

Definition at line 402 of file string.hpp.

◆ logging_progress_value()

long genesis::utils::logging_progress_value ( long  value = -1)
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 162 of file logging.hpp.

◆ make_svg_color_bar()

std::pair< SvgGradientLinear, SvgGroup > make_svg_color_bar ( SvgColorBarSettings const &  settings,
ColorMap const &  map,
ColorNormalization const &  norm,
std::string const &  id 
)

Definition at line 324 of file color_bar.cpp.

◆ make_svg_color_bar_discrete_()

static std::pair<SvgGradientLinear, SvgGroup> genesis::utils::make_svg_color_bar_discrete_ ( SvgColorBarSettings const &  settings,
std::map< double, Color > const &  stops 
)
static

Definition at line 129 of file color_bar.cpp.

◆ make_svg_color_bar_gradient_()

static std::pair<SvgGradientLinear, SvgGroup> genesis::utils::make_svg_color_bar_gradient_ ( SvgColorBarSettings const &  settings,
ColorMap const &  map,
ColorNormalization const &  norm,
std::string const &  id 
)
static

Definition at line 64 of file color_bar.cpp.

◆ make_svg_color_bar_tickmarks_()

static void genesis::utils::make_svg_color_bar_tickmarks_ ( SvgColorBarSettings const &  settings,
ColorMap const &  map,
ColorNormalization const &  norm,
SvgGroup group 
)
static

Definition at line 211 of file color_bar.cpp.

◆ make_svg_color_list()

SvgGroup make_svg_color_list ( ColorMap const &  map,
std::vector< std::string > const &  labels 
)

Definition at line 361 of file color_bar.cpp.

◆ make_svg_matrix()

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.

◆ make_unique()

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/

Definition at line 68 of file std.hpp.

◆ manhattan_distance() [1/2]

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 347 of file distance.hpp.

◆ manhattan_distance() [2/2]

double genesis::utils::manhattan_distance ( std::vector< double > const &  vec_a,
std::vector< double > const &  vec_b 
)
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 361 of file distance.hpp.

◆ manhattan_distance_matrix()

Matrix< double > manhattan_distance_matrix ( Matrix< double > const &  data)

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.

◆ manhattan_norm() [1/2]

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.

◆ manhattan_norm() [2/2]

double genesis::utils::manhattan_norm ( std::vector< double > const &  vec)
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.

◆ matrix_addition() [1/2]

Matrix<T> genesis::utils::matrix_addition ( Matrix< A > const &  a,
Matrix< B > const &  b 
)

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.

◆ matrix_addition() [2/2]

Matrix<T> genesis::utils::matrix_addition ( Matrix< A > const &  matrix,
B const &  scalar 
)

Calculate the element-wise sum of a Matrix and a scalar.

Definition at line 505 of file math/matrix.hpp.

◆ matrix_col_minmax()

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.

◆ matrix_col_sums()

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.

◆ matrix_minmax()

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.

◆ matrix_multiplication() [1/4]

Matrix<T> genesis::utils::matrix_multiplication ( Matrix< A > const &  a,
Matrix< B > const &  b 
)

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.

◆ matrix_multiplication() [2/4]

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.

◆ matrix_multiplication() [3/4]

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.

◆ matrix_multiplication() [4/4]

Matrix<T> genesis::utils::matrix_multiplication ( Matrix< A > const &  matrix,
B const &  scalar 
)

Calculate the element-wise multiplication of a Matrix and a scalar.

Definition at line 622 of file math/matrix.hpp.

◆ matrix_row_minmax()

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.

◆ matrix_row_sums()

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.

◆ matrix_sort_by_col_sum_symmetric()

Matrix<T> genesis::utils::matrix_sort_by_col_sum_symmetric ( Matrix< T > const &  data)

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.

◆ matrix_sort_by_row_sum_symmetric()

Matrix<T> genesis::utils::matrix_sort_by_row_sum_symmetric ( Matrix< T > const &  data)

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.

◆ matrix_sort_diagonal_symmetric()

Matrix<T> genesis::utils::matrix_sort_diagonal_symmetric ( Matrix< T > const &  data)

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.

◆ matrix_subtraction()

Matrix<T> genesis::utils::matrix_subtraction ( Matrix< A > const &  a,
Matrix< B > const &  b 
)

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.

◆ matrix_sum()

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.

◆ max_bin()

size_t max_bin ( const Histogram h)

Definition at line 63 of file utils/math/histogram/stats.cpp.

◆ max_value()

double max_value ( const Histogram h)

Definition at line 53 of file utils/math/histogram/stats.cpp.

◆ maximum()

double genesis::utils::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 179 of file statistics.hpp.

◆ maximum_distance() [1/2]

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 404 of file distance.hpp.

◆ maximum_distance() [2/2]

double genesis::utils::maximum_distance ( std::vector< double > const &  vec_a,
std::vector< double > const &  vec_b 
)
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 422 of file distance.hpp.

◆ maximum_distance_matrix()

Matrix< double > maximum_distance_matrix ( Matrix< double > const &  data)

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.

◆ maximum_norm() [1/2]

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.

◆ maximum_norm() [2/2]

double genesis::utils::maximum_norm ( std::vector< double > const &  vec)
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.

◆ mean()

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.

◆ mean_squared_error()

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.

See also
simple_linear_regression() for calculating such a fit.

Definition at line 125 of file slr.hpp.

◆ mean_stddev() [1/2]

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 - a standard deviation can never be below 0.0.

See also
mean_stddev( std::vector<double> const&, double epsilon ) for a version for std::vector.
arithmetic_mean() for a function that only calculates the mean, and thus saves the effort of a second iteration over the range.

Definition at line 327 of file statistics.hpp.

◆ mean_stddev() [2/2]

MeanStddevPair genesis::utils::mean_stddev ( std::vector< double > const &  vec,
double  epsilon = -1.0 
)
inline

Calculate the mean and standard deviation of a std::vector of double elements.

See also
mean_stddev( ForwardIterator first, ForwardIterator last, double epsilon ) for details.
arithmetic_mean() for a function that only calculates the mean, and thus saves the effort of a second iteration over the range.

Definition at line 382 of file statistics.hpp.

◆ median() [1/3]

double median ( const Histogram h)

Definition at line 68 of file utils/math/histogram/stats.cpp.

◆ median() [2/3]

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 676 of file statistics.hpp.

◆ median() [3/3]

double genesis::utils::median ( std::vector< double > const &  vec)
inline

Calculate the median value of a vector of double.

The vector has to be sorted.

Definition at line 712 of file statistics.hpp.

◆ min_bin()

size_t min_bin ( const Histogram h)

Definition at line 58 of file utils/math/histogram/stats.cpp.

◆ min_value()

double min_value ( const Histogram h)

Definition at line 48 of file utils/math/histogram/stats.cpp.

◆ minimal_layout()

TableLayout minimal_layout ( )

Definition at line 439 of file utils/text/table.cpp.

◆ minimum()

double genesis::utils::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 147 of file statistics.hpp.

◆ minimum_maximum()

MinMaxPair<double> genesis::utils::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 211 of file statistics.hpp.

◆ minmax_value() [1/2]

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 112 of file algorithm.hpp.

◆ minmax_value() [2/2]

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 121 of file algorithm.hpp.

◆ multi_dimensional_scaling() [1/2]

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.

See also
multi_dimensional_scaling() for details on the function, its parameters, and the license of the implementation.

Definition at line 231 of file mds.cpp.

◆ multi_dimensional_scaling() [2/2]

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.

Definition at line 262 of file mds.cpp.

◆ multi_dimensional_scaling_smacof()

static Matrix<double> genesis::utils::multi_dimensional_scaling_smacof ( Matrix< double > const &  distances,
Matrix< double > const &  initial_values,
size_t  dimensions,
size_t  iterations 
)
static

Definition at line 155 of file mds.cpp.

◆ multi_dimensional_scaling_ucf()

static Matrix<double> genesis::utils::multi_dimensional_scaling_ucf ( Matrix< double > const &  distances,
Matrix< double > const &  initial_values,
size_t  dimensions,
size_t  iterations 
)
static

Definition at line 63 of file mds.cpp.

◆ normalize()

void normalize ( Histogram h,
double  total 
)

Definition at line 61 of file operations.cpp.

◆ normalize_cols()

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().

Parameters
dataInput data Matrix; normalization is done inline.
Returns
Vector containing the min and max values for each column before normalization.

Definition at line 52 of file math/matrix.cpp.

◆ normalize_rows()

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().

Parameters
dataInput data Matrix; normalization is done inline.
Returns
Vector containing the min and max values for each row before normalization.

Definition at line 71 of file math/matrix.cpp.

◆ offset()

void offset ( Histogram h,
double  value 
)

Definition at line 47 of file operations.cpp.

◆ operator!=() [1/5]

bool genesis::utils::operator!= ( NexusTaxa const &  lhs,
NexusTaxa const &  rhs 
)

Definition at line 105 of file taxa.hpp.

◆ operator!=() [2/5]

bool genesis::utils::operator!= ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator!=() [3/5]

bool genesis::utils::operator!= ( JsonDocument const &  v,
std::nullptr_t   
)

◆ operator!=() [4/5]

bool genesis::utils::operator!= ( std::nullptr_t  ,
JsonDocument const &  v 
)

◆ operator!=() [5/5]

bool genesis::utils::operator!= ( Color const &  lhs,
Color const &  rhs 
)
inline

Definition at line 218 of file color.hpp.

◆ operator&() [1/3]

Bitvector genesis::utils::operator & ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Definition at line 43 of file utils/math/bitvector/operators.cpp.

◆ operator&() [2/3]

Bitvector genesis::utils::operator & ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Definition at line 43 of file utils/math/bitvector/operators.cpp.

◆ operator&() [3/3]

bool genesis::utils::operator & ( SkipWhitespace  lhs,
SkipWhitespace  rhs 
)
inline

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 95 of file scanner.hpp.

◆ operator<() [1/3]

bool genesis::utils::operator< ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator<() [2/3]

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:

  • If lhs and rhs have the same type, the values are compared using the default < operator.
  • Integer and floating-point numbers are automatically converted before comparison
  • In case lhs and rhs have different types, the values are ignored and the order of the types is considered, see operator<(const JsonDocument::ValueType, const JsonDocument::ValueType). %

Definition at line 793 of file json/document.cpp.

◆ operator<() [3/3]

bool genesis::utils::operator< ( const JsonDocument::ValueType  lhs,
const JsonDocument::ValueType  rhs 
)

Returns an ordering that is similar to Python:

  • order: null < boolean < number < object < array < string
  • furthermore, each type is not smaller than itself %

Definition at line 859 of file json/document.cpp.

◆ operator<<() [1/12]

std::ostream & operator<< ( std::ostream &  os,
const Histogram h 
)

Definition at line 45 of file utils/math/histogram/operators.cpp.

◆ operator<<() [2/12]

std::ostream & operator<< ( std::ostream &  os,
const HistogramAccumulator h 
)

Definition at line 59 of file utils/math/histogram/operators.cpp.

◆ operator<<() [3/12]

std::ostream& genesis::utils::operator<< ( std::ostream &  os,
NexusBlock const &  block 
)
inline

Definition at line 80 of file block.hpp.

◆ operator<<() [4/12]

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.

◆ operator<<() [5/12]

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.

◆ operator<<() [6/12]

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/tools/color/functions.cpp.

◆ operator<<() [7/12]

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 155 of file utils/math/bitvector/operators.cpp.

◆ operator<<() [8/12]

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 175 of file utils/containers/matrix/operators.hpp.

◆ operator<<() [9/12]

std::ostream & operator<< ( std::ostream &  out,
Table const &  table 
)

Definition at line 255 of file utils/text/table.cpp.

◆ operator<<() [10/12]

std::ostream & operator<< ( std::ostream &  os,
GeoCoordinate const &  coord 
)

Definition at line 344 of file utils/tools/geodesy/functions.cpp.

◆ operator<<() [11/12]

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.

Definition at line 380 of file style.cpp.

◆ operator<<() [12/12]

std::ostream& genesis::utils::operator<< ( std::ostream &  out,
TableLayout::Binder const &  binder 
)

Definition at line 405 of file utils/text/table.cpp.

◆ operator<=()

bool genesis::utils::operator<= ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator==() [1/6]

bool genesis::utils::operator== ( NexusTaxa const &  lhs,
NexusTaxa const &  rhs 
)

Definition at line 100 of file taxa.hpp.

◆ operator==() [2/6]

bool genesis::utils::operator== ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator==() [3/6]

bool genesis::utils::operator== ( JsonDocument const &  v,
std::nullptr_t   
)

◆ operator==() [4/6]

bool genesis::utils::operator== ( std::nullptr_t  ,
JsonDocument const &  v 
)

◆ operator==() [5/6]

bool genesis::utils::operator== ( Color const &  lhs,
Color const &  rhs 
)
inline

Definition at line 206 of file color.hpp.

◆ operator==() [6/6]

bool genesis::utils::operator== ( JsonDocument::const_reference  lhs,
JsonDocument::const_reference  rhs 
)

Compares two JSON values for equality according to the following rules:

  • Two JSON values are equal if (1) they are from the same type and (2) their stored values are the same.
  • Integer and floating-point numbers are automatically converted before comparison. Floating-point numbers are compared indirectly: two floating-point numbers f1 and f2 are considered equal if neither f1 > f2 nor f2 > f1 holds.
  • Two JSON null values are equal. %

Definition at line 730 of file json/document.cpp.

◆ operator>()

bool genesis::utils::operator> ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator>=()

bool genesis::utils::operator>= ( JsonDocument const &  lhs,
JsonDocument const &  rhs 
)

◆ operator>>()

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 163 of file utils/math/bitvector/operators.cpp.

◆ operator^()

Bitvector operator^ ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Definition at line 73 of file utils/math/bitvector/operators.cpp.

◆ operator|()

Bitvector operator| ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Definition at line 58 of file utils/math/bitvector/operators.cpp.

◆ p_norm() [1/2]

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.

See also
euclidean_norm(), manhattan_norm(), and maximum_norm() for special cases, which simply call this function with a fixed p, in order to make code more expressive.
aitchison_norm() for another type of norm.

Definition at line 70 of file distance.hpp.

◆ p_norm() [2/2]

double genesis::utils::p_norm ( std::vector< double > const &  vec,
double  p = 2.0 
)
inline

Calculate the p-norm of a std::vector of double elements.

See also
p_norm( ForwardIterator, ForwardIterator, double ) for details.
aitchison_norm() for another type of norm.

Definition at line 119 of file distance.hpp.

◆ p_norm_distance() [1/2]

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.

See also
euclidean_distance(), manhattan_distance(), and maximum_distance() for special cases, which simply call this function with a fixed p, in order to make code more expressive.

Definition at line 287 of file distance.hpp.

◆ p_norm_distance() [2/2]

double genesis::utils::p_norm_distance ( std::vector< double > const &  vec_a,
std::vector< double > const &  vec_b,
double  p = 2.0 
)
inline

Calculate the p-norm distance between two vectors of double elements.

See also
p_norm_distance( ForwardIteratorA, ForwardIteratorA, ForwardIteratorB, ForwardIteratorB, double ) for details.

Definition at line 333 of file distance.hpp.

◆ p_norm_distance_matrix()

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.

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.

See also
manhattan_distance_matrix(), euclidean_distance_matrix(), and maximum_distance_matrix() for specialized versions of this function with a fixed p for more expressive code.

Definition at line 48 of file distance.cpp.

◆ parse_float()

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]

The function stops reading at the first non-fitting digit. 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 155 of file parser.hpp.

◆ parse_integer()

T genesis::utils::parse_integer ( utils::InputStream source)

Alias for parse_signed_integer().

Definition at line 134 of file parser.hpp.

◆ parse_number_string()

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 48 of file parser.cpp.

◆ parse_quoted_string()

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.

Parameters
sourceStream to read from.
use_escapesIf 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_quotesIf 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_qmarksThe optional parameter include_qmarks demtermines whether the quotation marks are included in the output or not. Default is false.

Definition at line 116 of file parser.cpp.

◆ parse_signed_integer()

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 91 of file parser.hpp.

◆ parse_unsigned_integer()

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 56 of file parser.hpp.

◆ path_exists()

bool path_exists ( std::string const &  path)

Return whether a path exists, i.e., is a file or directory.

Definition at line 65 of file fs.cpp.

◆ pearson_correlation_coefficient() [1/2]

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 871 of file statistics.hpp.

◆ pearson_correlation_coefficient() [2/2]

double genesis::utils::pearson_correlation_coefficient ( std::vector< double > const &  vec_a,
std::vector< double > const &  vec_b 
)
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 915 of file statistics.hpp.

◆ principal_component_analysis()

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.

Parameters
dataMatrix with the data, samples in rows, features in columns.
componentsIntended number of PCA components to calculate. If 0 (default), all PCA components are calculated, i.e., as many components as data has columns.
standardizationIndicate the standardization algorithm to perfom on the data before calculating the PCA components, see PcaStandardization.
Returns
A struct that contains the eigenvalues and corresponding eigenvectors (i.e., the PCA components), and a Matrix with the projected data. See PcaData for details.

Definition at line 260 of file pca.cpp.

◆ print() [1/2]

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 206 of file utils/containers/matrix/operators.hpp.

◆ print() [2/2]

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 243 of file utils/containers/matrix/operators.hpp.

◆ print_byte_matrix_()

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.

◆ qualitative_color_list() [1/2]

std::vector< Color > const & qualitative_color_list ( QualitativeColorList  palette)

Definition at line 202 of file qualitative_lists.cpp.

◆ qualitative_color_list() [2/2]

std::vector< Color > const & qualitative_color_list ( std::string const &  palette)

Definition at line 232 of file qualitative_lists.cpp.

◆ qualitative_color_list_names()

std::vector< std::string > qualitative_color_list_names ( )

Definition at line 264 of file qualitative_lists.cpp.

◆ quartile_coefficient_of_dispersion() [1/2]

double genesis::utils::quartile_coefficient_of_dispersion ( Quartiles const &  q)
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 837 of file statistics.hpp.

◆ quartile_coefficient_of_dispersion() [2/2]

std::vector<double> genesis::utils::quartile_coefficient_of_dispersion ( std::vector< Quartiles > const &  q)
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 845 of file statistics.hpp.

◆ quartiles() [1/2]

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 728 of file statistics.hpp.

◆ quartiles() [2/2]

Quartiles genesis::utils::quartiles ( std::vector< double > const &  vec)
inline

Calculate the Quartiles of a vector of double.

The vector has to be sorted.

Definition at line 770 of file statistics.hpp.

◆ ranking_dense() [1/2]

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.

See also
ranking_standard(), ranking_modified(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 167 of file ranking.hpp.

◆ ranking_dense() [2/2]

std::vector<size_t> genesis::utils::ranking_dense ( std::vector< double > const &  vec)
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.

See also
ranking_standard(), ranking_modified(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 199 of file ranking.hpp.

◆ ranking_fractional() [1/2]

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.

See also
ranking_standard(), ranking_modified(), ranking_dense(), ranking_ordinal() for other ranking methods.

Definition at line 260 of file ranking.hpp.

◆ ranking_fractional() [2/2]

std::vector<double> genesis::utils::ranking_fractional ( std::vector< double > const &  vec)
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.

See also
ranking_standard(), ranking_modified(), ranking_dense(), ranking_ordinal() for other ranking methods.

Definition at line 317 of file ranking.hpp.

◆ ranking_modified() [1/2]

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.

See also
ranking_standard(), ranking_dense(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 110 of file ranking.hpp.

◆ ranking_modified() [2/2]

std::vector<size_t> genesis::utils::ranking_modified ( std::vector< double > const &  vec)
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.

See also
ranking_standard(), ranking_dense(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 149 of file ranking.hpp.

◆ ranking_ordinal() [1/2]

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.

See also
ranking_standard(), ranking_modified(), ranking_dense(), ranking_fractional() for other ranking methods.

Definition at line 217 of file ranking.hpp.

◆ ranking_ordinal() [2/2]

std::vector<size_t> genesis::utils::ranking_ordinal ( std::vector< double > const &  vec)
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.

See also
ranking_standard(), ranking_modified(), ranking_dense(), ranking_fractional() for other ranking methods.

Definition at line 240 of file ranking.hpp.

◆ ranking_standard() [1/2]

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.

See also
ranking_modified(), ranking_dense(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 59 of file ranking.hpp.

◆ ranking_standard() [2/2]

std::vector<size_t> genesis::utils::ranking_standard ( std::vector< double > const &  vec)
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.

See also
ranking_modified(), ranking_dense(), ranking_ordinal(), ranking_fractional() for other ranking methods.

Definition at line 91 of file ranking.hpp.

◆ read_char_or_throw() [1/2]

char genesis::utils::read_char_or_throw ( InputStream source,
char  criterion,
SkipWhitespace  skip_ws = SkipWhitespace::kNone 
)
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 297 of file scanner.hpp.

◆ read_char_or_throw() [2/2]

char genesis::utils::read_char_or_throw ( InputStream source,
std::function< bool(char)>  criterion,
SkipWhitespace  skip_ws = SkipWhitespace::kNone 
)
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 336 of file scanner.hpp.

◆ read_to_end_of_line()

std::string genesis::utils::read_to_end_of_line ( InputStream source)
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 132 of file scanner.hpp.

◆ read_until() [1/2]

std::string genesis::utils::read_until ( InputStream source,
char  criterion 
)
inline

Lexing function that reads from the stream until its current char equals the provided one. The read chars are returned.

Definition at line 252 of file scanner.hpp.

◆ read_until() [2/2]

std::string genesis::utils::read_until ( InputStream source,
std::function< bool(char)>  criterion 
)
inline

Lexing function that reads from the stream until its current char fulfills the provided criterion. The read chars are returned.

Definition at line 269 of file scanner.hpp.

◆ read_while() [1/2]

std::string genesis::utils::read_while ( InputStream source,
char  criterion 
)
inline

Lexing function that reads from the stream while its current char equals the provided one. The read chars are returned.

Definition at line 214 of file scanner.hpp.

◆ read_while() [2/2]

std::string genesis::utils::read_while ( InputStream source,
std::function< bool(char)>  criterion 
)
inline

Lexing function that reads from the stream while its current char fulfills the provided criterion. The read chars are returned.

Definition at line 231 of file scanner.hpp.

◆ readlink_internal_()

static bool genesis::utils::readlink_internal_ ( const std::string &  path,
std::string &  buffer,
ssize_t  length 
)
static

Definition at line 472 of file fs.cpp.

◆ real_path()

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.

Definition at line 611 of file fs.cpp.

◆ real_path_realpath_()

static std::string genesis::utils::real_path_realpath_ ( std::string const &  path,
bool  resolve_link 
)
static

Definition at line 594 of file fs.cpp.

◆ real_path_unix_()

static std::string genesis::utils::real_path_unix_ ( std::string const &  path,
bool  resolve_link 
)
static

Definition at line 560 of file fs.cpp.

◆ realpath_file_()

static std::string genesis::utils::realpath_file_ ( const std::string &  path)
static

Definition at line 461 of file fs.cpp.

◆ reduce_to_tridiagonal_matrix()

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.

Parameters
dataInput data matrix. Operations are performed inline, that is, the matrix is changed during execution of the function.

Definition at line 49 of file pca.cpp.

◆ relative_dir_base_split_()

static void genesis::utils::relative_dir_base_split_ ( std::string const &  path,
std::string &  dir,
std::string &  base 
)
static

Definition at line 415 of file fs.cpp.

◆ repeat()

std::string repeat ( std::string const &  word,
size_t  times 
)

Take a string and repeat it a given number of times.

Definition at line 416 of file string.cpp.

◆ replace_all()

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 278 of file string.cpp.

◆ replace_all_chars()

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 312 of file string.cpp.

◆ resolve_color_string()

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_to_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/tools/color/functions.cpp.

◆ round_to()

double genesis::utils::round_to ( double  x,
size_t  accuracy_order 
)
inline

Retun the value of x, rounded to the decimal digit given by accuracy_order.

Definition at line 136 of file common.hpp.

◆ sanitize_filename()

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:

  • All non-printable characters are removed.
  • Spaces at the beginning and end are removed.
  • All invalid chars are replaced by an underscore. See is_valid_filename() for a list of those chars.

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.

Definition at line 726 of file fs.cpp.

◆ sanitize_geo_coordinate()

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.

◆ scale()

void scale ( Histogram h,
double  factor 
)

Definition at line 54 of file operations.cpp.

◆ select_without_replacement()

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.

Parameters
kDesired sample size.
nTotal population size.
Returns
List of k unique numbers out of the range [ 0, n ).

Definition at line 46 of file random.cpp.

◆ sequential_color_list() [1/2]

std::vector< Color > const & sequential_color_list ( SequentialColorList  palette)

Definition at line 1530 of file sequential_lists.cpp.

◆ sequential_color_list() [2/2]

std::vector< Color > const & sequential_color_list ( std::string const &  palette)

Definition at line 1608 of file sequential_lists.cpp.

◆ sequential_color_list_names()

std::vector< std::string > sequential_color_list_names ( )

Definition at line 1688 of file sequential_lists.cpp.

◆ set_minus()

Bitvector set_minus ( Bitvector const &  lhs,
Bitvector const &  rhs 
)

Definition at line 125 of file utils/math/bitvector/operators.cpp.

◆ sigma()

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.

◆ signum() [1/3]

constexpr int genesis::utils::signum ( x,
std::false_type   
)
inline

Implementation of signum(T x) for unsigned types. See there for details.

Definition at line 81 of file common.hpp.

◆ signum() [2/3]

constexpr int genesis::utils::signum ( x,
std::true_type   
)
inline

Implementation of signum(T x) for signed types. See there for details.

Definition at line 93 of file common.hpp.

◆ signum() [3/3]

constexpr int genesis::utils::signum ( x)
inline

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 110 of file common.hpp.

◆ simple_frame()

TableLayout simple_frame ( bool  condensed)

Definition at line 483 of file utils/text/table.cpp.

◆ simple_grid()

TableLayout simple_grid ( bool  condensed)

Definition at line 464 of file utils/text/table.cpp.

◆ simple_layout()

TableLayout simple_layout ( bool  condensed)

Definition at line 445 of file utils/text/table.cpp.

◆ simple_linear_regression()

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.

See also
mean_squared_error() for calculating the resulting error.

Definition at line 74 of file slr.hpp.

◆ skip_to_end_of_line()

void genesis::utils::skip_to_end_of_line ( InputStream source)
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 116 of file scanner.hpp.

◆ skip_until() [1/2]

void genesis::utils::skip_until ( InputStream source,
char  criterion 
)
inline

Lexing function that advances the stream until its current char equals the provided one.

Definition at line 182 of file scanner.hpp.

◆ skip_until() [2/2]

void genesis::utils::skip_until ( InputStream source,
std::function< bool(char)>  criterion 
)
inline

Lexing function that advances the stream until its current char fulfills the provided criterion.

Definition at line 196 of file scanner.hpp.

◆ skip_while() [1/2]

void genesis::utils::skip_while ( InputStream source,
char  criterion 
)
inline

Lexing function that advances the stream while its current char equals the provided one.

Definition at line 151 of file scanner.hpp.

◆ skip_while() [2/2]

void genesis::utils::skip_while ( InputStream source,
std::function< bool(char)>  criterion 
)
inline

Lexing function that advances the stream while its current char fulfills the provided criterion.

Definition at line 165 of file scanner.hpp.

◆ sort_indices() [1/2]