ARTS
2.3.1285(git:92a29ea9-dirty)
|
#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< Matrix > | create_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< Sparse > | create_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 () |
using RetrievalData = std::tuple<ArrayOfRetrievalQuantity, ArrayOfArrayOfIndex> |
Definition at line 40 of file test_covariance_matrix.cc.
void covmat_seAddBlock | ( | CovarianceMatrix & | covmat_se, |
const MatrixType & | block, | ||
const Index & | i, | ||
const Index & | j, | ||
const Verbosity & | |||
) |
Definition at line 397 of file m_retrieval.cc.
References CovarianceMatrix::add_correlation(), covmat_seAddBlock(), CovarianceMatrix::get_block(), Block::get_column_range(), Range::get_extent(), Block::get_row_range(), CovarianceMatrix::has_block(), i, n, CovarianceMatrix::ndiagblocks(), CovarianceMatrix::nrows(), and Zeeman::start().
Referenced by covmat_seAddBlock(), covmat_seAddBlock_sg_Matrix_g(), covmat_seAddBlock_sg_Sparse_g(), and test_workspace_methods().
void covmat_seAddInverseBlock | ( | CovarianceMatrix & | covmat_se, |
const MatrixType & | block, | ||
const Index & | i, | ||
const Index & | j, | ||
const Verbosity & | |||
) |
Definition at line 490 of file m_retrieval.cc.
References CovarianceMatrix::add_correlation_inverse(), covmat_seAddInverseBlock(), CovarianceMatrix::get_block(), Block::get_column_range(), Block::get_row_range(), i, n, and CovarianceMatrix::ndiagblocks().
Referenced by covmat_seAddInverseBlock(), covmat_seAddInverseBlock_sg_Matrix_g(), covmat_seAddInverseBlock_sg_Sparse_g(), and test_workspace_methods().
void covmat_seSet | ( | CovarianceMatrix & | covmat, |
const MatrixType & | block, | ||
const Verbosity & | |||
) |
Definition at line 561 of file m_retrieval.cc.
References covmat_seSet(), and setCovarianceMatrix().
Referenced by covmat_seSet(), covmat_seSet_sg_CovarianceMatrix_g(), covmat_seSet_sg_Matrix_g(), covmat_seSet_sg_Sparse_g(), and test_workspace_methods().
void covmat_sxAddBlock | ( | CovarianceMatrix & | covmat_se, |
const ArrayOfRetrievalQuantity & | jq, | ||
const MatrixType & | block, | ||
const Index & | i, | ||
const Index & | j, | ||
const Verbosity & | |||
) |
Definition at line 599 of file m_retrieval.cc.
References CovarianceMatrix::add_correlation(), covmat_sxAddBlock(), jac_ranges_indices(), n, CovarianceMatrix::ndiagblocks(), Array< base >::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().
Referenced by covmat_sxAddBlock(), covmat_sxAddBlock_sg_Matrix_g(), covmat_sxAddBlock_sg_Sparse_g(), and test_workspace_methods().
void covmat_sxAddInverseBlock | ( | CovarianceMatrix & | covmat_se, |
const ArrayOfRetrievalQuantity & | jq, | ||
const MatrixType & | block, | ||
const Index & | i, | ||
const Index & | j, | ||
const Verbosity & | |||
) |
Definition at line 678 of file m_retrieval.cc.
References CovarianceMatrix::add_correlation_inverse(), covmat_sxAddInverseBlock(), CovarianceMatrix::has_block(), jac_ranges_indices(), n, Array< base >::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().
Referenced by covmat_sxAddInverseBlock(), covmat_sxAddInverseBlock_sg_Matrix_g(), covmat_sxAddInverseBlock_sg_Sparse_g(), and test_workspace_methods().
void covmat_sxSet | ( | CovarianceMatrix & | covmat, |
const MatrixType & | block, | ||
const Verbosity & | |||
) |
Definition at line 580 of file m_retrieval.cc.
References covmat_sxSet(), and setCovarianceMatrix().
Referenced by covmat_sxSet(), covmat_sxSet_sg_CovarianceMatrix_g(), covmat_sxSet_sg_Matrix_g(), covmat_sxSet_sg_Sparse_g(), and test_workspace_methods().
std::shared_ptr<Matrix> create_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.
i | The index of the first retrieval quantity |
j | The index of the second retrieval quantity |
jqs | The array holding the retrieval quantities. |
f | The functional to apply to the correlated grid positions. |
Definition at line 55 of file test_covariance_matrix.cc.
References RetrievalQuantity::Grids(), q1, and swap().
Referenced by random_covariance_matrix().
std::shared_ptr<Sparse> create_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.
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().
int main | ( | void | ) |
Definition at line 600 of file test_covariance_matrix.cc.
CovarianceMatrix random_covariance_matrix | ( | const ArrayOfRetrievalQuantity & | rqs, |
const ArrayOfArrayOfIndex & | jis | ||
) |
Create a covariance matrix with correlations between retrieval quantitites given in rqs and jis.
rqs | The array holding the retrieval quantities. |
jis | The 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(), and i.
RetrievalData setup_retrieval_1D | ( | ) |
Setup a random retrieval case for testing.
Definition at line 120 of file test_covariance_matrix.cc.
References i, and Array< base >::nelem().
Test addition of covariance matrices and inverse covariance matrices.
n_tests | The number of tests to perform |
Definition at line 319 of file test_covariance_matrix.cc.
Test extraction of diagonal.
n_tests | The number of tests to perform |
Definition at line 354 of file test_covariance_matrix.cc.
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.
n_tests | The number of tests to perform |
Definition at line 288 of file test_covariance_matrix.cc.
Test input and output of covariance matrices.
n_tests | The number of tests to perform |
Definition at line 376 of file test_covariance_matrix.cc.
Tests the multiplication of covariance matrices with matrices.
n_tests | The number of tests to perform |
Definition at line 255 of file test_covariance_matrix.cc.
Tests the multiplication of covariance matrices with vectors.
n_tests | The number of tests to perform. |
Definition at line 227 of file test_covariance_matrix.cc.
void test_workspace_methods | ( | ) |
Test general functionality of CovarianceMatrix class.
Definition at line 442 of file test_covariance_matrix.cc.
References C, covmat_seAddBlock(), covmat_seAddInverseBlock(), covmat_seSet(), covmat_sxAddBlock(), covmat_sxAddInverseBlock(), covmat_sxSet(), CovarianceMatrix::ncols(), Sparse::resize(), and Matrix::resize().