ARTS 2.5.9 (git: 825fa5f2)
test_matpack.cc File Reference
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <exception>
#include <iostream>
#include "array.h"
#include "describe.h"
#include "exceptions.h"
#include "logic.h"
#include "math_funcs.h"
#include "matpackII.h"
#include "matpackVII.h"
#include "matpack_eigen.h"
#include "mystring.h"
#include "rational.h"
#include "test_utils.h"
#include "time.h"
#include "wigner_functions.h"

Go to the source code of this file.

Macros

#define docheck(fn, val, expect)
 

Functions

Numeric by_reference (const Numeric &x)
 
Numeric by_value (Numeric x)
 
void fill_with_junk (VectorView x)
 
void fill_with_junk (MatrixView x)
 
int test1 ()
 
void test2 ()
 
void test4 ()
 
void test5 ()
 
void test6 ()
 
void test7 ()
 
void test8 ()
 
void test9 ()
 
void test10 ()
 
void test11 ()
 
void test12 ()
 
void test13 ()
 
void test14 ()
 
void test15 ()
 
void test17 ()
 
void test18 ()
 
void test19 ()
 
void test20 ()
 
void test21 ()
 
void test22 ()
 
void test23 ()
 
void test24 ()
 
void test25 ()
 
void test26 ()
 
void test27 ()
 
void test28 ()
 
void test29 ()
 
void test30 ()
 
void test31 ()
 
void test32 ()
 
void test33 ()
 
void junk4 (Tensor4View a)
 
void junk2 (ConstVectorView a)
 
void test34 ()
 
void test35 ()
 
void test36 ()
 
void test37 (const Index &i)
 
void test38 ()
 
void test39 ()
 
void test40 ()
 
void test41 ()
 
void test42 ()
 
constexpr Rational test_numeric2rational (const Index i, const Index maxi, const Rational r=0, const Rational n2r=0)
 
void test43 ()
 
void test44 ()
 
void test46 ()
 
bool test_diagonal (Index ntests)
 Test diagonal vector. More...
 
Numeric matrix_vector_mult (Index m, Index n, Index ntests, bool verbose)
 
Numeric test_matrix_vector_multiplication (bool verbose)
 
Numeric matrix_mult (Index k, Index m, Index n, Index ntests, Index nsubtests, bool verbose)
 Perform matrix multiplication test. More...
 
Numeric test_matrix_multiplication (bool verbose)
 Perform matrix multiplication tests. More...
 
void test_empty ()
 Check if the empty function is working correctly. More...
 
void nlinspace (Vector &x, const Numeric start, const Numeric stop, const Index n)
 nlinspace More...
 
void test47 ()
 
void test48 ()
 
void test_wigner_error ()
 
void test_pow_negative_one ()
 
void test_concepts ()
 
int main ()
 

Macro Definition Documentation

◆ docheck

#define docheck (   fn,
  val,
  expect 
)
Value:
cout << #fn << "(" << val << ") = " << fn(x) << " (expected " << #expect \
<< ")" << std::endl;

Function Documentation

◆ by_reference()

Numeric by_reference ( const Numeric x)

Definition at line 41 of file test_matpack.cc.

Referenced by test21().

◆ by_value()

Numeric by_value ( Numeric  x)

Definition at line 43 of file test_matpack.cc.

Referenced by test22().

◆ fill_with_junk() [1/2]

void fill_with_junk ( MatrixView  x)

Definition at line 47 of file test_matpack.cc.

◆ fill_with_junk() [2/2]

void fill_with_junk ( VectorView  x)

Definition at line 45 of file test_matpack.cc.

Referenced by test1().

◆ junk2()

void junk2 ( ConstVectorView  a)

Definition at line 605 of file test_matpack.cc.

References a, and describe().

Referenced by test34().

◆ junk4()

void junk4 ( Tensor4View  a)

Definition at line 603 of file test_matpack.cc.

References a, and describe().

Referenced by test34().

◆ main()

int main ( void  )

Definition at line 1841 of file test_matpack.cc.

References test_concepts().

◆ matrix_mult()

Numeric matrix_mult ( Index  k,
Index  m,
Index  n,
Index  ntests,
Index  nsubtests,
bool  verbose 
)

Perform matrix multiplication test.

