ARTS  2.4.0(git:4fb77825)
test_linalg.cc File Reference

Test for the linear algebra functions. More...

#include <stdlib.h>
#include <time.h>
#include <cmath>
#include <iostream>
#include <random>
#include "array.h"
#include "lin_alg.h"
#include "test_utils.h"

Go to the source code of this file.

Functions

void test_lusolve1D (void)
 
void test_lusolve4D (void)
 
void test_solve_linear_system (Index ntests, Index dim, bool verbose)
 Test ludcmp and lubacksub by solving a linear system of equations. More...
 
void test_inv (Index ntests, Index dim, bool verbose=false)
 Test matrix inversion. More...
 
void test_matrix_exp4D (void)
 Test for the matrix exponential function (4D matrix) More...
 
void test_matrix_exp1D (void)
 Test for the matrix exponential function (3D matrix) More...
 
void test_matrix_exp3D (void)
 Test for the matrix exponential function (3D matrix) More...
 
void test_real_diagonalize (Index ntests, Index dim)
 
void test_complex_diagonalize (Index ntests, Index dim)
 
void test_matrix_exp_propmat (Index nruns, Index ndiffs)
 
int main (void)
 

Detailed Description

Test for the linear algebra functions.

Author
Claudia Emde claud.nosp@m.ia.e.nosp@m.mde@d.nosp@m.lr.d.nosp@m.e
Date
Thu May 2 14:37:57 2002

Definition in file test_linalg.cc.

Function Documentation

◆ main()

int main ( void  )

Definition at line 624 of file test_linalg.cc.

References test_matrix_exp_propmat().

◆ test_complex_diagonalize()

void test_complex_diagonalize ( Index  ntests,
Index  dim 
)

◆ test_inv()

void test_inv ( Index  ntests,
Index  dim,
bool  verbose = false 
)

Test matrix inversion.

Generates a random, square (n,n)-matrix A and computes its inverse Ainv and I = Ainv*A. The maximum absolute error in I with respect to the identity matrix is written to standard out. The number of tests performed is controlled by the parameter ntests. If verbose == true, also A, Ainv and A*Ainv are written to standard out.

Parameters
[in]ntestsNumber of tests to be performed.
[in]dimSize of matrix A.
[in]verboseControls verbosity of output. If true, for each test the matrices A, Ainv and I = Ainv*A are written to standard out. Otherwise only the maximum absolute error in I = Ainv*A w.r.t. the identity matrix is written out.
Returns
void

Definition at line 319 of file test_linalg.cc.

References get_maximum_error(), id_mat(), inv(), mult(), random_fill_matrix_pos_def(), and ARTS::Var::time().

◆ test_lusolve1D()

void test_lusolve1D ( void  )

The function tests the LU-decompusition method for solving a 1D linear equation system. It uses the functions 'ludcmp' and 'lubacksub'.

Definition at line 49 of file test_linalg.cc.

References ludcmp().

◆ test_lusolve4D()

void test_lusolve4D ( void  )

The function tests the LU-decompusition method for solving a linear equation system. It uses the functions 'ludcmp' and 'lubacksub'.

Definition at line 106 of file test_linalg.cc.

References ludcmp(), and mult().

◆ test_matrix_exp1D()

void test_matrix_exp1D ( void  )

Test for the matrix exponential function (3D matrix)

Definition at line 397 of file test_linalg.cc.

References matrix_exp(), and q.

◆ test_matrix_exp3D()

void test_matrix_exp3D ( void  )

Test for the matrix exponential function (3D matrix)

Definition at line 417 of file test_linalg.cc.

References matrix_exp(), and q.

◆ test_matrix_exp4D()

void test_matrix_exp4D ( void  )

Test for the matrix exponential function (4D matrix)

Definition at line 359 of file test_linalg.cc.

References matrix_exp(), and q.

◆ test_matrix_exp_propmat()

void test_matrix_exp_propmat ( Index  nruns,
Index  ndiffs 
)

Definition at line 528 of file test_linalg.cc.

Referenced by main().

◆ test_real_diagonalize()

void test_real_diagonalize ( Index  ntests,
Index  dim 
)

◆ test_solve_linear_system()

void test_solve_linear_system ( Index  ntests,
Index  dim,
bool  verbose 
)

Test ludcmp and lubacksub by solving a linear system of equations.

Generates a random, square (n,n)-matrix A and a length-n vector x0 and solves A*x = A*x0. The maximum relative, component-wise error in abs(x0 - x) is written to standard out. The numbers of tests performed is controlled by the parameter ntests. If verbose == true, also A, x0 and x are written to standard out.

Parameters
[in]ntestsNumber of tests to be performed.
[in]dimDimensionality of the equation system.
[in]verboseControls verbosity of output. If true, for each test the matrix A and the vectors x0 and x are written to standard out. Otherwise only the maximum relative error in each component of x is written out.
Returns
void

Definition at line 252 of file test_linalg.cc.

References get_maximum_error(), lubacksub(), ludcmp(), mult(), random_fill_matrix_pos_def(), random_fill_vector(), solve(), ARTS::Var::time(), ARTS::Var::x(), and x0.