|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Dense real-valued matrix with STL storage and GSL-backed linear algebra. More...
#include <Matrix.h>
Public Member Functions | |
| RealMatrix () | |
| Constructs an empty 0×0 matrix. | |
| RealMatrix (std::vector< double > data_, std::size_t rows, std::size_t cols) | |
| Constructs a matrix from flat row-major data. | |
| RealMatrix (std::vector< std::vector< double > > data_) | |
| Constructs a matrix from nested row vectors. | |
| RealMatrix (std::size_t rows, std::size_t cols) | |
| Constructs a zero-initialized matrix of given shape. | |
| double & | at (size_t i, size_t j) |
Returns a mutable reference to element (i,j) with bounds checking. | |
| double & | unchecked_at (size_t i, size_t j) |
Returns a mutable reference to element (i,j) without bounds checking. | |
| const double & | at (size_t i, size_t j) const |
Returns a const reference to element (i,j) with bounds checking. | |
| const double & | unchecked_at (size_t i, size_t j) const |
Returns a const reference to element (i,j) without bounds checking. | |
| std::size_t | rows () const |
| Returns the number of rows. | |
| std::size_t | cols () const |
| Returns the number of columns. | |
| void | remove_row (std::size_t row_idx) |
| Removes one row from the matrix. | |
| void | remove_column (std::size_t col_idx) |
| Removes one column from the matrix. | |
| void | remove_row_and_column (std::size_t dim_idx) |
| Removes one row and one column with the same index. | |
| gsl_matrix_sptr | to_gsl_matrix () const |
| Converts this matrix to a newly allocated GSL matrix. | |
| bool | is_symmetric () const |
| Checks whether the matrix is symmetric. | |
| RealMatrix | transpose () const |
| Returns the transpose of the matrix. | |
| EigenSystem | eig () const |
| Computes the eigensystem of a symmetric matrix. | |
| SignedLogDet | slogdet () const |
| Computes the signed logarithmic determinant via LU decomposition. | |
| RealMatrix | inv () const |
| Computes the inverse of the matrix via LU decomposition. | |
| RealMatrix | operator- () const |
| Unary minus. | |
| RealMatrix & | operator+= (const RealMatrix &rhs) |
| In-place matrix addition. | |
| RealMatrix & | operator-= (const RealMatrix &rhs) |
| In-place matrix subtraction. | |
| RealMatrix & | operator*= (const RealMatrix &rhs) |
| In-place matrix multiplication. | |
| RealMatrix & | operator*= (double scalar) |
| In-place scalar multiplication. | |
| RealMatrix & | operator/= (double scalar) |
| In-place scalar division. | |
Static Public Member Functions | |
| static RealMatrix | from_gsl_copy (const gsl_matrix *A) |
| Creates a RealMatrix by copying data from a GSL matrix. | |
Public Attributes | |
| Number = Union[int, float] | |
| NestedList = Sequence[Sequence[Number]] | |
Friends | |
| RealMatrix | operator+ (RealMatrix lhs, const RealMatrix &rhs) |
| Matrix addition. | |
| RealMatrix | operator- (RealMatrix lhs, const RealMatrix &rhs) |
| Matrix subtraction. | |
| RealMatrix | operator* (RealMatrix lhs, const RealMatrix &rhs) |
| Matrix product. | |
| RealMatrix | operator* (RealMatrix lhs, double scalar) |
| Right scalar multiplication. | |
| RealMatrix | operator* (double scalar, RealMatrix rhs) |
| Left scalar multiplication. | |
| RealMatrix | operator/ (RealMatrix lhs, double scalar) |
| Scalar division. | |
| std::ostream & | operator<< (std::ostream &os, RealMatrix A) |
| Stream output helper. | |
Dense real-valued matrix with STL storage and GSL-backed linear algebra.
RealMatrix is a small utility class representing a dense matrix of double-precision real numbers. It stores data in a single contiguous std::vector<double> in row-major order.
Features include:
The class is intentionally lightweight and does not attempt to be a full linear algebra framework.
|
inline |
| RealMatrix::RealMatrix | ( | std::vector< double > | data_, |
| std::size_t | rows, | ||
| std::size_t | cols | ||
| ) |
Constructs a matrix from flat row-major data.
| data_ | Flat row-major data buffer. |
| rows | Number of rows. |
| cols | Number of columns. |
| std::invalid_argument | if data_.size() != rows * cols. |
Definition at line 555 of file Matrix.cpp.
| RealMatrix::RealMatrix | ( | std::vector< std::vector< double > > | data_ | ) |
Constructs a matrix from nested row vectors.
| data_ | Matrix data as data_[row][col]. |
| std::invalid_argument | if the outer vector is empty or if rows do not all have the same length. |
Definition at line 560 of file Matrix.cpp.
| RealMatrix::RealMatrix | ( | std::size_t | rows, |
| std::size_t | cols | ||
| ) |
Constructs a zero-initialized matrix of given shape.
| rows | Number of rows. |
| cols | Number of columns. |
Definition at line 584 of file Matrix.cpp.
| double & RealMatrix::at | ( | size_t | i, |
| size_t | j | ||
| ) |
Returns a mutable reference to element (i,j) with bounds checking.
| i | Row index. |
| j | Column index. |
| std::out_of_range | if (i,j) lies outside the matrix shape. |
Definition at line 587 of file Matrix.cpp.
| const double & RealMatrix::at | ( | size_t | i, |
| size_t | j | ||
| ) | const |
Returns a const reference to element (i,j) with bounds checking.
| i | Row index. |
| j | Column index. |
| std::out_of_range | if (i,j) lies outside the matrix shape. |
Definition at line 594 of file Matrix.cpp.
| std::size_t RealMatrix::cols | ( | ) | const |
Returns the number of columns.
Definition at line 605 of file Matrix.cpp.
| EigenSystem RealMatrix::eig | ( | ) | const |
Computes the eigensystem of a symmetric matrix.
Uses GSL symmetric eigendecomposition and sorts eigenvalues in descending order.
D: diagonal matrix of eigenvalues,P: matrix of eigenvectors.| std::invalid_argument | if the matrix is not square. |
| std::runtime_error | if the matrix is not symmetric. |
Definition at line 710 of file Matrix.cpp.
|
static |
Creates a RealMatrix by copying data from a GSL matrix.
| A | Source GSL matrix. |
Definition at line 658 of file Matrix.cpp.
| RealMatrix RealMatrix::inv | ( | ) | const |
Computes the inverse of the matrix via LU decomposition.
| std::invalid_argument | if the matrix is not square. |
| std::runtime_error | if the matrix is singular. |
Definition at line 750 of file Matrix.cpp.
| bool RealMatrix::is_symmetric | ( | ) | const |
Checks whether the matrix is symmetric.
The check is exact up to the project helper fpeq(...).
Definition at line 684 of file Matrix.cpp.
| RealMatrix & RealMatrix::operator*= | ( | const RealMatrix & | rhs | ) |
In-place matrix multiplication.
Performs dense matrix multiplication using a blocked algorithm.
| rhs | Right-hand side matrix. |
*this.| std::invalid_argument | if inner dimensions do not match. |
Definition at line 815 of file Matrix.cpp.
| RealMatrix & RealMatrix::operator*= | ( | double | scalar | ) |
In-place scalar multiplication.
| scalar | Multiplicative factor. |
*this. Definition at line 856 of file Matrix.cpp.
| RealMatrix & RealMatrix::operator+= | ( | const RealMatrix & | rhs | ) |
In-place matrix addition.
| rhs | Right-hand side matrix. |
*this.| std::invalid_argument | if shapes differ. |
Definition at line 789 of file Matrix.cpp.
| RealMatrix RealMatrix::operator- | ( | ) | const |
Unary minus.
Definition at line 777 of file Matrix.cpp.
| RealMatrix & RealMatrix::operator-= | ( | const RealMatrix & | rhs | ) |
In-place matrix subtraction.
| rhs | Right-hand side matrix. |
*this.| std::invalid_argument | if shapes differ. |
Definition at line 802 of file Matrix.cpp.
| RealMatrix & RealMatrix::operator/= | ( | double | scalar | ) |
In-place scalar division.
| scalar | Divisor. |
*this.| std::invalid_argument | if scalar is numerically zero. |
Definition at line 863 of file Matrix.cpp.
| void RealMatrix::remove_column | ( | std::size_t | col_idx | ) |
Removes one column from the matrix.
All columns to the right of col_idx are shifted left by one.
| col_idx | Index of the column to remove. |
col_idx < cols(). It does not currently throw on invalid indices. Definition at line 624 of file Matrix.cpp.
| void RealMatrix::remove_row | ( | std::size_t | row_idx | ) |
Removes one row from the matrix.
All rows below row_idx are shifted up by one.
| row_idx | Index of the row to remove. |
row_idx < rows(). It does not currently throw on invalid indices. Definition at line 609 of file Matrix.cpp.
| void RealMatrix::remove_row_and_column | ( | std::size_t | dim_idx | ) |
Removes one row and one column with the same index.
This is useful for principal-submatrix extraction, e.g. when removing one nuisance direction from a covariance / correlation matrix.
| dim_idx | Index of the row and column to remove. |
cols()-1) and the shifted column index. Definition at line 639 of file Matrix.cpp.
| std::size_t RealMatrix::rows | ( | ) | const |
Returns the number of rows.
Definition at line 601 of file Matrix.cpp.
| SignedLogDet RealMatrix::slogdet | ( | ) | const |
Computes the signed logarithmic determinant via LU decomposition.
| std::invalid_argument | if the matrix is not square. |
Definition at line 731 of file Matrix.cpp.
| gsl_matrix_sptr RealMatrix::to_gsl_matrix | ( | ) | const |
Converts this matrix to a newly allocated GSL matrix.
Definition at line 672 of file Matrix.cpp.
| RealMatrix RealMatrix::transpose | ( | ) | const |
Returns the transpose of the matrix.
Definition at line 698 of file Matrix.cpp.
| double & RealMatrix::unchecked_at | ( | size_t | i, |
| size_t | j | ||
| ) |
Returns a mutable reference to element (i,j) without bounds checking.
| i | Row index. |
| j | Column index. |
Definition at line 873 of file Matrix.cpp.
| const double & RealMatrix::unchecked_at | ( | size_t | i, |
| size_t | j | ||
| ) | const |
Returns a const reference to element (i,j) without bounds checking.
| i | Row index. |
| j | Column index. |
Definition at line 877 of file Matrix.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Stream output helper.
Prints the matrix in a nested bracket form.
| os | Output stream. |
| A | Matrix to print. |
Definition at line 439 of file Matrix.cpp.
| RealMatrix.NestedList = Sequence[Sequence[Number]] |
Definition at line 18 of file RealMatrix.py.
| RealMatrix.Number = Union[int, float] |
Definition at line 17 of file RealMatrix.py.