ARTS
2.4.0(git:4fb77825)
|
#include "test_utils.h"
#include <cmath>
#include "arts.h"
#include "lin_alg.h"
#include "matpackII.h"
Go to the source code of this file.
Functions | |
void | add_noise (VectorView v, Numeric scale) |
Add noise to vector. More... | |
void | random_fill_matrix (MatrixView A, Numeric range, bool positive) |
Fill matrix with random values. More... | |
void | random_fill_matrix (ComplexMatrixView A, Numeric range, bool positive) |
void | random_fill_matrix (Sparse &A, Numeric range, bool positive) |
Generate random sparse matrix. More... | |
void | random_fill_matrix (Matrix &A, Sparse &B, Numeric range, bool positive) |
Generate identical, random sparse and dense matrices. More... | |
void | random_fill_matrix_symmetric (MatrixView A, Numeric range, bool positive) |
Generate random, symmetric matrix. More... | |
void | random_fill_matrix_symmetric (ComplexMatrixView A, Numeric range, bool positive) |
void | random_fill_matrix_pos_def (MatrixView A, Numeric range, bool positive) |
Generate random, positive definite matrix. More... | |
void | random_fill_matrix_pos_semi_def (MatrixView A, Numeric range, bool positive) |
Generate random, positive semi-definite matrix. More... | |
void | random_fill_vector (VectorView v, Numeric range, bool positive) |
Fill vector with random values. More... | |
MatrixView | random_submatrix (MatrixView A, int m, int n) |
Pick random random submatrix of size m times n. More... | |
Range | random_range (Index n) |
Generate random sub-range of the range [0, n-1]. More... | |
Numeric | get_maximum_error (ConstVectorView v1, ConstVectorView v2, bool relative) |
Maximum element-wise error of two vectors. More... | |
Numeric | get_maximum_error (ConstMatrixView A1, ConstMatrixView A2, bool relative) |
Maximum element-wise error of two matrices. More... | |
Numeric | get_maximum_error (ConstComplexMatrixView A1, ConstComplexMatrixView A2, bool relative) |
Definition in file test_utils.cc.
void add_noise | ( | VectorView | v, |
Numeric | scale | ||
) |
Add noise to vector.
[in,out] | v | The vector to add the noise to. |
[in] | scale | Range for the generated noise given by [0,scale]. |
Definition at line 38 of file test_utils.cc.
References ConstVectorView::nelem().
Referenced by test_oem_gauss_newton(), test_oem_gauss_newton_sparse(), and test_oem_levenberg_marquardt().
Numeric get_maximum_error | ( | ConstComplexMatrixView | A1, |
ConstComplexMatrixView | A2, | ||
bool | relative | ||
) |
Definition at line 364 of file test_utils.cc.
References abs, max, min, ConstComplexMatrixView::ncols(), and ConstComplexMatrixView::nrows().
Numeric get_maximum_error | ( | ConstMatrixView | A1, |
ConstMatrixView | A2, | ||
bool | relative | ||
) |
Maximum element-wise error of two matrices.
If relative is true, the maximum element-wise error is computed. Otherwise the absolute error is computed.
[in] | A1 | The first matrix. |
[in] | A2 | The reference matrix used to normalize the relative error. |
[in] | relative | If true the relative error is computed, otherwise the absolute error is computed. |
Definition at line 335 of file test_utils.cc.
References abs, max, min, ConstMatrixView::ncols(), and ConstMatrixView::nrows().
Numeric get_maximum_error | ( | ConstVectorView | v1, |
ConstVectorView | v2, | ||
bool | relative | ||
) |
Maximum element-wise error of two vectors.
If relative is true, the maximum element-wise error is computed. Otherwise the absolute error is computed.
[in] | v1 | The first vector. |
[in] | v2 | The reference vector used to normalize the relative error. |
[in] | relative | If true the relative error is computed, otherwise the absolute error is computed. |
Definition at line 297 of file test_utils.cc.
References abs, max, min, and ConstVectorView::nelem().
Referenced by matrix_vector_mult(), test_complex_diagonalize(), test_dense_sparse_multiplication(), test_identity(), test_insert_row(), test_inv(), test_real_diagonalize(), test_solve_linear_system(), test_sparse_arithmetic(), test_sparse_construction(), test_sparse_dense_multiplication(), test_sparse_unary_operations(), and test_xml_io().
void random_fill_matrix | ( | ComplexMatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Definition at line 71 of file test_utils.cc.
References ConstComplexMatrixView::ncols(), and ConstComplexMatrixView::nrows().
Generate identical, random sparse and dense matrices.
Fills a dense and a sparse m-times-n matrix A with max{m,n} random values at random positions.
[out] | A | The dense matrix to be filled. |
[out] | B | The sparse matrix to be filled. |
[in] | range | The range from which values are genereated. If positive = true the values are generated from the range [0,range], otherwise from the range [-range, range] |
[in] | positive | See above. |
Definition at line 126 of file test_utils.cc.
References max, ConstMatrixView::ncols(), Sparse::ncols(), Absorption::nelem(), ConstMatrixView::nrows(), Sparse::nrows(), and Sparse::rw().
void random_fill_matrix | ( | MatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Fill matrix with random values.
Fills the given matrix with random values of type Numeric in the range [0, range], if positive is set to true, or [-range, range], if positive is set to false.
[in,out] | A | The matrix to be filled. |
[in] | range | The range of the values to draw the values from. |
[in] | positive | If true the matrix is filled with values from the interval [0,range], otherwise the values are taken from the interval [-range, range]. |
Definition at line 59 of file test_utils.cc.
References ConstMatrixView::ncols(), and ConstMatrixView::nrows().
Referenced by benchmark_inv(), benchmark_mult(), generate_linear_model(), generate_test_data(), matrix_vector_mult(), QuadraticModel::QuadraticModel(), random_fill_matrix_pos_def(), random_fill_matrix_pos_semi_def(), random_fill_matrix_symmetric(), test_dense_sparse_multiplication(), test_diagonal(), test_sparse_arithmetic(), test_sparse_construction(), test_sparse_dense_multiplication(), test_sparse_unary_operations(), and test_xml_io().
Generate random sparse matrix.
Fills a sparse m-times-n matrix A with max{m,n} random values at random positions.
[out] | A | The matrix to be filled. |
[in] | range | The range from which values are genereated. If positive = true the values are generated from the range [0,range], otherwise from the range [-range, range] |
[in] | positive | See above. |
Definition at line 96 of file test_utils.cc.
References max, Sparse::ncols(), Absorption::nelem(), Sparse::nrows(), and Sparse::rw().
void random_fill_matrix_pos_def | ( | MatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Generate random, positive definite matrix.
Generate a random, positive definite matrix by generating a positive semi-definite matrix and adding the identity matrix.
[out] | A | The random, positive definite matrix. |
[in] | range | The range from which the random values are picked. If positive == true, the values are taken from the range [0,range], otherwise the are taken from the range [-range, range]. |
[in] | positive | See above. |
Definition at line 181 of file test_utils.cc.
References M, mult(), ConstMatrixView::ncols(), ConstMatrixView::nrows(), random_fill_matrix(), and transpose().
Referenced by test_inv(), and test_solve_linear_system().
void random_fill_matrix_pos_semi_def | ( | MatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Generate random, positive semi-definite matrix.
Generate a random, positive semi-definite matrix by randomly generating a matrix and multiplying it by its transpose.
[out] | A | The random, positive semi-definite matrix. |
[in] | range | The range from which the random values are picked. If positive == true, the values are taken from the range [0,range], otherwise the are taken from the range [-range, range]. |
[in] | positive | See above. |
Definition at line 210 of file test_utils.cc.
References M, mult(), random_fill_matrix(), and transpose().
void random_fill_matrix_symmetric | ( | ComplexMatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Definition at line 161 of file test_utils.cc.
References M, random_fill_matrix(), and transpose().
void random_fill_matrix_symmetric | ( | MatrixView | A, |
Numeric | range, | ||
bool | positive | ||
) |
Generate random, symmetric matrix.
[out] | A | The matrix to be filled. |
[in] | range | The range from which values are genereated. If positive = true the values are generated from the range [0,range], otherwise from the range [-range, range] |
[in] | positive | See above. |
Definition at line 156 of file test_utils.cc.
References M, random_fill_matrix(), and transpose().
Referenced by generate_test_data(), QuadraticModel::QuadraticModel(), test_complex_diagonalize(), and test_real_diagonalize().
void random_fill_vector | ( | VectorView | v, |
Numeric | range, | ||
bool | positive | ||
) |
Fill vector with random values.
Fills the given vector with random values of type Numeric drawn from the range [0, range], if positive is set to true, or from the range [-range, range], if positive == false.
[in,out] | v | The vector to be filled. |
[in] | range | The range from which the values are taken. |
[in] | positive | If true, the values are taken from the interval [0, range], otherwise from the range [-range, range]. |
Definition at line 230 of file test_utils.cc.
References ConstVectorView::nelem().
Referenced by generate_test_data(), matrix_vector_mult(), test_insert_row(), test_oem_gauss_newton_sparse(), and test_solve_linear_system().
Generate random sub-range of the range [0, n-1].
Generate random Range object such that 0 <= extent <= n and 0 <= start < n - extent.
n | The range [0, n-1] to pick the sub-range from. |
Definition at line 273 of file test_utils.cc.
MatrixView random_submatrix | ( | MatrixView | A, |
int | m, | ||
int | n | ||
) |
Pick random random submatrix of size m times n.
Randomly chooses a submatrix of the given matrix A and returns the corresponding MatrixView.
[in] | A | The matrix to choose the submatrix from. |
[in] | m | Number of rows of the submatrix. |
[in] | n | Number of columns of the submatrix. |
Definition at line 251 of file test_utils.cc.
References ConstMatrixView::ncols(), and ConstMatrixView::nrows().