A library for working with phylogenetic and population genetic data.
v0.32.0
math/matrix.hpp File Reference
#include "genesis/utils/containers/matrix.hpp"
#include "genesis/utils/math/statistics.hpp"
#include <cmath>
#include <limits>
#include <vector>

Go to the source code of this file.

Namespaces

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

Functions

Matrix< double > correlation_matrix (Matrix< double > const &data)
 Calculate the correlation Matrix of a given data Matrix. More...
 
Matrix< double > covariance_matrix (Matrix< double > const &data)
 Calculate the covariance Matrix of a given data Matrix. 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<typename T = double, typename A = double, typename B = double>
Matrix< T > matrix_addition (Matrix< A > const &a, Matrix< B > const &b)
 Calculate the element-wise sum of two Matrices. More...
 
template<typename T = double, typename A = double, typename B = double>
Matrix< T > matrix_addition (Matrix< A > const &matrix, B const &scalar)
 Calculate the element-wise sum of a Matrix and a scalar. More...
 
template<typename T >
std::vector< MinMaxPair< T > > matrix_col_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the column-wise min and max values of a Matrix. More...
 
template<typename T >
std::vector< T > matrix_col_sums (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the sum of each column and return the result as a vector. More...
 
template<typename T >
MinMaxPair< T > matrix_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the min and max values of a Matrix. More...
 
template<typename T = double, typename A = double, typename B = double>
Matrix< T > matrix_multiplication (Matrix< A > const &a, Matrix< B > const &b)
 Calculate the product of two Matrices. More...
 
template<typename T = double, typename A = double, typename B = double>
std::vector< T > matrix_multiplication (Matrix< A > const &a, std::vector< B > const &b)
 Calculate the product of a Matrices a with a vector b, as if the vector was a Matrix with only one column. More...
 
template<typename T = double, typename A = double, typename B = double>
Matrix< T > matrix_multiplication (Matrix< A > const &matrix, B const &scalar)
 Calculate the element-wise multiplication of a Matrix and a scalar. More...
 
template<typename T = double, typename A = double, typename B = double>
std::vector< T > matrix_multiplication (std::vector< A > const &a, Matrix< B > const &b)
 Calculate the product of a vector a with a Matrices b, as if the vector was a Matrix with only one row. More...
 
template<typename T >
std::vector< MinMaxPair< T > > matrix_row_minmax (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the row-wise min and max values of a Matrix. More...
 
template<typename T >
std::vector< T > matrix_row_sums (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the sum of each row and return the result as a vector. More...
 
template<typename T >
Matrix< T > matrix_sort_by_col_sum_symmetric (Matrix< T > const &data)
 Sort rows and columns of a Matrix by the sum or the columns. More...
 
template<typename T >
Matrix< T > matrix_sort_by_row_sum_symmetric (Matrix< T > const &data)
 Sort rows and columns of a Matrix by the sum or the rows. More...
 
template<typename T >
Matrix< T > matrix_sort_diagonal_symmetric (Matrix< T > const &data)
 Sort a Matrix so that the highest entries are on the diagonal. More...
 
template<typename T = double, typename A = double, typename B = double>
Matrix< T > matrix_subtraction (Matrix< A > const &a, Matrix< B > const &b)
 Calculate the element-wise difference of two Matrices. More...
 
template<typename T >
matrix_sum (Matrix< T > const &data, bool ignore_non_finite_values=true)
 Calculate the sum of all elements in a Matrix. More...
 
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...
 
std::vector< MeanStddevPair > standardize_cols (Matrix< double > &data, bool scale_means=true, bool scale_std=true)
 Standardize the columns of a Matrix by subtracting the mean and scaling to unit variance. More...
 
std::vector< MeanStddevPair > standardize_rows (Matrix< double > &data, bool scale_means=true, bool scale_std=true)
 Standardize the rows of a Matrix by subtracting the mean and scaling to unit variance. More...
 
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...