|
qupid 0.2
Quasi-Signal Generation Model for Pixelized Detector
|
Dense m×n matrix of double with hand-rolled linear algebra. More...
#include <QPMatrix.hpp>
Public Member Functions | |
| QPMatrix () | |
| Null matrix: 0×0, no storage. | |
| QPMatrix (const int n) | |
| n×n zero matrix. | |
| QPMatrix (const int m, const int n) | |
| m×n zero matrix. | |
| QPMatrix (const int m, const int n, const int npassed,...) | |
| m×n matrix filled row-major from the variadic arguments. | |
| QPMatrix (QPVector &vec) | |
| Column vector from a QPVector. | |
| QPMatrix (const QPMatrix &other) | |
| Deep copy. | |
| QPMatrix (QPVector &vec, int ncomp) | |
ncomp×1 column vector from the first min(ncomp, 3) components of vec. | |
| QPMatrix & | operator= (const QPMatrix &) |
| Deep copy assignment; reallocates the storage. | |
| ~QPMatrix () | |
| Frees the element storage. | |
| QPMatrix | Transpose () |
| double | Det () |
| Determinant by recursive Laplace expansion along the first row. | |
| double | Trace () |
| Sum of the diagonal elements up to min(m, n). | |
| QPMatrix | SubMatrix (const int i, const int j) |
Minor matrix: this matrix with row i and column j removed. | |
| double | Cofactor (const int i, const int j) |
| Cofactor | |
| QPMatrix | Inverse () |
| Inverse by the adjugate formula | |
| double | At (int i) |
Value of linear element i of the row-major storage. | |
| double | At (int i, int j) |
Value at row i, column j: storage index i·n + j (row-major). | |
| double & | operator[] (int i) |
Reference to linear element i of the row-major storage. | |
| double & | operator() (int i) |
| Same as operator[]. | |
| double & | operator() (int i, int j) |
| Reference to the element addressed as i·m + j. | |
| bool | IsInside (int i) |
| bool | IsInside (int i, int j) |
| bool | IsSameShape (QPMatrix &other) |
| bool | IsTransShape (QPMatrix &other) |
| std::string | Print (bool quite=false) |
| Formats the matrix as tab-separated rows. | |
| QPMatrix & | operator*= (const double &other) |
| Multiply every element in place. | |
Protected Member Functions | |
| void | Freeing () |
| Releases the element storage. | |
Friends | |
| QPMatrix | operator* (QPMatrix, double) |
| Scaled copy. | |
| QPMatrix | operator* (double, QPMatrix) |
| Scaled copy. | |
| QPMatrix | operator* (QPMatrix, QPMatrix) |
| Matrix product. | |
| QPMatrix | operator+ (QPMatrix &, QPMatrix &) |
| Element-wise sum. | |
| QPMatrix | operator- (QPMatrix &, QPMatrix &) |
| Element-wise difference. | |
Dense m×n matrix of double with hand-rolled linear algebra.
Storage is a single row-major array; element (i, j) sits at index i·n + j, which is what At(int,int) uses.
Definition at line 15 of file QPMatrix.hpp.
| QPMatrix::QPMatrix | ( | ) |
Null matrix: 0×0, no storage.
Definition at line 10 of file QPMatrix.cpp.
Referenced by Inverse(), and SubMatrix().
| QPMatrix::QPMatrix | ( | const int | n | ) |
n×n zero matrix.
(The historical comment called this a unit matrix; the implementation zero-fills and never sets the diagonal.)
| n | number of rows and columns |
Definition at line 14 of file QPMatrix.cpp.
| QPMatrix::QPMatrix | ( | const int | m, |
| const int | n | ||
| ) |
m×n zero matrix.
| m | number of rows |
| n | number of columns |
Definition at line 18 of file QPMatrix.cpp.
| QPMatrix::QPMatrix | ( | const int | m, |
| const int | n, | ||
| const int | npassed, | ||
| ... | |||
| ) |
m×n matrix filled row-major from the variadic arguments.
| m | number of rows |
| n | number of columns |
| npassed | number of variadic values that follow |
0. not 0), or the values are garbage. Definition at line 23 of file QPMatrix.cpp.
| QPMatrix::QPMatrix | ( | QPVector & | vec | ) |
Column vector from a QPVector.
| vec | source vector |
| QPMatrix::QPMatrix | ( | const QPMatrix & | other | ) |
| QPMatrix::QPMatrix | ( | QPVector & | vec, |
| int | ncomp | ||
| ) |
ncomp×1 column vector from the first min(ncomp, 3) components of vec.
| vec | source vector |
| ncomp | number of rows |
Definition at line 36 of file QPMatrix.cpp.
| QPMatrix::~QPMatrix | ( | ) |
Deep copy assignment; reallocates the storage.
| other | source matrix |
Definition at line 52 of file QPMatrix.cpp.
References Freeing().
| QPMatrix QPMatrix::Transpose | ( | ) |
Definition at line 227 of file QPMatrix.cpp.
References At().
Referenced by QPMath::Gaussian::MatrixForm2D().
| double QPMatrix::Det | ( | ) |
Determinant by recursive Laplace expansion along the first row.
Square matrices only: otherwise prints a message and returns 0. A 0×0 matrix also returns 0.
Definition at line 146 of file QPMatrix.cpp.
References At(), Det(), and SubMatrix().
Referenced by Cofactor(), Det(), Inverse(), and QPMath::Gaussian::MatrixForm2D().
| double QPMatrix::Trace | ( | ) |
Sum of the diagonal elements up to min(m, n).
Reads through operator()(int,int), so non-square matrices are affected by its stride defect.
Definition at line 167 of file QPMatrix.cpp.
References operator()().
| QPMatrix QPMatrix::SubMatrix | ( | const int | i, |
| const int | j | ||
| ) |
Minor matrix: this matrix with row i and column j removed.
Writes through operator()(int,int) while reading through At, so the result is correct only for square input.
| i | row to remove |
| j | column to remove |
Definition at line 177 of file QPMatrix.cpp.
References At(), and QPMatrix().
Referenced by Cofactor(), and Det().
| double QPMatrix::Cofactor | ( | const int | i, |
| const int | j | ||
| ) |
Cofactor 