Creates to random m times k matrix A and a random k times n matrix B and computes C = A * B, C = A^T * B, C = A * B^T, C = A^T * B^T unsing the mult function from matpackI.cc. The result is verified using the mult_general functions. In addition to the operations above, ntests numbers of random submatrices of A and B are generated and their multiplication is also tested. Returns the maximum element-wise, relative error that occurred in the tests.

Parameters
[in]kDimension over which the multiplication is performed.
[in]mNumber of rows of A.
[in]nNumber of coluns of B.
[in]ntestsNumber of standard multiplications to be performed.
[in]nsubtestsNumber of submatrix multiplications to be performed.
[in]boolIf verbose is true the results of each test are printed to standard out.
Returns
The maximum element-wise, relative error that occured in the tests.

Definition at line 1060 of file test_matpack.cc.

References get_maximum_error(), mult(), mult_general(), random_fill_matrix(), random_range(), and transpose().

Referenced by test_matrix_multiplication().

◆ matrix_vector_mult()

Numeric matrix_vector_mult ( Index  m,
Index  n,
Index  ntests,
bool  verbose 
)

◆ nlinspace()

void nlinspace ( Vector x,
const Numeric  start,
const Numeric  stop,
const Index  n 
)

nlinspace

Linearly spaced vector with specified length.

Returns a vector equally and linearly spaced between start and stop of length n. (equals the Matlab function linspace)

The length must be > 1.

Parameters
xOutput: linearly spaced vector
startfirst value in x
stoplast value of x <= stop
nlength of x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 1334 of file test_matpack.cc.

References ARTS_ASSERT, and Vector::resize().

Referenced by test46().

◆ test1()

int test1 ( )

◆ test10()

void test10 ( )

Definition at line 230 of file test_matpack.cc.

References M, and v.

◆ test11()

void test11 ( )

Definition at line 240 of file test_matpack.cc.

References M, and v.

◆ test12()

void test12 ( )

Definition at line 251 of file test_matpack.cc.

References Array< base >::nelem().

◆ test13()

void test13 ( )

Definition at line 268 of file test_matpack.cc.

References M, and v.

◆ test14()

void test14 ( )

Definition at line 278 of file test_matpack.cc.

References a, b, and c.

◆ test15()

void test15 ( )

Definition at line 288 of file test_matpack.cc.

References a, and b.

◆ test17()

void test17 ( )

Definition at line 310 of file test_matpack.cc.

References a.

◆ test18()

void test18 ( )

Definition at line 316 of file test_matpack.cc.

References a.

◆ test19()

void test19 ( )

Definition at line 323 of file test_matpack.cc.

References a, and b.

◆ test2()

void test2 ( )

Definition at line 131 of file test_matpack.cc.

References v.

Referenced by test_transmat_from_propmat().

◆ test20()

void test20 ( )

Definition at line 334 of file test_matpack.cc.

References a.

◆ test21()

void test21 ( )

Definition at line 340 of file test_matpack.cc.

References by_reference().

◆ test22()

void test22 ( )

Definition at line 351 of file test_matpack.cc.

References by_value().

◆ test23()

void test23 ( )

Definition at line 362 of file test_matpack.cc.

References a, and b.

◆ test24()

void test24 ( )

Definition at line 370 of file test_matpack.cc.

References a, and b.

◆ test25()

void test25 ( )

Definition at line 384 of file test_matpack.cc.

References a, max(), and min().

◆ test26()

void test26 ( )

Definition at line 390 of file test_matpack.cc.

References a.

◆ test27()

void test27 ( )

Definition at line 396 of file test_matpack.cc.

References a.

◆ test28()

void test28 ( )

Definition at line 404 of file test_matpack.cc.

References a, and b.

◆ test29()

void test29 ( )

Definition at line 411 of file test_matpack.cc.

References a, and b.

◆ test30()

void test30 ( )

Definition at line 435 of file test_matpack.cc.

References a, b, and c.

◆ test31()

void test31 ( )

Definition at line 456 of file test_matpack.cc.

References a, joker, max(), sqrt(), and transform().

◆ test32()

void test32 ( )

Definition at line 520 of file test_matpack.cc.

References mult().

◆ test33()

void test33 ( )

Definition at line 542 of file test_matpack.cc.

References a, b, describe(), and transpose().

