|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Lightweight dense real-matrix utilities built on top of STL storage and GSL backends. More...
#include <gsl/gsl_matrix.h>#include <gsl/gsl_linalg.h>#include <gsl/gsl_eigen.h>#include <vector>#include <array>#include <memory>#include <stdexcept>#include <algorithm>#include "../special/special_generic.h"

Go to the source code of this file.
Classes | |
| struct | SignedLogDet |
| Signed logarithmic determinant representation. More... | |
| class | RealMatrix |
| Dense real-valued matrix with STL storage and GSL-backed linear algebra. More... | |
| struct | EigenSystem |
| Container for an eigendecomposition. More... | |
Typedefs | |
| using | Vector = std::vector< double > |
| Convenient alias for a dense vector of real values. | |
| using | gsl_matrix_sptr = std::unique_ptr< gsl_matrix, decltype(&gsl_matrix_free)> |
| Owning smart pointer for a GSL matrix. | |
| using | gsl_vector_sptr = std::unique_ptr< gsl_vector, decltype(&gsl_vector_free)> |
| Owning smart pointer for a GSL vector. | |
| using | gsl_permutation_sptr = std::unique_ptr< gsl_permutation, decltype(&gsl_permutation_free)> |
| Owning smart pointer for a GSL permutation. | |
| using | gsl_eigen_workspace_sptr = std::unique_ptr< gsl_eigen_symmv_workspace, decltype(&gsl_eigen_symmv_free)> |
| Owning smart pointer for a GSL symmetric-eigensystem workspace. | |
Functions | |
| gsl_matrix_sptr | make_gsl_matrix (size_t rows, size_t cols) |
| Allocates a GSL matrix with automatic RAII destruction. | |
| gsl_vector_sptr | make_gsl_vector (size_t size) |
| Allocates a GSL vector with automatic RAII destruction. | |
| gsl_permutation_sptr | make_gsl_permutation (size_t size) |
| Allocates a GSL permutation with automatic RAII destruction. | |
| gsl_eigen_workspace_sptr | make_eigen_workspace (size_t n) |
| Allocates a GSL symmetric eigensolver workspace with RAII destruction. | |
| RealMatrix | eye (std::size_t n) |
Returns the identity matrix of size n. | |
| RealMatrix | diag (const gsl_vector *X) |
| Builds a diagonal matrix from a GSL vector. | |
| RealMatrix | nearest_psd (RealMatrix R, double thr=1e-12) |
| Projects a matrix to the nearest positive semi-definite correlation-like matrix. | |
| RealMatrix | cholesky_L (RealMatrix R) |
| Returns the lower-triangular Cholesky factor of a PSD matrix. | |
| RealMatrix | block_diag (const std::vector< RealMatrix > &blocks) |
| Builds a block-diagonal matrix from several square blocks. | |
| template<typename... Ms> | |
| RealMatrix | block_diag (const Ms &... ms) |
| Variadic convenience overload for block_diag. | |
Lightweight dense real-matrix utilities built on top of STL storage and GSL backends.
This file provides:
Design goals:
std::vector<double> row-major storage,Storage convention:
(i,j) is stored at data[i * cols + j].Definition in file Matrix.h.
| using gsl_eigen_workspace_sptr = std::unique_ptr<gsl_eigen_symmv_workspace, decltype(&gsl_eigen_symmv_free)> |
| using gsl_matrix_sptr = std::unique_ptr<gsl_matrix, decltype(&gsl_matrix_free)> |
| using gsl_permutation_sptr = std::unique_ptr<gsl_permutation, decltype(&gsl_permutation_free)> |
| using gsl_vector_sptr = std::unique_ptr<gsl_vector, decltype(&gsl_vector_free)> |
| using Vector = std::vector<double> |
| RealMatrix block_diag | ( | const Ms &... | ms | ) |
Variadic convenience overload for block_diag.
| Ms | Matrix-like arguments convertible to RealMatrix. |
| ms | Input blocks. |
| RealMatrix block_diag | ( | const std::vector< RealMatrix > & | blocks | ) |
Builds a block-diagonal matrix from several square blocks.
| blocks | List of square matrices. |
| std::invalid_argument | if one input block is not square. |
Definition at line 529 of file Matrix.cpp.
| RealMatrix cholesky_L | ( | RealMatrix | R | ) |
Returns the lower-triangular Cholesky factor of a PSD matrix.
If R = L L^T, this function returns L.
| R | Input matrix. |
| std::invalid_argument | if the matrix is not square. |
| std::runtime_error | if Cholesky decomposition fails. |
Definition at line 508 of file Matrix.cpp.
| RealMatrix diag | ( | const gsl_vector * | X | ) |
Builds a diagonal matrix from a GSL vector.
| X | Input vector. |
X. Definition at line 464 of file Matrix.cpp.
| RealMatrix eye | ( | std::size_t | n | ) |
Returns the identity matrix of size n.
| n | Matrix dimension. |
n × n identity matrix. Definition at line 453 of file Matrix.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
| RealMatrix nearest_psd | ( | RealMatrix | R, |
| double | thr = 1e-12 |
||
| ) |
Projects a matrix to the nearest positive semi-definite correlation-like matrix.
Algorithm:
thr,This is especially useful for repairing numerically inconsistent correlation matrices.
| R | Input matrix. |
| thr | Lower bound applied to eigenvalues during clipping. |
| std::invalid_argument | if the matrix is not square. |
Definition at line 475 of file Matrix.cpp.