Square matrices only: otherwise prints and returns 0.
| i | row index |
| j | column index |
Definition at line 192 of file QPMatrix.cpp.
References Det(), and SubMatrix().
Referenced by Inverse().
| QPMatrix QPMatrix::Inverse | ( | ) |
Inverse by the adjugate formula 
Returns a null matrix (and prints a message) when the matrix is not square or 
Definition at line 200 of file QPMatrix.cpp.
References Cofactor(), Det(), and QPMatrix().
Referenced by QPMath::Gaussian::MatrixForm2D().
| double QPMatrix::At | ( | int | i | ) |
Value of linear element i of the row-major storage.
Out of range prints a message and returns -1.
| i | linear index in [0, m·n) |
Definition at line 96 of file QPMatrix.cpp.
References IsInside().
Referenced by Det(), Print(), SubMatrix(), and Transpose().
| double QPMatrix::At | ( | int | i, |
| int | j | ||
| ) |
Value at row i, column j: storage index i·n + j (row-major).
Out of range prints a message and returns -1.
| i | row index |
| j | column index |
Definition at line 104 of file QPMatrix.cpp.
References IsInside().
| double & QPMatrix::operator[] | ( | int | i | ) |
Reference to linear element i of the row-major storage.
Out of range prints a message and returns a reference to a shared internal sentinel; writes through it are lost.
| i | linear index in [0, m·n) |
Definition at line 122 of file QPMatrix.cpp.
References IsInside().
| double & QPMatrix::operator() | ( | int | i | ) |
Same as operator[].
| i | linear index in [0, m·n) |
Definition at line 130 of file QPMatrix.cpp.
References IsInside().
Referenced by Trace().
| double & QPMatrix::operator() | ( | int | i, |
| int | j | ||
| ) |
Reference to the element addressed as i·m + j.
| i | row index |
| j | column index |
Definition at line 138 of file QPMatrix.cpp.
References IsInside().
| bool QPMatrix::IsInside | ( | int | i | ) |
| i | linear index |
Definition at line 84 of file QPMatrix.cpp.
Referenced by At(), At(), operator()(), operator()(), and operator[]().
| bool QPMatrix::IsInside | ( | int | i, |
| int | j | ||
| ) |
| i | row index |
| j | column index |
Definition at line 89 of file QPMatrix.cpp.
| bool QPMatrix::IsSameShape | ( | QPMatrix & | other | ) |
| other | matrix to compare |
Definition at line 112 of file QPMatrix.cpp.
| bool QPMatrix::IsTransShape | ( | QPMatrix & | other | ) |
| other | matrix to compare |
other is n×m Definition at line 117 of file QPMatrix.cpp.
| std::string QPMatrix::Print | ( | bool | quite = false | ) |
Formats the matrix as tab-separated rows.
| quite | when true, only returns the string; when false, also prints it to stdout |
Definition at line 304 of file QPMatrix.cpp.
References At().
|
inline |
Multiply every element in place.
| other | scale factor |
Definition at line 182 of file QPMatrix.hpp.
|
protected |
Releases the element storage.
Does not reset the pointer; only the destructor and operator= (which reallocates) may call it.
Definition at line 77 of file QPMatrix.cpp.
Referenced by operator=(), and ~QPMatrix().
Scaled copy.
Definition at line 238 of file QPMatrix.cpp.
Scaled copy.
Definition at line 246 of file QPMatrix.cpp.
Matrix product.
Inner dimensions are checked; on mismatch prints a message and returns a null matrix.
Definition at line 254 of file QPMatrix.cpp.
Element-wise sum.
Shapes are checked; on mismatch prints a message and returns a null matrix.
Definition at line 270 of file QPMatrix.cpp.
Element-wise difference.
Shapes are checked; on mismatch prints a message and returns a null matrix.
Definition at line 287 of file QPMatrix.cpp.