ARTS  2.3.1285(git:92a29ea9-dirty)
test_matpack.cc File Reference
#include <algorithm>
#include <cmath>
#include <cstdlib>
#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 "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_rat, const Rational n2r=0_rat)
 
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 ()
 
int main ()
 

Macro Definition Documentation

◆ docheck

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

Referenced by test44().

Function Documentation

◆ by_reference()

Numeric by_reference ( const Numeric x)

Definition at line 39 of file test_matpack.cc.

Referenced by test21().

◆ by_value()

Numeric by_value ( Numeric  x)

Definition at line 41 of file test_matpack.cc.

Referenced by test22().

◆ fill_with_junk() [1/2]

void fill_with_junk ( VectorView  x)

Definition at line 43 of file test_matpack.cc.

Referenced by test1().

◆ fill_with_junk() [2/2]

void fill_with_junk ( MatrixView  x)

Definition at line 45 of file test_matpack.cc.

◆ junk2()

void junk2 ( ConstVectorView  a)

Definition at line 603 of file test_matpack.cc.

References describe().

Referenced by test34().

◆ junk4()

void junk4 ( Tensor4View  a)

Definition at line 601 of file test_matpack.cc.

References describe().

Referenced by test34().

◆ main()

int main ( void  )

Definition at line 1361 of file test_matpack.cc.

References test43().

◆ 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 1058 of file test_matpack.cc.

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 1332 of file test_matpack.cc.

References i, Vector::resize(), and Zeeman::start().

Referenced by test46().

◆ test1()

◆ test10()

void test10 ( )

Definition at line 228 of file test_matpack.cc.

References M.

◆ test11()

void test11 ( )

Definition at line 238 of file test_matpack.cc.

References M, and ConstVectorView::nelem().

◆ test12()

void test12 ( )

Definition at line 249 of file test_matpack.cc.

References Array< base >::nelem().

◆ test13()

void test13 ( )

Definition at line 266 of file test_matpack.cc.

References M.

◆ test14()

void test14 ( )

Definition at line 276 of file test_matpack.cc.

◆ test15()

void test15 ( )

Definition at line 286 of file test_matpack.cc.

◆ test17()

void test17 ( )

Definition at line 308 of file test_matpack.cc.

References ConstVectorView::sum().

◆ test18()

void test18 ( )

Definition at line 314 of file test_matpack.cc.

◆ test19()

void test19 ( )

Definition at line 321 of file test_matpack.cc.

◆ test2()

void test2 ( )

Definition at line 129 of file test_matpack.cc.

References ConstVectorView::nelem().

◆ test20()

void test20 ( )

Definition at line 332 of file test_matpack.cc.

◆ test21()

void test21 ( )

Definition at line 338 of file test_matpack.cc.

References by_reference(), and i.

◆ test22()

void test22 ( )

Definition at line 349 of file test_matpack.cc.

References by_value(), and i.

◆ test23()

void test23 ( )

Definition at line 360 of file test_matpack.cc.

◆ test24()

void test24 ( )

Definition at line 368 of file test_matpack.cc.

◆ test25()

void test25 ( )

Definition at line 382 of file test_matpack.cc.

References max, and min.

◆ test26()

void test26 ( )

Definition at line 388 of file test_matpack.cc.

◆ test27()

void test27 ( )

Definition at line 394 of file test_matpack.cc.

◆ test28()

void test28 ( )

Definition at line 402 of file test_matpack.cc.

◆ test29()

void test29 ( )

Definition at line 409 of file test_matpack.cc.

References Matrix::resize().

◆ test30()

void test30 ( )

◆ test31()

void test31 ( )

Definition at line 454 of file test_matpack.cc.

References i, ConstTensor3View::npages(), and ConstTensor3View::nrows().

◆ test32()

void test32 ( )

Definition at line 518 of file test_matpack.cc.

◆ test33()

void test33 ( )

Definition at line 540 of file test_matpack.cc.

References describe(), and transpose().

◆ test34()

void test34 ( )

Definition at line 605 of file test_matpack.cc.

References junk2(), and junk4().

◆ test35()

void test35 ( )

Definition at line 615 of file test_matpack.cc.

◆ test36()

void test36 ( )

Definition at line 634 of file test_matpack.cc.

References joker.

◆ test37()

void test37 ( const Index i)

Definition at line 642 of file test_matpack.cc.

References v1.

◆ test38()

void test38 ( )

Definition at line 657 of file test_matpack.cc.

References VectorView::get_c_array(), and MatrixView::get_c_array().

◆ test39()

void test39 ( )

Definition at line 682 of file test_matpack.cc.

References v1, and v2.

◆ test4()

void test4 ( )

Definition at line 141 of file test_matpack.cc.

References C, i, joker, mult(), and ConstVectorView::nelem().

◆ test40()

void test40 ( )

Definition at line 694 of file test_matpack.cc.

◆ test41()

void test41 ( )

Definition at line 702 of file test_matpack.cc.

References v1.

◆ test42()

void test42 ( )

Definition at line 724 of file test_matpack.cc.

References joker.

◆ test43()

void test43 ( )

Definition at line 758 of file test_matpack.cc.

References r, and test_numeric2rational().

Referenced by main().

◆ test44()

void test44 ( )

Definition at line 799 of file test_matpack.cc.

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

◆ test46()

void test46 ( )

Definition at line 835 of file test_matpack.cc.

References VectorView::begin(), VectorView::end(), n, nlinspace(), and v1.

◆ test47()

void test47 ( )

◆ test5()

void test5 ( )

Definition at line 167 of file test_matpack.cc.

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

◆ test6()

void test6 ( )

Definition at line 186 of file test_matpack.cc.

References i, M, n, and transform().

◆ test7()

void test7 ( )

Definition at line 207 of file test_matpack.cc.

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

◆ test8()

void test8 ( )

Definition at line 214 of file test_matpack.cc.

References i, and ConstVectorView::nelem().

◆ test9()

void test9 ( )

Definition at line 221 of file test_matpack.cc.

References joker.

◆ 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 854 of file test_matpack.cc.

References ConstMatrixView::diagonal(), i, min, ConstMatrixView::ncols(), ConstMatrixView::nrows(), random_fill_matrix(), and transpose().

◆ test_empty()

◆ 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 1181 of file test_matpack.cc.

References matrix_mult().

◆ test_matrix_vector_multiplication()

Numeric test_matrix_vector_multiplication ( bool  verbose)

Definition at line 983 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_rat,
const Rational  n2r = 0_rat 
)

Definition at line 746 of file test_matpack.cc.

References numeric2rational(), and r.

Referenced by test43().