ARTS 2.5.11 (git: 6827797f)
|
#include <covariance_matrix.h>
Public Member Functions | |
CovarianceMatrix ()=default | |
CovarianceMatrix (const CovarianceMatrix &)=default | |
CovarianceMatrix (CovarianceMatrix &&)=default | |
CovarianceMatrix & | operator= (const CovarianceMatrix &)=default |
CovarianceMatrix & | operator= (CovarianceMatrix &&)=default |
~CovarianceMatrix ()=default | |
operator Matrix () const | |
Matrix | get_inverse () const |
Index | nrows () const |
Index | ncols () const |
Index | ndiagblocks () const |
! The number of diagonal blocks in the matrix excluding inverses. | |
Index | ninvdiagblocks () const |
! The number of inverse diagonal blocks in the matrix. | |
Index | nblocks () const |
! The number of blocks in the matrix excluding inverses. | |
bool | has_block (Index i, Index j) |
Check if the block with indices (i, j) is contained in the covariance matrix. | |
const Block * | get_block (Index i=-1, Index j=-1) |
Return a pointer to the block with indices (i,j). | |
std::vector< Block > & | get_blocks () |
Block in the covariance matrix. | |
std::vector< Block > & | get_inverse_blocks () |
Blocks of the inverse covariance matrix. | |
bool | has_diagonal_blocks (const ArrayOfArrayOfIndex &jis) const |
Checks that the covariance matrix contains one diagonal block per retrieval quantity. | |
bool | is_consistent (const ArrayOfArrayOfIndex &jis) const |
Checks that the dimensions of the blocks in the covariance matrix are consistent with ranges occupied by the different retrieval quantities in the state vector. | |
bool | is_consistent (const Block &block) const |
This method checks whether a block is consistent with existing blocks in the covariance matrix, i.e. | |
void | compute_inverse () const |
Compute the inverse of this correlation matrix. | |
void | add_correlation (Block c) |
Add block to covariance matrix. | |
void | add_correlation_inverse (Block c) |
Add block inverse to covariance matrix. | |
Vector | diagonal () const |
Diagonal elements as vector. | |
Vector | inverse_diagonal () const |
Diagonal of the inverse of the covariance matrix as vector. | |
Private Member Functions | |
void | generate_blocks (std::vector< std::vector< const Block * > > &) const |
void | invert_correlation_block (std::vector< Block > &inverses, std::vector< const Block * > &blocks) const |
bool | has_inverse (IndexPair indices) const |
Private Attributes | |
std::vector< Block > | correlations_ |
std::vector< Block > | inverses_ |
Friends | |
void | mult (MatrixView, ConstMatrixView, const CovarianceMatrix &) |
void | mult (MatrixView, const CovarianceMatrix &, ConstMatrixView) |
void | mult (VectorView, const CovarianceMatrix &, ConstVectorView) |
void | mult_inv (MatrixView, ConstMatrixView, const CovarianceMatrix &) |
void | mult_inv (MatrixView, const CovarianceMatrix &, ConstMatrixView) |
void | solve (VectorView, const CovarianceMatrix &, ConstVectorView) |
MatrixView | operator+= (MatrixView, const CovarianceMatrix &) |
void | add_inv (MatrixView, const CovarianceMatrix &) |
void | xml_read_from_stream (istream &, CovarianceMatrix &, bifstream *, const Verbosity &) |
Reads CovarianceMatrix from XML input stream. | |
void | xml_write_to_stream (ostream &, const CovarianceMatrix &, bofstream *, const String &, const Verbosity &) |
Write CovarianceMatrix to XML output stream. | |
std::ostream & | operator<< (std::ostream &os, const CovarianceMatrix &v) |
A Covariance Matrix
This class represents correlations between retrieval quantities in the form of a covariance matrix. The covariance matrix is represented by a vector of blocks that describe the correlations between the retrieval quantities.
A block in a covariance matrix is identified by its block-row and block-column indices. The block-row i is defined by the row of blocks that contains the ith diagonal block. Similarly, the block-column j is defined as the column of block that contains the jth diagonal block.
The covariance matrix class implements overloads for the common ARTS operations for multiplication by matrices and vectors as well as adding covariance matrices to other matrices.
Computing inverses of covariance matrices is handled indirectly by providing mult_inv methods that multiply the inverse of the covariance matrix by a given vector or matrix. This, however, requires previously having computed the inverse of the matrix using the compute_inverse method.
Definition at line 210 of file covariance_matrix.h.
|
default |
|
default |
|
default |
|
default |
void CovarianceMatrix::add_correlation | ( | Block | c | ) |
Add block to covariance matrix.
This function add a given block to the covariance matrix. If this block is not consistent with other blocks in the matrix an error will be thrown.
c | The block to add to the covariance matrix |
Definition at line 507 of file covariance_matrix.cc.
References c, and correlations_.
Referenced by add_scalar_variance(), check_and_add_block(), covmat_seAddBlock(), covmat_sxAddBlock(), and setCovarianceMatrix().
void CovarianceMatrix::add_correlation_inverse | ( | Block | c | ) |
Add block inverse to covariance matrix.
This function adds the inverse of a given block to a covariance matrix. An error will be thrown if the corresponding non-inverse block is not already in the covariance matrix.
c | The inverse of a block already in the matrix. |
Definition at line 509 of file covariance_matrix.cc.
Referenced by add_scalar_variance(), check_and_add_block(), covmat_seAddInverseBlock(), and covmat_sxAddInverseBlock().
void CovarianceMatrix::compute_inverse | ( | ) | const |
Compute the inverse of this correlation matrix.
This function must be executed after all block have been added to the covariance matrix and before any of the mult_inv or add_inv methods is used.
Definition at line 388 of file covariance_matrix.cc.
References generate_blocks(), inverses_, and invert_correlation_block().
Referenced by inverse_diagonal().
Vector CovarianceMatrix::diagonal | ( | ) | const |
Diagonal elements as vector.
Extracts the diagonal elements from the covariance matrix. matrix.
Definition at line 513 of file covariance_matrix.cc.
References b, correlations_, and nrows().
Referenced by covmat_sxExtractSqrtDiagonal().
|
private |
Definition at line 344 of file covariance_matrix.cc.
References correlations_.
Referenced by compute_inverse().
const Block * CovarianceMatrix::get_block | ( | Index | i = -1 , |
Index | j = -1 |
||
) |
Return a pointer to the block with indices (i,j).
If any of i or j is less than zero, than the first block found in this row or column is returned. This is useful for obtaining the element range corresponding to a given block row or column range.
i | The block-row index of the block to return or -1. |
j | The block-column index of the block to return or -1. |
Definition at line 249 of file covariance_matrix.cc.
References b, and correlations_.
Referenced by covmat_seAddBlock(), and covmat_seAddInverseBlock().
|
inline |
Block in the covariance matrix.
Definition at line 263 of file covariance_matrix.h.
References correlations_.
Matrix CovarianceMatrix::get_inverse | ( | ) | const |
Definition at line 156 of file covariance_matrix.cc.
References c, Block::dense, inverses_, and nrows().
|
inline |
Blocks of the inverse covariance matrix.
Definition at line 270 of file covariance_matrix.h.
References inverses_.
bool CovarianceMatrix::has_block | ( | Index | i, |
Index | j | ||
) |
Check if the block with indices (i, j) is contained in the covariance matrix.
i | the block-row index |
j | the block-column index |
Definition at line 236 of file covariance_matrix.cc.
References b, and correlations_.
Referenced by covmat_seAddBlock(), and covmat_sxAddInverseBlock().
bool CovarianceMatrix::has_diagonal_blocks | ( | const ArrayOfArrayOfIndex & | jis | ) | const |
Checks that the covariance matrix contains one diagonal block per retrieval quantity.
TODO: This should be moved to m_retrieval
jis | The ArrayOfArrayOfIndex containing the first and last indices of each retrieval quantity in the state vector. |
Definition at line 264 of file covariance_matrix.cc.
References b, and correlations_.
Referenced by retrievalDefClose().
|
private |
Definition at line 335 of file covariance_matrix.cc.
Referenced by invert_correlation_block().
Vector CovarianceMatrix::inverse_diagonal | ( | ) | const |
Diagonal of the inverse of the covariance matrix as vector.
Extracts the diagonal elements from the inverse of the covariance matrix. This can trigger the computation of the inverse of the matrix, if it has not been provided by the user.
Definition at line 526 of file covariance_matrix.cc.
References b, compute_inverse(), inverses_, and nrows().
|
private |
Definition at line 396 of file covariance_matrix.cc.
References a, ARTS_ASSERT, b, Block::dense, and has_inverse().
Referenced by compute_inverse().
bool CovarianceMatrix::is_consistent | ( | const ArrayOfArrayOfIndex & | jis | ) | const |
Checks that the dimensions of the blocks in the covariance matrix are consistent with ranges occupied by the different retrieval quantities in the state vector.
TODO: This should be moved to m_retrieval
jis | The ArrayOfArrayOfIndex containing the first and last indices of each retrieval quantity in the state vector. |
Definition at line 280 of file covariance_matrix.cc.
References b, correlations_, and inverses_.
Referenced by retrievalDefClose().
bool CovarianceMatrix::is_consistent | ( | const Block & | block | ) | const |
This method checks whether a block is consistent with existing blocks in the covariance matrix, i.e.
that there is no other block in the given row i (colum j) that has a different number of rows (columns) than the given block.
block | The block for which to check consistent |
Definition at line 312 of file covariance_matrix.cc.
References b, c, and correlations_.
Index CovarianceMatrix::nblocks | ( | ) | const |
! The number of blocks in the matrix excluding inverses.
Definition at line 234 of file covariance_matrix.cc.
References correlations_.
Index CovarianceMatrix::ncols | ( | ) | const |
Definition at line 206 of file covariance_matrix.cc.
References nrows().
Index CovarianceMatrix::ndiagblocks | ( | ) | const |
! The number of diagonal blocks in the matrix excluding inverses.
Definition at line 208 of file covariance_matrix.cc.
References c, and correlations_.
Referenced by covmat_seAddBlock(), covmat_seAddInverseBlock(), covmat_sxAddBlock(), and covmat_sxAddInverseBlock().
Index CovarianceMatrix::ninvdiagblocks | ( | ) | const |
! The number of inverse diagonal blocks in the matrix.
Definition at line 221 of file covariance_matrix.cc.
Index CovarianceMatrix::nrows | ( | ) | const |
Definition at line 183 of file covariance_matrix.cc.
References c, correlations_, and inverses_.
Referenced by add_scalar_variance(), check_and_add_block(), covmat_seAddBlock(), diagonal(), get_inverse(), inverse_diagonal(), and ncols().
|
explicit |
Definition at line 129 of file covariance_matrix.cc.
References c, and Block::dense.
|
default |
|
default |
|
friend |
Definition at line 608 of file covariance_matrix.cc.
|
friend |
Definition at line 551 of file covariance_matrix.cc.
|
friend |
Definition at line 541 of file covariance_matrix.cc.
|
friend |
Definition at line 561 of file covariance_matrix.cc.
|
friend |
Definition at line 581 of file covariance_matrix.cc.
|
friend |
Definition at line 571 of file covariance_matrix.cc.
|
friend |
Definition at line 601 of file covariance_matrix.cc.
|
friend |
Definition at line 614 of file covariance_matrix.cc.
|
friend |
Definition at line 591 of file covariance_matrix.cc.
|
friend |
Reads CovarianceMatrix from XML input stream.
is_xml | XML Input stream |
covmat | CovarianceMatrix |
pbifs | Pointer to binary file stream. NULL for ASCII output. |
verbosity |
Definition at line 105 of file xml_io_compound_types.cc.
|
friend |
Write CovarianceMatrix to XML output stream.
os_xml | XML output stream |
covmat | CovarianceMatrix |
pbofs | Pointer to binary file stream. NULL for ASCII output. |
name | Unused |
verbosity |
Definition at line 184 of file xml_io_compound_types.cc.
|
private |
Definition at line 386 of file covariance_matrix.h.
Referenced by add_correlation(), add_inv(), diagonal(), generate_blocks(), get_block(), get_blocks(), has_block(), has_diagonal_blocks(), is_consistent(), mult_inv(), nblocks(), ndiagblocks(), and nrows().
|
mutableprivate |
Definition at line 387 of file covariance_matrix.h.
Referenced by add_correlation_inverse(), compute_inverse(), get_inverse(), get_inverse_blocks(), has_inverse(), inverse_diagonal(), is_consistent(), ninvdiagblocks(), and nrows().