ARTS  2.3.1285(git:92a29ea9-dirty)
complex.h File Reference

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

#include <complex>
#include "lapack.h"
#include "matpackI.h"

Go to the source code of this file.

Classes

class  ComplexIterator1D
 The iterator class for sub vectors. More...
 
class  ConstComplexIterator1D
 The constant iterator class for sub vectors. More...
 
class  ConstComplexVectorView
 A constant view of a ComplexVector. More...
 
class  ComplexVectorView
 The ComplexVectorView class. More...
 
class  ComplexIterator2D
 The row iterator class for sub matrices. More...
 
class  ConstComplexIterator2D
 The const row iterator class for sub matrices. More...
 
class  ComplexVector
 The ComplexVector class. More...
 
class  ConstComplexMatrixView
 A constant view of a ComplexMatrix. More...
 
class  ComplexMatrixView
 The ComplexMatrixView class. More...
 
class  ComplexMatrix
 The ComplexMatrix class. More...
 

Macros

#define a1   c.real()
 
#define b1   c.imag()
 
#define a2   z.real()
 
#define b2   z.imag()
 
#define _complex_operations_(T)
 

Typedefs

typedef std::complex< NumericComplex
 
typedef Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrixType
 
typedef Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > ComplexStrideType
 
typedef Eigen::Map< ComplexMatrixType, 0, ComplexStrideTypeComplexMatrixViewMap
 
typedef Eigen::Map< const ComplexMatrixType, 0, ComplexStrideTypeComplexConstMatrixViewMap
 
typedef Array< ComplexVectorArrayOfComplexVector
 
typedef Array< ComplexMatrixArrayOfComplexMatrix
 

Functions

std::complex< float > operator+ (const double &d, const std::complex< float > &c)
 
std::complex< float > operator* (const double &d, const std::complex< float > &c)
 
std::complex< float > operator+ (const std::complex< float > &c, const double &d)
 
std::complex< float > operator* (const std::complex< float > &c, const double &d)
 
constexpr Numeric abs2 (Complex c)
 squared magnitude of c More...
 
constexpr Complex conj (Complex c)
 the conjugate of c More...
 
constexpr Complex operator+ (Complex c, Numeric n)
 
constexpr Complex operator- (Complex c, Numeric n)
 
constexpr Complex operator* (Complex c, Numeric n)
 
constexpr Complex operator/ (Complex c, Numeric n)
 
constexpr Complex operator+ (Numeric n, Complex c)
 
constexpr Complex operator- (Numeric n, Complex c)
 
constexpr Complex operator* (Numeric n, Complex c)
 
constexpr Complex operator/ (Numeric n, Complex c)
 
constexpr Complex operator+ (Complex c, Complex z)
 
constexpr Complex operator- (Complex c, Complex z)
 
constexpr Complex operator* (Complex c, Complex z)
 
constexpr Complex operator/ (Complex c, Complex z)
 
 _complex_operations_ (int) _complex_operations_(float) _complex_operations_(Index) extern const Joker joker
 
ConstComplexMatrixView transpose (ConstComplexMatrixView m)
 Const version of transpose. More...
 
ComplexMatrixView transpose (ComplexMatrixView m)
 Returns the transpose. 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 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 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 ConstMatrixView &B, const ConstComplexMatrixView &C)
 
void mult (ComplexMatrixView A, const ConstComplexMatrixView &B, const ConstMatrixView &C)
 
void mult (ComplexMatrixView A, const ConstMatrixView &B, const ConstMatrixView &C)
 
Complex operator* (const ConstComplexVectorView &a, const ConstComplexVectorView &b)
 Scalar product. More...
 
std::ostream & operator<< (std::ostream &os, const ConstComplexVectorView &v)
 Output operator. More...
 
std::ostream & operator<< (std::ostream &os, const ConstComplexMatrixView &v)
 Output operator. More...
 
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)
 

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.h.

Macro Definition Documentation

◆ _complex_operations_

