GammaLib
2.1.0.dev
|
Generic matrix class definition. More...
#include <GMatrix.hpp>
Public Member Functions | |
GMatrix (void) | |
Void matrix constructor. More... | |
GMatrix (const int &rows, const int &columns) | |
Matrix constructor. More... | |
GMatrix (const GMatrix &matrix) | |
Copy constructor. More... | |
GMatrix (const GMatrixSymmetric &matrix) | |
GMatrixSymmetric to GMatrix storage class convertor. More... | |
GMatrix (const GMatrixSparse &matrix) | |
GMatrixSparse to GMatrix storage class convertor. More... | |
virtual | ~GMatrix (void) |
Destructor. More... | |
virtual double & | operator() (const int &row, const int &column) |
Return reference to matrix element. More... | |
virtual const double & | operator() (const int &row, const int &column) const |
Return reference to matrix element (const version) More... | |
virtual GVector | operator* (const GVector &vector) const |
Vector multiplication. More... | |
virtual GMatrix & | operator= (const GMatrix &matrix) |
Matrix assignment operator. More... | |
virtual GMatrix & | operator= (const double &value) |
Value assignment operator. More... | |
virtual GMatrix | operator+ (const GMatrix &matrix) const |
Binary matrix addition. More... | |
virtual GMatrix | operator+ (const double &scalar) const |
Binary matrix scalar addition. More... | |
virtual GMatrix | operator- (const GMatrix &matrix) const |
Binary matrix subtraction. More... | |
virtual GMatrix | operator- (const double &scalar) const |
Binary matrix scalar subtraction. More... | |
virtual GMatrix | operator* (const GMatrix &matrix) const |
Binary matrix multiplication. More... | |
virtual GMatrix | operator- (void) const |
Negate matrix elements. More... | |
virtual GMatrix & | operator+= (const GMatrix &matrix) |
Unary matrix addition operator. More... | |
virtual GMatrix & | operator+= (const double &scalar) |
Unary matrix scalar addition operator. More... | |
virtual GMatrix & | operator-= (const GMatrix &matrix) |
Unary matrix subtraction operator. More... | |
virtual GMatrix & | operator-= (const double &scalar) |
Unary matrix scalar subtraction operator. More... | |
virtual GMatrix & | operator*= (const GMatrix &matrix) |
Unary matrix multiplication operator. More... | |
virtual GMatrix & | operator*= (const double &scalar) |
Scale matrix elements. More... | |
virtual GMatrix & | operator/= (const double &scalar) |
Divide matrix elements. More... | |
virtual void | clear (void) |
Clear matrix. More... | |
virtual GMatrix * | clone (void) const |
Clone matrix. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual double & | at (const int &row, const int &column) |
Return reference to matrix element. More... | |
virtual const double & | at (const int &row, const int &column) const |
Return reference to matrix element (const version) More... | |
virtual GVector | row (const int &row) const |
Extract row as vector from matrix. More... | |
virtual void | row (const int &row, const GVector &vector) |
Set row in matrix. More... | |
virtual GVector | column (const int &column) const |
Extract column as vector from matrix. More... | |
virtual void | column (const int &column, const GVector &vector) |
Set matrix column from vector. More... | |
virtual void | add_to_row (const int &row, const GVector &vector) |
Add row to matrix elements. More... | |
virtual void | add_to_column (const int &column, const GVector &vector) |
Add vector column into matrix. More... | |
virtual double | fill (void) const |
Return fill of matrix. More... | |
virtual double | min (void) const |
Return minimum matrix element. More... | |
virtual double | max (void) const |
Return maximum matrix element. More... | |
virtual double | sum (void) const |
Return matrix element sum. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print matrix. More... | |
GMatrix | transpose (void) const |
Return transposed matrix. More... | |
GMatrix | invert (void) const |
Return inverted matrix. More... | |
GVector | solve (const GVector &vector) const |
Solves linear matrix equation. More... | |
GMatrix | abs (void) const |
Return absolute of matrix. More... | |
GMatrix | extract_lower_triangle (void) const |
Extract lower triangle of matrix. More... | |
GMatrix | extract_upper_triangle (void) const |
Extract upper triangle of matrix. More... | |
void | eulerx (const double &angle) |
Set Euler rotation matrix around x axis. More... | |
void | eulery (const double &angle) |
Set Euler rotation matrix around y axis. More... | |
void | eulerz (const double &angle) |
Set Euler rotation matrix around z axis. More... | |
Public Member Functions inherited from GMatrixBase | |
GMatrixBase (void) | |
Void constructor. More... | |
GMatrixBase (const GMatrixBase &matrix) | |
Copy constructor. More... | |
virtual | ~GMatrixBase (void) |
Destructor. More... | |
virtual GMatrixBase & | operator= (const GMatrixBase &matrix) |
Assignment operator. More... | |
virtual bool | operator== (const GMatrixBase &matrix) const |
Equalty operator. More... | |
virtual bool | operator!= (const GMatrixBase &matrix) const |
Non-equality operator. More... | |
bool | is_empty (void) const |
Check if matrix is empty. More... | |
const int & | size (void) const |
Return number of matrix elements. More... | |
const int & | columns (void) const |
Return number of matrix columns. More... | |
const int & | rows (void) const |
Return number of matrix rows. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Private Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GMatrix &matrix) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | alloc_members (const int &rows, const int &columns) |
Allocate matrix memory. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from GMatrixBase | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GMatrixBase &matrix) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | select_non_zero (void) |
Setup compressed matrix factorisation. More... | |
void | scale_elements (const double &scalar) |
Scale all matrix elements with a scalar. More... | |
void | set_all_elements (const double &value) |
Set all elements to a specific value. More... | |
double | get_min_element (void) const |
Return minimum matrix element. More... | |
double | get_max_element (void) const |
Returns maximum matrix element. More... | |
double | get_element_sum (void) const |
Returns sum over all matrix elements. More... | |
std::string | print_elements (const GChatter &chatter=NORMAL, const int &num=15) const |
Print all matrix elements. More... | |
std::string | print_row_compression (const GChatter &chatter=NORMAL) const |
Print row compression scheme if it exists. More... | |
std::string | print_col_compression (const GChatter &chatter=NORMAL) const |
Print column compression scheme if it exists. More... | |
Protected Attributes inherited from GMatrixBase | |
int | m_rows |
Number of rows. More... | |
int | m_cols |
Number of columns. More... | |
int | m_elements |
Number of elements stored in matrix. More... | |
int | m_alloc |
Size of allocated matrix memory. More... | |
int | m_num_rowsel |
Number of selected rows (for compressed decomposition) More... | |
int | m_num_colsel |
Number of selected columns (for compressed decomposition) More... | |
int * | m_colstart |
Column start indices (m_cols+1) More... | |
int * | m_rowsel |
Row selection (for compressed decomposition) More... | |
int * | m_colsel |
Column selection (for compressed decomposition) More... | |
double * | m_data |
Matrix data. More... | |
Generic matrix class definition.
This class implements a generic matrix. The class is a non-specialized representation of a matrix, and all other matrix storage classes can be converted into that class.
For a description of the common matrix methods, please refer to the GMatrixBase class.
Matrix allocation is done using the constructors
GMatrix matrix(rows, columns); GMatrix matrix(matrix); GMatrix matrix(sparsematrix); GMatrix matrix(symmetricmatrix);
where rows
and columns
specify the number of rows and columns of the matrix. Storage conversion constructors exist that allow allocating a generic matrix by copying from a sparse matrix of type GMatrixSparse and a symmetric matrix of type GMatrixSymmetric.
To support using the GMatrix for coordinate transformations, methods are available to compute matrices for the three Euler angles:
matrix.eulerx(angle); matrix.eulery(angle); matrix.eulerz(angle);
Methods are also available to extract the lower or the upper triangle of a matrix:
matrix.extract_lower_triangle(); matrix.extract_upper_triangle();
Matrix elements are stored column-wise by the class.
Definition at line 79 of file GMatrix.hpp.
GMatrix::GMatrix | ( | void | ) |
Void matrix constructor.
Constructs an empty matrix. An empty matrix has zero rows and columns.
Definition at line 70 of file GMatrix.cpp.
References init_members().
Referenced by clone().
|
explicit |
Matrix constructor.
[in] | rows | Number of rows [>=0]. |
[in] | columns | Number of columns [>=0]. |
GException::invalid_argument | Number of rows or columns is negative. |
Constructs a matrix with the specified number of rows
and columns
. The memory for all matrix elements will be allocated and all matrix elements will be initialized to 0.
Definition at line 93 of file GMatrix.cpp.
References alloc_members(), G_CONSTRUCTOR, init_members(), and gammalib::str().
GMatrix::GMatrix | ( | const GMatrix & | matrix | ) |
Copy constructor.
[in] | matrix | Matrix. |
Definition at line 126 of file GMatrix.cpp.
References copy_members(), and init_members().
GMatrix::GMatrix | ( | const GMatrixSymmetric & | matrix | ) |
GMatrixSymmetric to GMatrix storage class convertor.
[in] | matrix | Symmetric matrix (GMatrixSymmetric). |
Constructs a GMatrix object from a symmetric matrix object of type GMatrixSymmetric. Since the result is a generic matrix, the constructor will succeed in all cases.
Definition at line 148 of file GMatrix.cpp.
References alloc_members(), GMatrixBase::columns(), init_members(), GMatrixBase::m_cols, GMatrixBase::m_rows, row(), and GMatrixBase::rows().
GMatrix::GMatrix | ( | const GMatrixSparse & | matrix | ) |
GMatrixSparse to GMatrix storage class convertor.
[in] | matrix | Sparse matrix (GMatrixSparse). |
Constructs a GMatrix object from a sparse matrix object of type GMatrixSparse. Since the result is a generic matrix, the constructor will succeed in all cases.
Definition at line 181 of file GMatrix.cpp.
References alloc_members(), GMatrixBase::columns(), init_members(), GMatrixBase::m_cols, GMatrixBase::m_rows, row(), and GMatrixBase::rows().
|
virtual |
GMatrix GMatrix::abs | ( | void | ) | const |
Return absolute of matrix.
Returns matrix where all elements of the matrix have been replaced by their absolute values.
Definition at line 983 of file GMatrix.cpp.
References abs(), GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_elements, and GMatrixBase::m_rows.
|
virtual |
Add vector column into matrix.
[in] | column | Matrix column [0,...,columns()[. |
[in] | vector | Vector. |
GException::out_of_range | Invalid matrix column specified. |
GException::matrix_vector_mismatch | Vector size does not match number of matrix rows. |
Adds the content of a vector to a matrix column.
Implements GMatrixBase.
Definition at line 857 of file GMatrix.cpp.
References column(), G_ADD_TO_COLUMN, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, row(), GVector::size(), and gammalib::str().
|
virtual |
Add row to matrix elements.
[in] | row | Matrix row [0,...,rows()[. |
[in] | vector | Vector of matrix row elements (columns() elements). |
GException::out_of_range | Invalid matrix row specified. |
GException::matrix_vector_mismatch | Vector does not match the matrix dimensions. |
Implements GMatrixBase.
Definition at line 812 of file GMatrix.cpp.
References G_ADD_TO_ROW, GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_rows, GVector::size(), and gammalib::str().
|
private |
Allocate matrix memory.
[in] | rows | Number of matrix rows. |
[in] | columns | Number of matrix columns. |
Allocates memory for the matrix elements. The method assumes that no memory has been allocated for the matrix elements and the column start index array. The method allocates the memory for matrix elements and the column start indices, sets all matrix elements to 0, and sets the column start indices.
If either the number of rows or the number of columns is non-positive, the method does nothing.
Definition at line 1324 of file GMatrix.cpp.
References GMatrixBase::columns(), GMatrixBase::m_alloc, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, and GMatrixBase::rows().
|
virtual |
Return reference to matrix element.
GException::out_of_range | Matrix row or column out of range. |
Returns a reference to the matrix element at row
and column
.
This method verifies the validity of the row
and column
argument.
Implements GMatrixBase.
Definition at line 580 of file GMatrix.cpp.
References G_AT, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, and GMatrixBase::m_rows.
|
virtual |
Return reference to matrix element (const version)
GException::out_of_range | Matrix row or column out of range. |
Returns a const reference to the matrix element at row
and column
.
This method verifies the validity of the row
and column
argument.
Implements GMatrixBase.
Definition at line 609 of file GMatrix.cpp.
References G_AT, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, and GMatrixBase::m_rows.
|
inlinevirtual |
Return class name.
Implements GMatrixBase.
Definition at line 156 of file GMatrix.hpp.
|
virtual |
Clear matrix.
Implements GMatrixBase.
Definition at line 541 of file GMatrix.cpp.
References free_members(), and init_members().
Referenced by GCTAPointing::init_members().
|
virtual |
Clone matrix.
Implements GMatrixBase.
Definition at line 559 of file GMatrix.cpp.
References GMatrix().
|
virtual |
Extract column as vector from matrix.
[in] | column | Matrix column [0,...,columns()[. |
GException::out_of_range | Invalid matrix column specified. |
This method extracts a matrix column into a vector.
Implements GMatrixBase.
Definition at line 718 of file GMatrix.cpp.
References G_EXTRACT_COLUMN, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, and row().
Referenced by add_to_column(), column(), GMatrixSparse::GMatrixSparse(), and GCTAResponseCube::irf_radial().
|
virtual |
Set matrix column from vector.
[in] | column | Matrix column [0,...,columns()[. |
[in] | vector | Vector. |
GException::out_of_range | Invalid matrix column specified. |
GException::invalid_argument | Vector size does not match number of matrix rows. |
Inserts the content of a vector into a matrix column. Any previous content in the matrix column will be overwritted.
Implements GMatrixBase.
Definition at line 763 of file GMatrix.cpp.
References column(), G_SET_COLUMN, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, row(), GVector::size(), and gammalib::str().
|
private |
Copy class members.
[in] | matrix | Matrix. |
Definition at line 1292 of file GMatrix.cpp.
Referenced by GMatrix(), and operator=().
void GMatrix::eulerx | ( | const double & | angle | ) |
Set Euler rotation matrix around x axis.
[in] | angle | Rotation angle (degrees) |
Definition at line 1120 of file GMatrix.cpp.
References alloc_members(), cos(), gammalib::deg2rad, GMatrixBase::free_members(), GMatrixBase::init_members(), and sin().
void GMatrix::eulery | ( | const double & | angle | ) |
Set Euler rotation matrix around y axis.
[in] | angle | Rotation angle (degrees) |
Definition at line 1157 of file GMatrix.cpp.
References alloc_members(), cos(), gammalib::deg2rad, GMatrixBase::free_members(), GMatrixBase::init_members(), and sin().
Referenced by GCTAResponseIrf::irf_diffuse(), GCOMResponse::irf_elliptical(), GResponse::irf_elliptical(), GCOMResponse::irf_radial(), GResponse::irf_radial(), GCTAResponseIrf::nroi_diffuse(), GCTAResponseIrf::nroi_elliptical(), GCTAResponseIrf::nroi_radial(), GCTAResponseCube::psf_diffuse(), GSkyDir::rotate(), GHorizDir::rotate_deg(), and GCTAPointing::update().
void GMatrix::eulerz | ( | const double & | angle | ) |
Set Euler rotation matrix around z axis.
[in] | angle | Rotation angle (degrees) |
Definition at line 1194 of file GMatrix.cpp.
References alloc_members(), cos(), gammalib::deg2rad, GMatrixBase::free_members(), GMatrixBase::init_members(), and sin().
Referenced by GCTAResponseIrf::irf_diffuse(), GCOMResponse::irf_elliptical(), GResponse::irf_elliptical(), GCOMResponse::irf_radial(), GResponse::irf_radial(), GCTAResponseIrf::nroi_diffuse(), GCTAResponseIrf::nroi_elliptical(), GCTAResponseIrf::nroi_radial(), GCTAResponseCube::psf_diffuse(), GSkyDir::rotate(), GHorizDir::rotate_deg(), and GCTAPointing::update().
GMatrix GMatrix::extract_lower_triangle | ( | void | ) | const |
Extract lower triangle of matrix.
GException::invalid_argument | Matrix is not a square matrix. |
This method extracts the lower triangle of a matrix into another matrix. (including the diagonal elements). All remaining matrix elements will be zero.
Triangular extraction only works for square matrixes.
Definition at line 1049 of file GMatrix.cpp.
References G_EXTRACT_LOWER, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_rows, row(), and gammalib::str().
GMatrix GMatrix::extract_upper_triangle | ( | void | ) | const |
Extract upper triangle of matrix.
GException::invalid_argument | Matrix is not a square matrix. |
This method extracts the upper triangle of a matrix into another matrix. (including the diagonal elements). All remaining matrix elements will be zero.
Triangular extraction only works for square matrixes.
Definition at line 1088 of file GMatrix.cpp.
References G_EXTRACT_UPPER, GMatrixBase::m_cols, GMatrixBase::m_colstart, GMatrixBase::m_data, GMatrixBase::m_rows, row(), and gammalib::str().
|
virtual |
Return fill of matrix.
Returns the fill of the matrix. The fill of a matrix is defined as the number non-zero elements devided by the number of total elements. By definition, the fill is comprised in the interval [0,..,1].
The fill of a matrix with zero elements will be set to 0.
Implements GMatrixBase.
Definition at line 1011 of file GMatrix.cpp.
References GMatrixBase::m_data, and GMatrixBase::m_elements.
|
private |
Delete class members.
Definition at line 1302 of file GMatrix.cpp.
Referenced by clear(), operator=(), and ~GMatrix().
|
private |
Initialise class members.
Definition at line 1280 of file GMatrix.cpp.
Referenced by clear(), GMatrix(), and operator=().
GMatrix GMatrix::invert | ( | void | ) | const |
Return inverted matrix.
GException::feature_not_implemented | Feature not yet implemented. |
Returns inverse of matrix.
Definition at line 932 of file GMatrix.cpp.
References G_INVERT, GMatrixBase::m_cols, and GMatrixBase::m_rows.
|
inlinevirtual |
Return maximum matrix element.
Returns the largest element in the matrix.
Implements GMatrixBase.
Definition at line 339 of file GMatrix.hpp.
References GMatrixBase::get_max_element().
|
inlinevirtual |
Return minimum matrix element.
Returns the smallest element in the matrix.
Implements GMatrixBase.
Definition at line 325 of file GMatrix.hpp.
References GMatrixBase::get_min_element().
|
inlinevirtual |
Return reference to matrix element.
Returns a reference to the matrix element at row
and column
.
Implements GMatrixBase.
Definition at line 172 of file GMatrix.hpp.
References GMatrixBase::m_colstart, and GMatrixBase::m_data.
|
inlinevirtual |
Return reference to matrix element (const version)
Returns a const reference to the matrix element at row
and column
.
Implements GMatrixBase.
Definition at line 188 of file GMatrix.hpp.
References GMatrixBase::m_colstart, and GMatrixBase::m_data.
Vector multiplication.
[in] | vector | Vector. |
GException::invalid_argument | Vector size differs from number of columns in matrix. |
This method performs a vector multiplication of a matrix. The vector multiplication will produce a vector. The multiplication can only be performed when the number of matrix columns is identical to the size of the vector. If the size of the vector differs an exception will be thrown.
Implements GMatrixBase.
Definition at line 289 of file GMatrix.cpp.
References G_OP_MUL_VEC, GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_rows, row(), GVector::size(), gammalib::str(), and sum().
Binary matrix multiplication.
[in] | matrix | Matrix. |
Returns the product of two matrices. The method makes use of the unary multiplication operator.
Definition at line 275 of file GMatrix.hpp.
Unary matrix multiplication operator.
[in] | matrix | Matrix. |
GException::invalid_argument | Number of rows in matrix is different from number of matrix columns. |
This method performs a matrix multiplication. The operation can only succeed when the dimensions of both matrices are compatible.
In case of rectangular matrices the result matrix does not change and the operation is performed inplace. For the general case the result matrix changes in size and for simplicity a new matrix is allocated to hold the result.
Definition at line 479 of file GMatrix.cpp.
References G_OP_MAT_MUL, GMatrixBase::m_cols, GMatrixBase::m_rows, row(), gammalib::str(), and sum().
|
inlinevirtual |
Scale matrix elements.
[in] | scalar | Scale factor. |
scalar
.Returns a matrix where all elements have been multiplied by the specified scalar
value.
Definition at line 293 of file GMatrix.hpp.
References GMatrixBase::scale_elements().
Binary matrix addition.
[in] | matrix | Matrix. |
Returns the sum of two matrices. The method makes use of the unary addition operator.
Definition at line 204 of file GMatrix.hpp.
|
inlinevirtual |
Binary matrix scalar addition.
[in] | scalar | Scalar. |
scalar
added.Returns a matrix where a scalar
has been added to each matrix element.
Definition at line 221 of file GMatrix.hpp.
Unary matrix addition operator.
[in] | matrix | Matrix. |
GException::invalid_argument | Incompatible number of matrix rows or columns. |
This method performs a matrix addition. The method throws an exception if the number of matrix rows or columns are not identical.
Definition at line 351 of file GMatrix.cpp.
References G_OP_ADD, GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, and gammalib::str().
|
virtual |
Unary matrix scalar addition operator.
[in] | scalar | Scalar. |
Adds a scalar
to each matrix element.
Definition at line 388 of file GMatrix.cpp.
References GMatrixBase::m_data, and GMatrixBase::m_elements.
Binary matrix subtraction.
[in] | matrix | Matrix. |
Returns the difference between two matrices. The method makes use of the unary subtraction operator.
Definition at line 239 of file GMatrix.hpp.
|
inlinevirtual |
Binary matrix scalar subtraction.
[in] | scalar | Scalar. |
scalar
subtracted.Returns a matrix where a scalar
has been subtracted from each matrix element.
Definition at line 257 of file GMatrix.hpp.
|
virtual |
Negate matrix elements.
Returns a matrix where each element has been replaced by its negative element.
Definition at line 324 of file GMatrix.cpp.
References GMatrixBase::m_data, and GMatrixBase::m_elements.
Unary matrix subtraction operator.
[in] | matrix | Matrix. |
GException::invalid_argument | Incompatible number of matrix rows or columns. |
This method performs a matrix addition. The method throws an exception if the number of matrix rows or columns are not identical.
Definition at line 412 of file GMatrix.cpp.
References G_OP_SUB, GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_elements, GMatrixBase::m_rows, and gammalib::str().
|
virtual |
Unary matrix scalar subtraction operator.
[in] | scalar | Scalar. |
Subtracts a scalar
from each matrix element.
Definition at line 449 of file GMatrix.cpp.
References GMatrixBase::m_data, and GMatrixBase::m_elements.
|
inlinevirtual |
Divide matrix elements.
[in] | scalar | Scalar. |
scalar
.Returns a matrix where all elements have been divided by the specified scalar
value.
Definition at line 310 of file GMatrix.hpp.
Matrix assignment operator.
[in] | matrix | Matrix. |
Assigns the content of another matrix to the actual matrix instance.
Definition at line 228 of file GMatrix.cpp.
References copy_members(), free_members(), init_members(), and GMatrixBase::operator=().
|
virtual |
Value assignment operator.
[in] | value | Value. |
Assigns the specified value
to all elements of the matrix.
Definition at line 262 of file GMatrix.cpp.
References GMatrixBase::m_data, and GMatrixBase::m_elements.
Print matrix.
[in] | chatter | Chattiness. |
Implements GMatrixBase.
Definition at line 1232 of file GMatrix.cpp.
References GMatrixBase::m_alloc, GMatrixBase::m_cols, GMatrixBase::m_colsel, GMatrixBase::m_elements, GMatrixBase::m_num_colsel, GMatrixBase::m_num_rowsel, GMatrixBase::m_rows, GMatrixBase::m_rowsel, gammalib::parformat(), GMatrixBase::print_col_compression(), GMatrixBase::print_elements(), GMatrixBase::print_row_compression(), SILENT, and gammalib::str().
|
virtual |
Extract row as vector from matrix.
[in] | row | Matrix row [0,...,rows()[. |
GException::out_of_range | Invalid matrix row specified. |
Extracts one row
of the matrix into a vector. The vector will contain columns() elements.
Implements GMatrixBase.
Definition at line 637 of file GMatrix.cpp.
References G_EXTRACT_ROW, GMatrixBase::m_cols, GMatrixBase::m_data, and GMatrixBase::m_rows.
Referenced by add_to_column(), column(), extract_lower_triangle(), extract_upper_triangle(), GMatrix(), operator*(), operator*=(), and transpose().
|
virtual |
Set row in matrix.
[in] | row | Matrix row [0,...,rows()[. |
[in] | vector | Vector of matrix row elements (columns() elements). |
GException::out_of_range | Invalid matrix row specified. |
GException::invalid_argument | Vector size does not match number of matrix columns. |
Sets the elements from a vector as the elements of a matrix row. The size of the vector must be identical to the number of columns in the matrix.
Implements GMatrixBase.
Definition at line 676 of file GMatrix.cpp.
References G_SET_ROW, GMatrixBase::m_cols, GMatrixBase::m_data, GMatrixBase::m_rows, GVector::size(), and gammalib::str().
Solves linear matrix equation.
[in] | vector | Solution vector. |
GException::feature_not_implemented | Feature not yet implemented. |
Solves the linear equation
\[M \times {\tt solution} = {\tt vector} \]
where \(M\) is the matrix, \({\tt vector}\) is the result, and \({\tt solution}\) is the solution.
Definition at line 962 of file GMatrix.cpp.
References G_SOLVE.
|
inlinevirtual |
Return matrix element sum.
Returns the sum of all matrix elements.
Implements GMatrixBase.
Definition at line 353 of file GMatrix.hpp.
References GMatrixBase::get_element_sum().
Referenced by operator*(), and operator*=().
GMatrix GMatrix::transpose | ( | void | ) | const |
Return transposed matrix.
Returns transposed matrix of the matrix.
Definition at line 903 of file GMatrix.cpp.
References GMatrixBase::m_cols, GMatrixBase::m_rows, and row().
Referenced by GCTAPointing::instdir().