A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
common.hpp File Reference
#include <cmath>
#include <limits>
#include <stdexcept>
#include <vector>

Go to the source code of this file.

Classes

struct  MeanStddevPair
 Store a mean and a standard deviation value. More...
 
struct  MinMaxPair< T >
 Store a pair of min and max values. More...
 
struct  Quartiles
 Store the values of quartiles: q0 == min, q1 == 25%, q2 == 50%, q3 == 75%, q4 == max. More...
 

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Functions

template<typename T >
constexpr T abs_diff (T const &lhs, T const &rhs)
 Calculate the absolute differenence between two values. 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...
 
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...
 
size_t int_pow (size_t base, size_t exp)
 Calculate the power base^exp for positive integer values. 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...
 
MeanStddevPair mean_stddev (std::vector< double > const &vec, double epsilon=-1.0)
 Calcualte the mean and standard deviation of a vector of double. More...
 
double median (std::vector< double > const &vec)
 Calculate the median value of a vector 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...
 
Quartiles quartiles (std::vector< double > const &vec)
 Calculate the Quartiles of a vector of double. More...
 
std::vector< size_t > ranking_dense (std::vector< double > const &vec)
 Return the ranking of the given values, using Dense ranking ("1223" ranking). More...
 
std::vector< double > ranking_fractional (std::vector< double > const &vec)
 Return the ranking of the given values, using Fractional ranking ("1 2.5 2.5 4" ranking). More...
 
std::vector< size_t > ranking_modified (std::vector< double > const &vec)
 Return the ranking of the given values, using Modified competition ranking ("1334" ranking). More...
 
std::vector< size_t > ranking_ordinal (std::vector< double > const &vec)
 Return the ranking of the given values, using Ordinal ranking ("1234" ranking). More...
 
std::vector< size_t > ranking_standard (std::vector< double > const &vec)
 Return the ranking of the given values, using Standard competition ranking ("1224" ranking). 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...
 
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...
 
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...
 

Variables

constexpr double PI = 3.141592653589793238463
 Make the world go round. More...