#define _complex_operations_ (   T)
Value:
constexpr Complex operator+(Complex c, T x) { \
return operator+(c, static_cast<Numeric>(x)); \
} \
constexpr Complex operator-(Complex c, T x) { \
return operator-(c, static_cast<Numeric>(x)); \
} \
constexpr Complex operator*(Complex c, T x) { \
return operator*(c, static_cast<Numeric>(x)); \
} \
constexpr Complex operator/(Complex c, T x) { \
return operator/(c, static_cast<Numeric>(x)); \
} \
\
constexpr Complex operator+(T x, Complex c) { \
return operator+(static_cast<Numeric>(x), c); \
} \
constexpr Complex operator-(T x, Complex c) { \
return operator-(static_cast<Numeric>(x), c); \
} \
constexpr Complex operator*(T x, Complex c) { \
return operator*(static_cast<Numeric>(x), c); \
} \
constexpr Complex operator/(T x, Complex c) { \
return operator/(static_cast<Numeric>(x), c); \
}
constexpr Complex operator/(Complex c, Numeric n)
Definition: complex.h:79
std::complex< Numeric > Complex
Definition: complex.h:33
std::complex< float > operator*(const double &d, const std::complex< float > &c)
Definition: complex.h:39
constexpr Complex operator-(Complex c, Numeric n)
Definition: complex.h:73
std::complex< float > operator+(const double &d, const std::complex< float > &c)
Definition: complex.h:35

Definition at line 118 of file complex.h.

◆ a1

◆ a2

◆ b1

◆ b2

Typedef Documentation

◆ ArrayOfComplexMatrix

Definition at line 949 of file complex.h.

◆ ArrayOfComplexVector

Definition at line 948 of file complex.h.

◆ Complex

typedef std::complex<Numeric> Complex

Definition at line 33 of file complex.h.

◆ ComplexConstMatrixViewMap

Definition at line 172 of file complex.h.

◆ ComplexMatrixType

typedef Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> ComplexMatrixType

Definition at line 163 of file complex.h.

◆ ComplexMatrixViewMap

Definition at line 170 of file complex.h.

◆ ComplexStrideType

typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> ComplexStrideType

Definition at line 168 of file complex.h.

Function Documentation

◆ _complex_operations_()

_complex_operations_ ( int  ) const

◆ abs2()

constexpr Numeric abs2 ( Complex  c)

squared magnitude of c

Definition at line 62 of file complex.h.

◆ conj()

constexpr Complex conj ( Complex  c)

◆ copy() [1/4]

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 ComplexVectorView::end(), ComplexIterator1D::mstride, ConstComplexIterator1D::mstride, ComplexIterator1D::mx, and ConstComplexIterator1D::mx.

Referenced by ComplexMatrix::ComplexMatrix(), ComplexVector::ComplexVector(), Array< QuantumFieldDescription >::operator=(), ComplexVectorView::operator=(), ComplexMatrixView::operator=(), ComplexMatrix::operator=(), InteractiveWorkspace::resize(), and LineShape::LegacyLineMixingData::vector2modellm().

◆ copy() [2/4]

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

Copy a scalar to all elements.

Definition at line 490 of file complex.cc.

References ComplexVectorView::end().

◆ copy() [3/4]

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 ComplexMatrixView::end().

◆ copy() [4/4]

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 ComplexMatrixView::end().

◆ MapToEigen() [1/4]

◆ MapToEigen() [2/4]

◆ MapToEigen() [3/4]

◆ MapToEigen() [4/4]

◆ MapToEigenCol() [1/2]

◆ MapToEigenCol() [2/2]

◆ MapToEigenRow() [1/2]

ComplexConstMatrixViewMap MapToEigenRow ( const ConstComplexVectorView A)

Definition at line 1672 of file complex.cc.

References ConstComplexMatrixView::MapToEigen.

Referenced by ComplexMatrix::get_raw_data(), and mult().

◆ MapToEigenRow() [2/2]

ComplexMatrixViewMap MapToEigenRow ( ComplexVectorView A)

Definition at line 1702 of file complex.cc.

References ConstComplexMatrixView::MapToEigen.

