ARTS
2.3.1285(git:92a29ea9-dirty)
|
Tests for sparse matrices. More...
#include <iostream>
#include <stdexcept>
#include "lin_alg.h"
#include "matpackI.h"
#include "matpackII.h"
#include "test_utils.h"
#include "xml_io.h"
Go to the source code of this file.
Functions | |
void | test3 () |
void | test40 () |
void | test41 () |
void | test42 () |
void | test43 () |
void | test44 () |
void | test45 () |
void | test46 () |
void | test47 () |
void | test48 () |
void | test49 () |
Numeric | test_xml_io (Index ntests, bool verbose) |
Numeric | test_insert_row (Index ntests, bool verbose) |
Test sparse insert_row function. More... | |
Numeric | test_identity (Index ntests, bool verbose) |
Test sparse identity matrix. More... | |
Numeric | test_sparse_construction (Index m, Index n, Index ntests, bool verbose) |
Test sparse matrix construction. More... | |
Numeric | test_sparse_unary_operations (Index m, Index n, Index ntests, bool verbose) |
Test unary operation on sparse matrices. More... | |
Numeric | test_dense_sparse_multiplication (Index m, Index n, Index ntests, bool verbose) |
Test dense-sparse multiplication. More... | |
Numeric | test_sparse_dense_multiplication (Index m, Index n, Index ntests, bool verbose) |
Test sparse-dense multiplication. More... | |
Numeric | test_sparse_multiplication (Index m, Index n, Index ntests, bool verbose) |
Test sparse multiplication. More... | |
Numeric | test_sparse_arithmetic (Index m, Index n, Index ntests, bool verbose) |
Test sparse matrix arithmetic. More... | |
int | main () |
Tests for sparse matrices.
Add more tests here as necessary...
Definition in file test_sparse.cc.
int main | ( | void | ) |
Definition at line 1111 of file test_sparse.cc.
References test_sparse_arithmetic().
void test3 | ( | ) |
Definition at line 43 of file test_sparse.cc.
References i, M, and Sparse::rw().
void test40 | ( | ) |
Definition at line 183 of file test_sparse.cc.
References Sparse::rw().
void test41 | ( | ) |
Definition at line 211 of file test_sparse.cc.
References r.
void test42 | ( | ) |
Definition at line 239 of file test_sparse.cc.
References r.
void test43 | ( | ) |
Definition at line 254 of file test_sparse.cc.
References r.
void test44 | ( | ) |
Definition at line 278 of file test_sparse.cc.
References r.
void test45 | ( | ) |
Definition at line 296 of file test_sparse.cc.
References xml_read_from_file().
void test46 | ( | ) |
Definition at line 329 of file test_sparse.cc.
References xml_read_from_file().
void test47 | ( | ) |
Definition at line 358 of file test_sparse.cc.
References id_mat(), and Sparse::resize().
void test48 | ( | ) |
Definition at line 369 of file test_sparse.cc.
References r.
void test49 | ( | ) |
Definition at line 384 of file test_sparse.cc.
References add(), C, i, Sparse::rw(), and sub().
Test dense-sparse multiplication.
Test multiplication B x C of a dense matrix B with a sparse matrix C. Takes a random submatrix of a m-times-n matrix B and multiplies it with a randomly generated sparse matrix C. The operation is simultaneously performed using dense arithmetic and the results are compared. Also tests the multiplication of transposed matrices.
m | The number of rows of the dense matrix C. |
n | The number of cols ot the sparse matrix B. |
ntests | The number of tests to be performed. |
verbose | If true, the test results of each test are printed to stdout. |
Definition at line 685 of file test_sparse.cc.
References C, get_maximum_error(), i, joker, min, mult(), random_fill_matrix(), Matrix::resize(), and transpose().
Test sparse identity matrix.
Test the creation of sparse identity matrices using Sparse::make_I(...). For each test, a randomly sized sparse matrix is created and set to the identity matrix. The result is compared to the result of the dense couterpart identity(...). ntests sets the number of tests to be performed. Also tests if the matrix was correctly resized. If the resize fails the function returns 1.0.
ntest | The number of tests to perform. |
verbose | If true, test results for each test are printed to stdout. |
Definition at line 519 of file test_sparse.cc.
References get_maximum_error(), i, id_mat(), n, Sparse::ncols(), Sparse::nrows(), Sparse::resize(), and Matrix::resize().
Test sparse insert_row function.
Performs ntests randomized tests of the Sparse::insert_row(...) function. For each test a random vector is inserted as row r into a sparse matrix. The sparse matrix is then transformed into a dense matrix and the row r compared to the vector. Return the maximum error between the rth row in the sparse matrix and the inserted vector, which should be 0.
ntests | Number of test to perform. |
verbose | If verbose == true, the error for each test is printed to stdout. |
Definition at line 457 of file test_sparse.cc.
References get_maximum_error(), i, Sparse::insert_row(), joker, n, Sparse::ncols(), Sparse::nrows(), r, random_fill_vector(), Sparse::resize(), Vector::resize(), and Matrix::resize().
Test sparse matrix arithmetic.
Test multiplication, addition and subtraction of sparse matrices using the corresponding dense operations. The operations performed are
A x B, C + D, C - D
for a m-times-n matrix C, a m-times-m matrix A, a m-times-n matrix B and a m-times-n matrix D.
m | The number of rows of C |
n | The number of columns of C |
ntests | The number of test to be performed |
verbose | If true, the results of each test are printed to stdout. |
Definition at line 1028 of file test_sparse.cc.
References add(), C, get_maximum_error(), i, mult(), random_fill_matrix(), and sub().
Referenced by main().
Test sparse matrix construction.
Performs ntests of the construction and conversion of sparse matrices to dense matrices. In each test a sparse m-times-n matrix is created and filled with random values. The matrix is then converted to a dense matrix and the error between the two matrices is computed.
m | The number of rows of the sparse matrix. |
n | The number of columns of the sparse matrix. |
ntests | The number of test to be performed. |
verbose | If true, the results of each test are printed to stdout. |
Definition at line 570 of file test_sparse.cc.
References get_maximum_error(), i, and random_fill_matrix().
Test sparse-dense multiplication.
Test multiplication B x C of a sparse matrix B with a dense matrix C. Takes a random submatrix of a m-times-n matrix C and multiplies it with a randomly generated sparse matrix B. The operation is simultaneously performed using dense arithmetic and the results are compared. Also test the multiplication of transposed matrices.
m | The number of rows of the dense matrix C. |
n | The number of cols ot the sparse matrix B. |
ntests | The number of tests to be performed. |
verbose | If true, the test results of each test are printed to stdout. |
Definition at line 805 of file test_sparse.cc.
References C, get_maximum_error(), i, joker, min, mult(), random_fill_matrix(), Matrix::resize(), and transpose().
Test sparse multiplication.
Test multiplication of sparse matrices with sparse and dense matrices as well as vectors. Performs ntests test, where in each test the product of two sparse matrices, of a sparse and a dense matrix and of a sparse matrix and a vector are computed:
Matrix-matrix product: A = B x C Matrix-vector product: y = B * x
Where A is a m-times-n matrix and B a m-times-k matrix, where k is picked randomly for each test from the range [1,999]. The results are compared to the results obtained using dense arithmetic and the maximum relative error taken over all tests is returned.
m | Number of rows of A. |
n | Number of columns of A. |
ntests | Number of tests to perform. |
verbose | If true, the results of each test are printed to stdout. |
Definition at line 932 of file test_sparse.cc.
References i.
Test unary operation on sparse matrices.
Perform ntests tests of the unary operation on sparse matrices (abs(...), transpose(...)) as well as construction of sparse matrices using rw, ro. The test of the construction of sparse matrix is done by filling a dense matrix with identical random values at the same positions and comparing the dense and the sparse matrices.
m | The number of rows of the sparse matrix. |
n | The number of colums of the sparse matrix. |
ntests | The number of tests to be performed. |
verbose | If true, results for each test are printed to stdout. |
Definition at line 613 of file test_sparse.cc.
References get_maximum_error(), i, and random_fill_matrix().
Definition at line 411 of file test_sparse.cc.
References FILE_TYPE_ASCII, get_maximum_error(), i, n, random_fill_matrix(), xml_read_from_file(), and xml_write_to_file().