35 inline std::complex<float>
operator+(
const double& d,
36 const std::complex<float>& c) {
37 return (
float(d) + c);
39 inline std::complex<float>
operator*(
const double& d,
40 const std::complex<float>& c) {
41 return (
float(d) * c);
44 inline std::complex<float>
operator+(
const std::complex<float>& c,
46 return (c +
float(d));
48 inline std::complex<float>
operator*(
const std::complex<float>& c,
50 return (c *
float(d));
118 #define _complex_operations_(T) \ 119 constexpr Complex operator+(Complex c, T x) { \ 120 return operator+(c, static_cast<Numeric>(x)); \ 122 constexpr Complex operator-(Complex c, T x) { \ 123 return operator-(c, static_cast<Numeric>(x)); \ 125 constexpr Complex operator*(Complex c, T x) { \ 126 return operator*(c, static_cast<Numeric>(x)); \ 128 constexpr Complex operator/(Complex c, T x) { \ 129 return operator/(c, static_cast<Numeric>(x)); \ 132 constexpr Complex operator+(T x, Complex c) { \ 133 return operator+(static_cast<Numeric>(x), c); \ 135 constexpr Complex operator-(T x, Complex c) { \ 136 return operator-(static_cast<Numeric>(x), c); \ 138 constexpr Complex operator*(T x, Complex c) { \ 139 return operator*(static_cast<Numeric>(x), c); \ 141 constexpr Complex operator/(T x, Complex c) { \ 142 return operator/(static_cast<Numeric>(x), c); \ 148 #undef _complex_operations_ 166 typedef Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
169 typedef Eigen::Map<ComplexMatrixType, 0, ComplexStrideType>
171 typedef Eigen::Map<const ComplexMatrixType, 0, ComplexStrideType>
287 assert(n < mrange.mextent);
293 return *(mdata + mrange.mstart +
n * mrange.mstride);
298 return reinterpret_cast<const Numeric(&)[2]
>(
get(
n))[0];
303 return reinterpret_cast<const Numeric(&)[2]
>(
get(
n))[1];
372 using ConstComplexVectorView::operator[];
389 assert(n < mrange.mextent);
395 return *(mdata + mrange.mstart +
n * mrange.mstride);
400 return reinterpret_cast<Numeric(&)[2]
>(
get(
n))[0];
405 return reinterpret_cast<Numeric(&)[2]
>(
get(
n))[1];
454 const Complex* get_c_array()
const;
498 if (msv.mdata + msv.mrange.mstart !=
542 if (msv.mdata + msv.mrange.mstart !=
596 void resize(
Index n);
629 bool empty()
const {
return not nrows() or not ncols(); }
638 assert(r < mrr.mextent);
639 assert(c < mcr.mextent);
646 return *(mdata + mrr.mstart + r * mrr.mstride + mcr.mstart +
658 Range(2*mcr.mstart, mcr.mextent, mcr.mstride*2));}
662 Range(2*mcr.mstart + 1, mcr.mextent, mcr.mstride*2));}
736 using ConstComplexMatrixView::operator();
754 assert(r < mrr.mextent);
755 assert(c < mcr.mextent);
762 return *(mdata + mrr.mstart + r * mrr.mstride + mcr.mstart +
768 return reinterpret_cast<Numeric(&)[2]
>(
get(
r, c))[0];
773 return reinterpret_cast<Numeric(&)[2]
>(
get(
r, c))[1];
778 Range(2*mcr.mstart, mcr.mextent, mcr.mstride*2));}
782 Range(2*mcr.mstart + 1, mcr.mextent, mcr.mstride*2));}
828 const Complex* get_c_array()
const;
Array< ComplexVector > ArrayOfComplexVector
INDEX Index
The type to use for all integer numbers and indices.
friend class ComplexMatrixView
Complex * mdata
Pointer to the plain C array that holds the data.
constexpr Complex operator/(Complex c, Numeric n)
Range mrange
The range of mdata that is actually used.
const Complex & operator*() const
Dereferencing.
ConstComplexIterator1D & operator++()
Prefix increment operator.
ComplexIterator2D iterator
Numeric & get_imag(Index r, Index c)
Get element implementation without assertions.
ComplexConstMatrixViewMap MapToEigenCol(const ConstComplexVectorView &A)
Index mstart
The start index.
ConstMatrixView real() const
Get a view of the real part of the matrix.
Complex * mx
Current position.
ComplexVectorView msv
Current position.
The constant iterator class for sub vectors.
MatrixView real()
Get a view of the real part of the matrix.
Complex & operator()(Index r, Index c)
Plain index operator.
The ComplexVectorView class.
constexpr Complex conj(Complex c)
the conjugate of c
ConstComplexIterator1D const_iterator
ComplexVectorView * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > ComplexStrideType
ComplexIterator1D(Complex *x, Index stride)
Explicit constructor.
Numeric & get_imag(Index n)
Get element implementation without assertions.
Numeric get_real(Index r, Index c) const
Get element implementation without assertions.
friend void copy(ConstComplexIterator1D origin, const ConstComplexIterator1D &end, ComplexIterator1D target)
Copy data between begin and end to target.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
bool operator!=(const ConstComplexIterator2D &other) const
Not equal operator, needed for algorithms like copy.
ConstMatrixView imag() const
Get a view of the imaginary part of the matrix.
const Numeric & get_real(Index n) const
Get element implementation without assertions.
constexpr Numeric abs2(Complex c)
squared magnitude of c
Complex operator()(Index r, Index c) const
Plain const index operator.
bool operator!=(const ComplexIterator2D &other) const
Not equal operator, needed for algorithms like copy.
friend class ConstComplexMatrixView
MatrixView imag()
Get a view of the imaginary parts of the matrix.
friend class ConstComplexVectorView
Array< ComplexMatrix > ArrayOfComplexMatrix
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
bool operator!=(const ComplexIterator1D &other) const
Not equal operator, needed for algorithms like copy.
friend class ComplexVectorView
VectorView imag()
Get a view of the imaginary part of the vector.
ConstVectorView imag() const
Get a view of the imaginary part of the vector.
ConstComplexVectorView diagonal() const
ComplexMatrix diagonal as vector.
Eigen::Map< const ComplexMatrixType, 0, ComplexStrideType > ComplexConstMatrixViewMap
ConstComplexVectorView msv
Current position.
std::complex< Numeric > Complex
const Complex * mx
Current position.
Complex & operator*() const
Dereferencing.
Struct cannot be const, but can be passed as const to allow defaults.
The iterator class for sub vectors.
Complex & operator[](Index n)
Plain Index operator.
Complex * mdata
Pointer to the plain C array that holds the data.
ConstComplexMatrixView transpose(ConstComplexMatrixView m)
Const version of transpose.
The const row iterator class for sub matrices.
Complex get(Index r, Index c) const
Get element implementation without assertions.
VectorView real()
Get a view of the real part of the vector.
Eigen::Map< ComplexMatrixType, 0, ComplexStrideType > ComplexMatrixViewMap
const Complex & get(Index n) const
Get element implementation without assertions.
NUMERIC Numeric
The type to use for all floating point numbers.
Numeric & get_real(Index r, Index c)
Get element implementation without assertions.
ConstComplexIterator1D end() const
Return const iterator behind last element.
ConstComplexIterator1D(Complex *x, Index stride)
Explicit constructor.
const Complex & operator[](Index n) const
Plain const index operator.
Implementation of Matrix, Vector, and such stuff.
const ConstComplexVectorView * operator->() const
The -> operator is needed, so that we can write i->begin() to get t he 1D iterators.
ComplexIterator1D iterator
std::ostream & operator<<(std::ostream &os, const ConstComplexVectorView &v)
Output operator.
This can be used to make arrays out of anything.
Index get_column_extent() const
Get the extent of the underlying data.
Numeric get_imag(Index r, Index c) const
Get element implementation without assertions.
bool operator!=(const ConstComplexIterator1D &other) const
Not equal operator, needed for algorithms like copy.
ConstComplexIterator2D end() const
Return const iterator behind last row.
void inv(MatrixView Ainv, ConstMatrixView A)
Matrix Inverse.
ComplexIterator1D & operator++()
Prefix increment operator.
ComplexConstMatrixViewMap MapToEigenRow(const ConstComplexVectorView &A)
ComplexConstMatrixViewMap MapToEigen(const ConstComplexMatrixView &A)
ConstVectorView real() const
Get a view of the real part of the vector.
A constant view of a Vector.
Index nelem(const Lines &l)
Number of lines.
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrixType
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
std::complex< float > operator*(const double &d, const std::complex< float > &c)
ConstComplexIterator2D & operator++()
Prefix increment operator.
A constant view of a Matrix.
ConstComplexIterator2D begin() const
Return const iterator to first row.
A constant view of a ComplexMatrix.
ComplexIterator1D()=default
Default constructor.
A constant view of a ComplexVector.
ComplexVectorView & operator*()
Dereferencing.
Numeric & get_real(Index n)
Get element implementation without assertions.
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
ComplexIterator2D(const ComplexVectorView &x, Index stride)
Explicit constructor.
ComplexIterator2D & operator++()
Prefix increment operator.
Interface for the LAPACK library.
#define _complex_operations_(T)
void mult(ComplexVectorView y, const ConstComplexMatrixView &M, const ConstComplexVectorView &x)
Matrix-Vector Multiplication.
ConstComplexIterator2D(const ConstComplexVectorView &x, Index stride)
Explicit constructor.
const ConstComplexVectorView & operator*() const
Dereferencing.
constexpr Complex operator-(Complex c, Numeric n)
ConstComplexIterator1D begin() const
Return const iterator to first element.
ConstComplexIterator2D const_iterator
std::complex< float > operator+(const double &d, const std::complex< float > &c)
MatrixView & operator+=(MatrixView &A, const Block &B)
The row iterator class for sub matrices.
The ComplexMatrixView class.
const Numeric & get_imag(Index n) const
Get element implementation without assertions.