◆ mult() [1/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 ConstComplexMatrixView::MapToEigen, MapToEigenRow(), ConstComplexVectorView::mdata, ConstComplexMatrixView::ncols(), ConstComplexVectorView::nelem(), and ConstComplexMatrixView::nrows().

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(), ComplexMatrix::get_raw_data(), get_stepwise_effective_source(), get_stepwise_transmission_matrix(), interpTArray(), iy_transmission_mult(), iyHybrid(), iySurfaceFastem(), QuadraticModel::Jacobian(), jacobianCalcFreqShift(), jacobianCalcFreqStretch(), jacobianCalcPointingZaInterp(), jacobianCalcPointingZaRecalc(), lsf(), main(), matrix_vector_mult(), MatrixMatrixMultiply(), MatrixVectorMultiply(), MCGeneral(), MCIPA(), mcPathTraceRadar(), MCRadar(), met_mm_polarisation_hmatrix(), oem_cost_x(), oem_cost_y(), oem_gauss_newton_m_form(), oem_gauss_newton_n_form(), oem_linear_mform(), random_fill_matrix_pos_def(), random_fill_matrix_pos_semi_def(), MCAntenna::return_los(), rte_step_doit_replacement(), rtmethods_jacobian_finalisation(), scale_rows(), 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(), x2artsSpectroscopy(), yActive(), yCalc(), yCalc_mblock_loop_body(), and ySimpleSpectrometer().

◆ mult() [2/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 ConstComplexMatrixView::MapToEigen, ConstComplexMatrixView::mdata, ConstComplexMatrixView::ncols(), and ConstComplexMatrixView::nrows().

◆ mult() [3/5]

◆ mult() [4/5]

◆ mult() [5/5]

◆ operator*() [1/6]

std::complex<float> operator* ( const double &  d,
const std::complex< float > &  c 
)
inline

Definition at line 39 of file complex.h.

◆ operator*() [2/6]

std::complex<float> operator* ( const std::complex< float > &  c,
const double &  d 
)
inline

Definition at line 48 of file complex.h.

◆ operator*() [3/6]

constexpr Complex operator* ( Complex  c,
Numeric  n 
)

Definition at line 76 of file complex.h.

◆ operator*() [4/6]

constexpr Complex operator* ( Numeric  n,
Complex  c 
)

Definition at line 89 of file complex.h.

◆ operator*() [5/6]

constexpr Complex operator* ( Complex  c,
Complex  z 
)

Definition at line 102 of file complex.h.

◆ operator*() [6/6]

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/5]

std::complex<float> operator+ ( const double &  d,
const std::complex< float > &  c 
)
inline

Definition at line 35 of file complex.h.

◆ operator+() [2/5]

std::complex<float> operator+ ( const std::complex< float > &  c,
const double &  d 
)
inline

Definition at line 44 of file complex.h.

◆ operator+() [3/5]

constexpr Complex operator+ ( Complex  c,
Numeric  n 
)

Definition at line 70 of file complex.h.

◆ operator+() [4/5]

constexpr Complex operator+ ( Numeric  n,
Complex  c 
)

Definition at line 83 of file complex.h.

◆ operator+() [5/5]

constexpr Complex operator+ ( Complex  c,
Complex  z 
)

Definition at line 96 of file complex.h.

◆ operator-() [1/3]

constexpr Complex operator- ( Complex  c,
Numeric  n 
)

Definition at line 73 of file complex.h.

Referenced by Iterator1D::operator!=().

◆ operator-() [2/3]

constexpr Complex operator- ( Numeric  n,
Complex  c 
)

Definition at line 86 of file complex.h.

◆ operator-() [3/3]

constexpr Complex operator- ( Complex  c,
Complex  z 
)

Definition at line 99 of file complex.h.

◆ operator/() [1/3]

constexpr Complex operator/ ( Complex  c,
Numeric  n 
)

Definition at line 79 of file complex.h.

◆ operator/() [2/3]

constexpr Complex operator/ ( Numeric  n,
Complex  c 
)

Definition at line 92 of file complex.h.

◆ operator/() [3/3]

constexpr Complex operator/ ( Complex  c,
Complex  z 
)

Definition at line 105 of file complex.h.

◆ operator<<() [1/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 i.

Referenced by ComplexMatrix::get_raw_data().

◆ operator<<() [2/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().

◆ transpose() [1/2]

◆ transpose() [2/2]

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 ComplexMatrixView::ComplexMatrixView(), ConstComplexMatrixView::mcr, ConstComplexMatrixView::mdata, and ConstComplexMatrixView::mrr.