ARTS  2.4.0(git:4fb77825)
test_covariance_matrix.cc File Reference
#include <cstdlib>
#include <limits>
#include <random>
#include <utility>
#include "array.h"
#include "covariance_matrix.h"
#include "jacobian.h"
#include "lin_alg.h"
#include "test_utils.h"
#include "xml_io.h"
#include "invlib/algebra.h"
#include "invlib/interfaces/arts_wrapper.h"

Go to the source code of this file.

Typedefs

using RetrievalData = std::tuple< ArrayOfRetrievalQuantity, ArrayOfArrayOfIndex >
 

Functions

template<typename F >
std::shared_ptr< Matrixcreate_covariance_matrix_1D (Index i, Index j, ArrayOfRetrievalQuantity jqs, F f)
 Create a block of a covariance matrix representating a correlation between the retrieval quantities i and j by applying the functional f to the grid positions of each of the retrieval grids. More...
 
template<typename F >
std::shared_ptr< Sparsecreate_sparse_covariance_matrix_1D (Index i, Index j, ArrayOfRetrievalQuantity jqs, F f)
 Same as create_covariance_matrix_1D but creates a matrix of type sparse. More...
 
RetrievalData setup_retrieval_1D ()
 Setup a random retrieval case for testing. More...
 
CovarianceMatrix random_covariance_matrix (const ArrayOfRetrievalQuantity &rqs, const ArrayOfArrayOfIndex &jis)
 Create a covariance matrix with correlations between retrieval quantitites given in rqs and jis. More...
 
Numeric test_multiplication_by_vector (Index n_tests)
 Tests the multiplication of covariance matrices with vectors. More...
 
Numeric test_multiplication_by_matrix (Index n_tests)
 Tests the multiplication of covariance matrices with matrices. More...
 
Numeric test_inverse (Index n_tests)
 Tests the inversion of covariance matrices by computing the products of inverses of covariance matrices with matrices and vectors and comparing the result to what is obtained by performing these operations with an identical matrix of type Matrix. More...
 
Numeric test_addition (Index n_tests)
 Test addition of covariance matrices and inverse covariance matrices. More...
 
Numeric test_diagonal (Index n_tests)
 Test extraction of diagonal. More...
 
Numeric test_io (Index n_tests)
 Test input and output of covariance matrices. More...
 
template<typename MatrixType >
void covmat_seSet (CovarianceMatrix &covmat, const MatrixType &block, const Verbosity &)
 
template<typename MatrixType >
void covmat_sxSet (CovarianceMatrix &covmat, const MatrixType &block, const Verbosity &)
 
