ARTS 2.5.9 (git: 825fa5f2)
ConstComplexVectorView Class Reference

A constant view of a ComplexVector. More...

#include <matpack_complex.h>

Inheritance diagram for ConstComplexVectorView:
ComplexVectorView ComplexVector

Public Types

using const_iterator = ConstComplexIterator1D
 

Public Member Functions

constexpr ConstComplexVectorView (const ConstComplexVectorView &)=default
 
constexpr ConstComplexVectorView (ConstComplexVectorView &&)=default
 
ConstComplexVectorViewoperator= (const ConstComplexVectorView &)=default
 
ConstComplexVectorViewoperator= (ConstComplexVectorView &&)=default
 
bool empty () const noexcept
 
Index nelem () const noexcept
 
Index size () const noexcept
 
Complex sum () const
 Returns true if variable size is zero. More...
 
const Complexoperator[] (Index n) const
 Plain const index operator. More...
 
const Complexget (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_real (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_imag (Index n) const
 Get element implementation without assertions. More...
 
ConstVectorView real () const
 Get a view of the real part of the vector. More...
 
ConstVectorView imag () const
 Get a view of the imaginary part of the vector. More...
 
ConstComplexVectorView operator[] (const Range &r) const
 Const index operator for subrange. More...
 
ConstComplexIterator1D begin () const
 Return const iterator to first element. More...
 
ConstComplexIterator1D end () const
 Return const iterator behind last element. More...
 
 operator ConstComplexMatrixView () const
 Conversion to const 1 column matrix. More...
 
virtual ~ConstComplexVectorView ()=default
 Destructor. More...
 
 ConstComplexVectorView (const Complex &a)
 A special constructor, which allows to make a ConstComplexVectorView from a scalar. More...
 
Index selem () const noexcept
 Start element in memory. More...
 
Index delem () const noexcept
 Steps in memory between elements. More...
 
Complexget_c_array () const noexcept
 

Static Public Attributes

static constexpr bool matpack_type {true}
 

Protected Member Functions

 ConstComplexVectorView ()=default
 
 ConstComplexVectorView (Complex *data, const Range &range)
 Explicit constructor. More...
 
 ConstComplexVectorView (Complex *data, const Range &p, const Range &n)
 Recursive constructor. More...
 

Protected Attributes

Range mrange {0, 0}
 The range of mdata that is actually used. More...
 
Complexmdata {nullptr}
 Pointer to the plain C array that holds the data. More...
 

Friends

class ComplexVectorView
 
class ConstComplexIterator2D
 
class ConstComplexMatrixView
 
Complex operator* (const ConstComplexVectorView &a, const ConstComplexVectorView &b)
 Scalar product. More...
 
void mult (ComplexVectorView, const ConstComplexMatrixView &, const ConstComplexVectorView &)
 Matrix-Vector Multiplication. More...
 
std::ostream & operator<< (std::ostream &os, const ConstComplexVectorView &v)
 Output operator. More...
 

Detailed Description

A constant view of a ComplexVector.

Together with the derived class ComplexVectorView this contains the main implementation of a ComplexVector. The class ComplexVector is just a special case of a ComplexVectorView which also allocates storage.

Definition at line 285 of file matpack_complex.h.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ ConstComplexVectorView() [1/6]

constexpr ConstComplexVectorView::ConstComplexVectorView ( const ConstComplexVectorView )
constexprdefault

◆ ConstComplexVectorView() [2/6]

constexpr ConstComplexVectorView::ConstComplexVectorView ( ConstComplexVectorView &&  )
constexprdefault

◆ ~ConstComplexVectorView()

virtual ConstComplexVectorView::~ConstComplexVectorView ( )
virtualdefault

Destructor.

◆ ConstComplexVectorView() [3/6]

ConstComplexVectorView::ConstComplexVectorView ( const Complex a)

A special constructor, which allows to make a ConstComplexVectorView from a scalar.

This one is a bit tricky: We have to cast away the arguments const qualifier, because mdata is not const. This should be safe, since there are no non-const methods for ConstComplexVectorView.

Definition at line 100 of file matpack_complex.cc.

◆ ConstComplexVectorView() [4/6]

ConstComplexVectorView::ConstComplexVectorView ( )
protecteddefault

Referenced by operator[]().

◆ ConstComplexVectorView() [5/6]

ConstComplexVectorView::ConstComplexVectorView ( Complex data,
const Range range 
)
protected

Explicit constructor.

This one is used by Vector to initialize its own VectorView part.

Definition at line 107 of file matpack_complex.cc.

◆ ConstComplexVectorView() [6/6]

ConstComplexVectorView::ConstComplexVectorView ( Complex data,
const Range p,
const Range n 
)
protected

Recursive constructor.

This is used to construct sub ranges from sub ranges. That means that the new range has to be interpreted relative to the original range. The new range may contain -1 for the extent which acts as a joker. However, the used Range constructor converts this to an explicit range, consistent with the original Range.

Parameters
*dataThe actual data.
pPrevious range.
nNew Range.

Definition at line 123 of file matpack_complex.cc.

Member Function Documentation

◆ begin()

◆ delem()

Index ConstComplexVectorView::delem ( ) const
inlinenoexcept

Steps in memory between elements.

Definition at line 363 of file matpack_complex.h.

References mrange, and Range::mstride.

◆ empty()

bool ConstComplexVectorView::empty ( ) const
inlinenoexcept

Definition at line 298 of file matpack_complex.h.

References nelem().

◆ end()

ConstComplexIterator1D ConstComplexVectorView::end ( ) const

Return const iterator behind last element.

Definition at line 82 of file matpack_complex.cc.

References mdata, Range::mextent, mrange, Range::mstart, and Range::mstride.

Referenced by copy(), and sum().

◆ get()

const Complex & ConstComplexVectorView::get ( Index  n) const
inline

Get element implementation without assertions.

Definition at line 312 of file matpack_complex.h.

References mdata, mrange, Range::mstart, and Range::mstride.

Referenced by get_imag(), get_real(), and operator[]().

◆ get_c_array()

Complex * ConstComplexVectorView::get_c_array ( ) const
inlinenoexcept

Definition at line 365 of file matpack_complex.h.

References mdata.

Referenced by diagonalize(), and inv().

◆ get_imag()

const Numeric & ConstComplexVectorView::get_imag ( Index  n) const
inline

Get element implementation without assertions.

Definition at line 322 of file matpack_complex.h.

References get(), and imag().

◆ get_real()

const Numeric & ConstComplexVectorView::get_real ( Index  n) const
inline

Get element implementation without assertions.

Definition at line 317 of file matpack_complex.h.

References get(), and real().

◆ imag()

ConstVectorView ConstComplexVectorView::imag ( ) const

Get a view of the imaginary part of the vector.

Definition at line 662 of file matpack_complex.cc.

References mdata, Range::mextent, mrange, Range::mstart, and Range::mstride.

Referenced by get_imag().

◆ nelem()

◆ operator ConstComplexMatrixView()

ConstComplexVectorView::operator ConstComplexMatrixView ( ) const

Conversion to const 1 column matrix.

Definition at line 89 of file matpack_complex.cc.

◆ operator=() [1/2]

ConstComplexVectorView & ConstComplexVectorView::operator= ( const ConstComplexVectorView )
default

◆ operator=() [2/2]

ConstComplexVectorView & ConstComplexVectorView::operator= ( ConstComplexVectorView &&  )
default

◆ operator[]() [1/2]

ConstComplexVectorView ConstComplexVectorView::operator[] ( const Range r) const

Const index operator for subrange.

We have to also account for the case, that *this is already a subrange of a Vector. This allows correct recursive behavior.

Definition at line 71 of file matpack_complex.cc.

References ConstComplexVectorView(), mdata, and mrange.

◆ operator[]() [2/2]

const Complex & ConstComplexVectorView::operator[] ( Index  n) const
inline

Plain const index operator.

Definition at line 305 of file matpack_complex.h.

References ARTS_ASSERT, get(), Range::mextent, and mrange.

◆ real()

ConstVectorView ConstComplexVectorView::real ( ) const

Get a view of the real part of the vector.

Definition at line 656 of file matpack_complex.cc.

References mdata, Range::mextent, mrange, Range::mstart, and Range::mstride.

Referenced by get_real().

◆ selem()

Index ConstComplexVectorView::selem ( ) const
inlinenoexcept

Start element in memory.

Definition at line 360 of file matpack_complex.h.

References mrange, and Range::mstart.

◆ size()

Index ConstComplexVectorView::size ( ) const
inlinenoexcept

Definition at line 300 of file matpack_complex.h.

References Range::mextent, and mrange.

Referenced by ComplexVector::operator=().

◆ sum()

Complex ConstComplexVectorView::sum ( ) const

Returns true if variable size is zero.

Returns the number of elements. The names ‘size’ and ‘length’ are already used by STL functions returning size_t. To avoid confusion we choose the name ‘nelem’. This is also more consistent with ‘nrow’ and ‘ncol’ for matrices.

The value range of long, which is used to store the index is on a PC from -2147483648 to 2147483647. This means that a 15GB large array of float can be addressed with this index. So the extra bit that size_t has compared to long is not needed. The sum of all elements of a Vector.

Definition at line 58 of file matpack_complex.cc.

References begin(), and end().

Friends And Related Function Documentation

◆ ComplexVectorView

friend class ComplexVectorView
friend

Definition at line 347 of file matpack_complex.h.

◆ ConstComplexIterator2D

friend class ConstComplexIterator2D
friend

Definition at line 348 of file matpack_complex.h.

◆ ConstComplexMatrixView

friend class ConstComplexMatrixView
friend

Definition at line 349 of file matpack_complex.h.

◆ mult

void mult ( ComplexVectorView  ,
const ConstComplexMatrixView ,
const ConstComplexVectorView  
)
friend

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 1580 of file matpack_complex.cc.

◆ operator*

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

Scalar product.

The two vectors may be identical.

Definition at line 1555 of file matpack_complex.cc.

◆ operator<<

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

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 133 of file matpack_complex.cc.

Member Data Documentation

◆ matpack_type

constexpr bool ConstComplexVectorView::matpack_type {true}
staticconstexpr

Definition at line 287 of file matpack_complex.h.

Referenced by test_concepts().

◆ mdata

◆ mrange


The documentation for this class was generated from the following files: