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

A class implementing complex numbers for ARTS. More...

#include "complex.h"
#include <cmath>
#include <cstring>
#include "blas.h"
#include "exceptions.h"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const ConstComplexVectorView &v)
 Output operator. More...
 
void copy (ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
 Copy data between begin and end to target. More...
 
void copy (Complex x, ComplexIterator1D target, const ComplexIterator1D &end)
 Copy a scalar to all elements. More...
 
void swap (ComplexVector &v1, ComplexVector &v2)
 Swaps two objects. More...
 
std::ostream & operator<< (std::ostream &os, const ConstComplexMatrixView &v)
 Output operator. More...
 
void copy (ConstComplexIterator2D origin, const ConstComplexIterator2D &end, ComplexIterator2D target)
 Copy data between begin and end to target. More...
 
void copy (Complex x, ComplexIterator2D target, const ComplexIterator2D &end)
 Copy a scalar to all elements. More...
 
void copy (Numeric x, ComplexIterator2D target, const ComplexIterator2D &end)
 Copy a scalar to all elements. More...
 
void swap (ComplexMatrix &m1, ComplexMatrix &m2)
 Swaps two objects. More...
 
ConstComplexMatrixView transpose (ConstComplexMatrixView m)
 Const version of transpose. More...
 
ComplexMatrixView transpose (ComplexMatrixView m)
 Returns the transpose. More...
 
ComplexMatrixView transpose (ComplexVector v)
 Returns the transpose. More...
 
Complex operator* (const ConstComplexVectorView &a, const ConstComplexVectorView &b)
 Scalar product. More...
 
void mult (ComplexVectorView y, const ConstComplexMatrixView &M, const ConstComplexVectorView &x)
 Matrix-Vector Multiplication. More...
 
void mult (ComplexMatrixView A, const ConstComplexMatrixView &B, const ConstComplexMatrixView &C)
 Matrix-Matrix Multiplication. More...
 
void mult (ComplexMatrixView A, const ConstComplexMatrixView &B, const ConstMatrixView &C)
 
void mult (ComplexMatrixView A, const ConstMatrixView &B, const ConstComplexMatrixView &C)
 
void mult (ComplexMatrixView A, const ConstMatrixView &B, const ConstMatrixView &C)
 
ComplexConstMatrixViewMap MapToEigen (const ConstComplexMatrixView &A)
 
ComplexConstMatrixViewMap MapToEigen (const ConstComplexVectorView &A)
 
ComplexConstMatrixViewMap MapToEigenRow (const ConstComplexVectorView &A)
 
ComplexConstMatrixViewMap MapToEigenCol (const ConstComplexVectorView &A)
 
ComplexMatrixViewMap MapToEigen (ComplexMatrixView &A)
 
ComplexMatrixViewMap MapToEigen (ComplexVectorView &A)
 
ComplexMatrixViewMap MapToEigenRow (ComplexVectorView &A)
 
ComplexMatrixViewMap MapToEigenCol (ComplexVectorView &A)
 
Complex debug_matrixview_get_elem (ComplexMatrixView &mv, Index r, Index c)
 Helper function to access matrix elements. More...
 

Detailed Description

A class implementing complex numbers for ARTS.

Author
Oliver Lemke olemk.nosp@m.e@co.nosp@m.re-du.nosp@m.mp.i.nosp@m.nfo
Date
2002-12-19

Definition in file complex.cc.

Function Documentation

◆ copy() [1/5]

void copy ( Complex  x,
ComplexIterator1D  target,
const ComplexIterator1D end 
)

Copy a scalar to all elements.

Definition at line 490 of file complex.cc.

References Zeeman::end(), and ARTS::Var::x().

◆ copy() [2/5]

void copy ( Complex  x,
ComplexIterator2D  target,
const ComplexIterator2D end 
)

Copy a scalar to all elements.

Definition at line 1328 of file complex.cc.

References ComplexVectorView::begin(), and Zeeman::end().

◆ copy() [3/5]

void copy ( ConstComplexIterator1D  origin,
const ConstComplexIterator1D end,
ComplexIterator1D  target 
)

Copy data between begin and end to target.

Target must be a valid area of memory. Note that the strides in the iterators can be different, so that we can for example copy data between different kinds of subvectors.

Definition at line 478 of file complex.cc.

References Zeeman::end(), ComplexIterator1D::mstride, ConstComplexIterator1D::mstride, ComplexIterator1D::mx, and ConstComplexIterator1D::mx.

Referenced by ComplexMatrix::ComplexMatrix(), ComplexVector::ComplexVector(), ComplexMatrix::operator=(), Array< base >::operator=(), ComplexMatrixView::operator=(), ComplexVectorView::operator=(), and InteractiveWorkspace::resize().

◆ copy() [4/5]

void copy ( ConstComplexIterator2D  origin,
const ConstComplexIterator2D end,
ComplexIterator2D  target 
)

Copy data between begin and end to target.

Target must be a valid area of memory. Note that the strides in the iterators can be different, so that we can for example copy data between different kinds of subvectors.

Origin, end, and target are 2D iterators, marking rows in a matrix. For each row the 1D iterator is obtained and used to copy the elements.

Definition at line 1316 of file complex.cc.

References ConstComplexVectorView::begin(), and Zeeman::end().

◆ copy() [5/5]

void copy ( Numeric  x,
ComplexIterator2D  target,
const ComplexIterator2D end 
)

Copy a scalar to all elements.

Definition at line 1337 of file complex.cc.

References ComplexVectorView::begin(), and Zeeman::end().

◆ debug_matrixview_get_elem()

Complex debug_matrixview_get_elem ( ComplexMatrixView mv,
Index  r,
Index  c 
)

Helper function to access matrix elements.

Because of function inlining the operator() is not accessible from the debuggger. This function helps to access Matrix elements from within the debugger.

Parameters
mvMatrixView
rRow index
cColumn index
Author
Oliver Lemke
Date
2004-05-10

Definition at line 1731 of file complex.cc.

◆ MapToEigen() [1/4]

◆ MapToEigen() [2/4]

◆ MapToEigen() [3/4]

◆ MapToEigen() [4/4]

◆ MapToEigenCol() [1/2]

◆ MapToEigenCol() [2/2]

◆ MapToEigenRow() [1/2]

ComplexMatrixViewMap MapToEigenRow ( ComplexVectorView A)

Definition at line 1702 of file complex.cc.

References MapToEigen().

◆ MapToEigenRow() [2/2]

ComplexConstMatrixViewMap MapToEigenRow ( const ConstComplexVectorView A)

Definition at line 1672 of file complex.cc.

References MapToEigen().

Referenced by mult().

◆ mult() [1/5]

void mult ( ComplexMatrixView  A,
const ConstComplexMatrixView B,
const ConstComplexMatrixView C 
)

Matrix-Matrix Multiplication.

Uses the Eigen library. Be carful to test the size of your input beforehand. Note that to keep speed, the inputs should be different variables. There is memory duplication if this is not the case. Note that it is mdata that is checked, so even if the matrices are at different parts of a tensor, there is still a slowdown

Parameters
[in,out]AThe matrix A, that will hold the result of the multiplication.
[in]BThe matrix B
[in]CThe matrix C

Definition at line 1604 of file complex.cc.

References MapToEigen(), ConstComplexMatrixView::mdata, ConstComplexMatrixView::ncols(), and ConstComplexMatrixView::nrows().

◆ mult() [2/5]

◆ mult() [3/5]

◆ mult() [4/5]

◆ mult() [5/5]

void mult ( ComplexVectorView  y,
const ConstComplexMatrixView M,
const ConstComplexVectorView x 
)

Matrix-Vector Multiplication.

Uses the Eigen library. Be carful to test the size of your input beforehand.

For left-hand multiplication, please use pure matrix-mult.

Parameters
[out]yThe length-m ComplexVectorView where the result is stored.
[in]MReference to the m-times-n Const{Complex,}MatrixView holding the matrix M.
[in]xReference to the length-n Const{Complex,}VectorView holding the vector x.

Definition at line 1579 of file complex.cc.

References M, MapToEigen(), MapToEigenRow(), ARTS::Var::x(), and ARTS::Var::y().

Referenced by benchmark_mult(), benchmark_oem_linear(), cloud_RT_surface(), MCAntenna::draw_los(), LinearModel::evaluate(), QuadraticModel::evaluate(), generate_test_data(), get_diydx(), get_ppath_transmat(), get_stepwise_effective_source(), get_stepwise_transmission_matrix(), iy_transmission_mult(), iyHybrid(), iySurfaceFastem(), QuadraticModel::Jacobian(), jacobianCalcFreqShift(), jacobianCalcFreqStretch(), jacobianCalcPointingZaInterp(), jacobianCalcPointingZaRecalc(), lsf(), main(), matrix_vector_mult(), MatrixMatrixMultiply(), MatrixVectorMultiply(), MCGeneral(), mcPathTraceRadar(), MCRadar(), met_mm_polarisation_hmatrix(), random_fill_matrix_pos_def(), random_fill_matrix_pos_semi_def(), MCAntenna::return_los(), rte_step_doit_replacement(), rtmethods_jacobian_finalisation(), sensor_responseAntenna(), sensor_responseBackend(), sensor_responseFrequencySwitching(), sensor_responseMetMM(), sensor_responseMixer(), sensor_responseMixerBackendPrecalcWeights(), sensor_responsePolarisation(), sensor_responseStokesRotation(), sensor_responseWMRF(), SparseSparseMultiply(), surface_calc(), test4(), test5(), test_complex_diagonalize(), test_dense_sparse_multiplication(), test_inv(), test_lusolve4D(), test_real_diagonalize(), test_solve_linear_system(), test_sparse_arithmetic(), test_sparse_dense_multiplication(), transform_x(), transform_x_back(), VectorMatrixMultiply(), yActive(), yCalc(), yCalc_mblock_loop_body(), and ySimpleSpectrometer().

◆ operator*()

Complex operator* ( const ConstComplexVectorView a,
const ConstComplexVectorView b 
)

Scalar product.

The two vectors may be identical.

Definition at line 1554 of file complex.cc.

References ConstComplexVectorView::begin(), ConstComplexVectorView::end(), and ConstComplexVectorView::nelem().

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  os,
const ConstComplexMatrixView v 
)

Output operator.

This demonstrates how iterators can be used to traverse the matrix. The iterators know which part of the matrix is ‘active’, and also the strides in both directions. This function is a bit more complicated than necessary to illustrate the concept, because the formating should look nice. This means that the first row, and the first element in each row, have to be treated individually.

Definition at line 866 of file complex.cc.

References ConstComplexVectorView::begin(), ConstComplexMatrixView::begin(), ConstComplexVectorView::end(), and ConstComplexMatrixView::end().

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  os,
const ConstComplexVectorView v 
)

Output operator.

This demonstrates how iterators can be used to traverse the vector. The iterators know which part of the vector is ‘active’, and also the stride.

Definition at line 134 of file complex.cc.

References ConstComplexVectorView::begin(), ConstComplexVectorView::end(), and Zeeman::end().

◆ swap() [1/2]

void swap ( ComplexMatrix m1,
ComplexMatrix m2 
)

Swaps two objects.

Definition at line 1474 of file complex.cc.

References ConstComplexMatrixView::mcr, ConstComplexMatrixView::mdata, ConstComplexMatrixView::mrr, and swap().

◆ swap() [2/2]

◆ transpose() [1/3]

Returns the transpose.

This creates a special MatrixView for the transpose. The original is not changed!

Definition at line 1515 of file complex.cc.

References ConstComplexMatrixView::mcr, ConstComplexMatrixView::mdata, and ConstComplexMatrixView::mrr.

◆ transpose() [2/3]

ComplexMatrixView transpose ( ComplexVector  v)

Returns the transpose.

This creates a special MatrixView for the transpose. The original is not changed!

Definition at line 1521 of file complex.cc.

References transpose().

◆ transpose() [3/3]