template<typename MatrixType >
void covmat_seAddBlock (CovarianceMatrix &covmat_se, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
 
template<typename MatrixType >
void covmat_seAddInverseBlock (CovarianceMatrix &covmat_se, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
 
template<typename MatrixType >
void covmat_sxAddBlock (CovarianceMatrix &covmat_se, const ArrayOfRetrievalQuantity &jq, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
 
template<typename MatrixType >
void covmat_sxAddInverseBlock (CovarianceMatrix &covmat_se, const ArrayOfRetrievalQuantity &jq, const MatrixType &block, const Index &i, const Index &j, const Verbosity &)
 
void test_workspace_methods ()
 Test general functionality of CovarianceMatrix class. More...
 
int main ()
 

Typedef Documentation

◆ RetrievalData

Function Documentation

◆ covmat_seAddBlock()

template<typename MatrixType >
void covmat_seAddBlock ( CovarianceMatrix covmat_se,
const MatrixType block,
const Index i,
const Index j,
const Verbosity  
)

◆ covmat_seAddInverseBlock()

template<typename MatrixType >
void covmat_seAddInverseBlock ( CovarianceMatrix covmat_se,
const MatrixType block,
const Index i,
const Index j,
const Verbosity  
)

◆ covmat_seSet()

template<typename MatrixType >
void covmat_seSet ( CovarianceMatrix covmat,
const MatrixType block,
const Verbosity  
)

◆ covmat_sxAddBlock()

template<typename MatrixType >
void covmat_sxAddBlock ( CovarianceMatrix covmat_se,
const ArrayOfRetrievalQuantity jq,
const MatrixType block,
const Index i,
const Index j,
const Verbosity  
)

◆ covmat_sxAddInverseBlock()

template<typename MatrixType >
void covmat_sxAddInverseBlock ( CovarianceMatrix covmat_se,
const ArrayOfRetrievalQuantity jq,
const MatrixType block,
const Index i,
const Index j,
const Verbosity  
)

◆ covmat_sxSet()

template<typename MatrixType >
void covmat_sxSet ( CovarianceMatrix covmat,
const MatrixType block,
const Verbosity  
)

◆ create_covariance_matrix_1D()

template<typename F >
std::shared_ptr<Matrix> create_covariance_matrix_1D ( Index  i,
Index  j,
ArrayOfRetrievalQuantity  jqs,
f 
)

Create a block of a covariance matrix representating a correlation between the retrieval quantities i and j by applying the functional f to the grid positions of each of the retrieval grids.

Parameters
iThe index of the first retrieval quantity
jThe index of the second retrieval quantity
jqsThe array holding the retrieval quantities.
fThe functional to apply to the correlated grid positions.
Returns
Shared pointer to the Matrix object representing the correlation relation.

Definition at line 55 of file test_covariance_matrix.cc.

References RetrievalQuantity::Grids(), q1, and swap().

Referenced by random_covariance_matrix().

◆ create_sparse_covariance_matrix_1D()

template<typename F >
std::shared_ptr<Sparse> create_sparse_covariance_matrix_1D ( Index  i,
Index  j,
ArrayOfRetrievalQuantity  jqs,
f 
)

Same as create_covariance_matrix_1D but creates a matrix of type sparse.

Definition at line 82 of file test_covariance_matrix.cc.

References RetrievalQuantity::Grids(), ConstVectorView::nelem(), Absorption::nelem(), q1, and swap().

Referenced by random_covariance_matrix().

◆ main()

int main ( void  )

Definition at line 600 of file test_covariance_matrix.cc.

◆ random_covariance_matrix()

CovarianceMatrix random_covariance_matrix ( const ArrayOfRetrievalQuantity rqs,
const ArrayOfArrayOfIndex jis 
)

Create a covariance matrix with correlations between retrieval quantitites given in rqs and jis.

Parameters
rqsThe array holding the retrieval quantities.
jisThe array holding the jacobian indices of the retrieval quantities.

Definition at line 163 of file test_covariance_matrix.cc.

References create_covariance_matrix_1D(), create_sparse_covariance_matrix_1D(), ARTS::Var::x(), and ARTS::Var::y().

◆ setup_retrieval_1D()

RetrievalData setup_retrieval_1D ( )

Setup a random retrieval case for testing.

Returns
A RetrievalData object holding an array of retrieval quantities and jacobian indices.

Definition at line 120 of file test_covariance_matrix.cc.

References Array< base >::nelem().

◆ test_addition()

Numeric test_addition ( Index  n_tests)

Test addition of covariance matrices and inverse covariance matrices.

Parameters
n_testsThe number of tests to perform
Returns
The maximum error of the result with respect to the same operations performed using an identical matrix of type Matrix

Definition at line 319 of file test_covariance_matrix.cc.

◆ test_diagonal()

Numeric test_diagonal ( Index  n_tests)

Test extraction of diagonal.

Parameters
n_testsThe number of tests to perform
Returns
The maximum error of the result with respect to the diagonal extracted from an identical matrix of type Matrix

Definition at line 354 of file test_covariance_matrix.cc.

◆ test_inverse()

Numeric test_inverse ( Index  n_tests)

Tests the inversion of covariance matrices by computing the products of inverses of covariance matrices with matrices and vectors and comparing the result to what is obtained by performing these operations with an identical matrix of type Matrix.

Parameters
n_testsThe number of tests to perform
Returns
The maximum error of the result with respect to the same operations performed using an identical matrix of type Matrix

Definition at line 288 of file test_covariance_matrix.cc.

◆ test_io()

Numeric test_io ( Index  n_tests)

Test input and output of covariance matrices.

Parameters
n_testsThe number of tests to perform
Returns
The maximum error of the original covariance matrix and a covariance that has been stored to xml format and reread.

Definition at line 376 of file test_covariance_matrix.cc.

◆ test_multiplication_by_matrix()

Numeric test_multiplication_by_matrix ( Index  n_tests)

Tests the multiplication of covariance matrices with matrices.

Parameters
n_testsThe number of tests to perform
Returns
The maximum error of the result with respect to the same multiplication performed using an identical matrix of type Matrix

Definition at line 255 of file test_covariance_matrix.cc.

◆ test_multiplication_by_vector()

Numeric test_multiplication_by_vector ( Index  n_tests)

Tests the multiplication of covariance matrices with vectors.

Parameters
n_testsThe number of tests to perform.
Returns
The maximum error of the result with respect to the same multiplication performed using an identical matrix of type Matrix

Definition at line 227 of file test_covariance_matrix.cc.

◆ test_workspace_methods()

void test_workspace_methods ( )