◆ test34()

void test34 ( )

Definition at line 607 of file test_matpack.cc.

References junk2(), and junk4().

◆ test35()

void test35 ( )

Definition at line 617 of file test_matpack.cc.

References a, b, c, and d.

◆ test36()

void test36 ( )

Definition at line 636 of file test_matpack.cc.

References a, b, and joker.

◆ test37()

void test37 ( const Index i)

Definition at line 644 of file test_matpack.cc.

◆ test38()

void test38 ( )

Definition at line 659 of file test_matpack.cc.

References a, b, c, Tensor3View::get_c_array(), ConstMatrixView::get_c_array(), and v.

◆ test39()

void test39 ( )

Definition at line 684 of file test_matpack.cc.

◆ test4()

void test4 ( )

Definition at line 143 of file test_matpack.cc.

References a, b, joker, and mult().

Referenced by test_transmat_from_propmat().

◆ test40()

void test40 ( )

Definition at line 696 of file test_matpack.cc.

References v.

◆ test41()

void test41 ( )

Definition at line 704 of file test_matpack.cc.

◆ test42()

void test42 ( )

Definition at line 726 of file test_matpack.cc.

References joker.

◆ test43()

◆ test44()

void test44 ( )

Definition at line 801 of file test_matpack.cc.

References docheck, is_decreasing(), is_increasing(), and is_sorted().

◆ test46()

void test46 ( )

Definition at line 837 of file test_matpack.cc.

References VectorView::begin(), VectorView::end(), nlinspace(), and v.

◆ test47()

void test47 ( )

◆ test48()

◆ test5()

void test5 ( )

Definition at line 169 of file test_matpack.cc.

References a, b, M, mult(), and transpose().

◆ test6()

void test6 ( )

Definition at line 188 of file test_matpack.cc.

References M, and transform().

◆ test7()

void test7 ( )

Definition at line 209 of file test_matpack.cc.

References max(), min(), ConstVectorView::nelem(), and transform().

◆ test8()

void test8 ( )

Definition at line 216 of file test_matpack.cc.

References ConstVectorView::nelem().

◆ test9()

void test9 ( )

Definition at line 223 of file test_matpack.cc.

References joker.

◆ test_concepts()

◆ test_diagonal()

bool test_diagonal ( Index  ntests)

Test diagonal vector.

Generates ntest random (m,n)-matrices and checks if the returned diagonal vector has the same entries as the diagonal. Also test transposed matrices and submatrices of the generated matrix.

Parameters
[in]ntestsNumber of tests to run.
Returns
True if all tests were passed, false otherwise.

Definition at line 856 of file test_matpack.cc.

References ConstMatrixView::diagonal(), ConstMatrixView::ncols(), ConstVectorView::nelem(), ConstMatrixView::nrows(), random_fill_matrix(), transpose(), and v.

◆ test_empty()

void test_empty ( )

Check if the empty function is working correctly.

Definition at line 1225 of file test_matpack.cc.

References v.

◆ test_matrix_multiplication()

Numeric test_matrix_multiplication ( bool  verbose)

Perform matrix multiplication tests.

Use matrix_mult function to perform matrix multiplication tests, for different combinations of dimensions including: k = m = n = 0 k = m = n = 1 k = 10, m = n = 1 k = 10, m = 100, n = 10 k = 10, m = 100, n = 100 k = m = n = 100

Definition at line 1183 of file test_matpack.cc.

References matrix_mult().

◆ test_matrix_vector_multiplication()

Numeric test_matrix_vector_multiplication ( bool  verbose)

Definition at line 985 of file test_matpack.cc.

References matrix_vector_mult().

◆ test_numeric2rational()

constexpr Rational test_numeric2rational ( const Index  i,
const Index  maxi,
const Rational  r = 0,
const Rational  n2r = 0 
)
constexpr

Definition at line 748 of file test_matpack.cc.

References numeric2rational(), and test_numeric2rational().

Referenced by test43(), and test_numeric2rational().

◆ test_pow_negative_one()

void test_pow_negative_one ( )

Definition at line 1823 of file test_matpack.cc.

References pow_negative_one().

◆ test_wigner_error()

void test_wigner_error ( )

Definition at line 1812 of file test_matpack.cc.

References make_wigner_ready(), and wigner3j().