ARTS 2.5.0 (git: 9ee3ac6c)
VectorView Class Reference

The VectorView class. More...

#include <matpackI.h>

Inheritance diagram for VectorView:
ConstVectorView Vector

Public Types

typedef Iterator1D iterator
 
- Public Types inherited from ConstVectorView
typedef ConstIterator1D const_iterator
 

Public Member Functions

constexpr VectorView (const VectorView &)=default
 
 VectorView (const Vector &)
 Bail out immediately if somebody tries to create a VectorView from a const Vector. More...
 
 VectorView (Vector &v) ARTS_NOEXCEPT
 Create VectorView from a Vector. More...
 
Numericoperator[] (Index n) ARTS_NOEXCEPT
 Plain Index operator. More...
 
Numericget (Index n) ARTS_NOEXCEPT
 Get element implementation without assertions. More...
 
VectorView operator[] (const Range &r) ARTS_NOEXCEPT
 Index operator for subrange. More...
 
Iterator1D begin () ARTS_NOEXCEPT
 Return iterator to first element. More...
 
Iterator1D end () ARTS_NOEXCEPT
 Return iterator behind last element. More...
 
VectorViewoperator= (const ConstVectorView &v)
 Assignment operator. More...
 
VectorViewoperator= (const VectorView &v)
 Assignment from VectorView to VectorView. More...
 
VectorViewoperator= (const Vector &v)
 Assignment from Vector. More...
 
VectorViewoperator= (const Array< Numeric > &v)
 Assignment operator from Array<Numeric>. More...
 
VectorViewoperator= (Numeric x)
 Assigning a scalar to a VectorView will set all elements to this value. More...
 
VectorView operator*= (Numeric x) ARTS_NOEXCEPT
 Multiplication by scalar. More...
 
VectorView operator/= (Numeric x) ARTS_NOEXCEPT
 Division by scalar. More...
 
VectorView operator+= (Numeric x) ARTS_NOEXCEPT
 Addition of scalar. More...
 
VectorView operator-= (Numeric x) ARTS_NOEXCEPT
 Subtraction of scalar. More...
 
VectorView operator*= (const ConstVectorView &x) ARTS_NOEXCEPT
 Element-vise multiplication by another vector. More...
 
VectorView operator/= (const ConstVectorView &x) ARTS_NOEXCEPT
 Element-vise division by another vector. More...
 
VectorView operator+= (const ConstVectorView &x) ARTS_NOEXCEPT
 Element-vise addition of another vector. More...
 
VectorView operator-= (const ConstVectorView &x) ARTS_NOEXCEPT
 Element-vise subtraction of another vector. More...
 
 operator MatrixView () ARTS_NOEXCEPT
 Conversion to 1 column matrix. More...
 
const Numericget_c_array () const ARTS_NOEXCEPT
 Conversion to plain C-array, const-version. More...
 
Numericget_c_array () ARTS_NOEXCEPT
 Conversion to plain C-array, non-const version. More...
 
virtual ~VectorView ()=default
 Destructor. More...
 
 VectorView (Numeric &a) ARTS_NOEXCEPT
 A special constructor, which allows to make a VectorView from a scalar. More...
 
ConstIterator1D begin () const ARTS_NOEXCEPT
 Return const iterator to first element. More...
 
ConstIterator1D end () const ARTS_NOEXCEPT
 Return const iterator behind last element. More...
 
Numeric get (Index n) const ARTS_NOEXCEPT
 Get element implementation without assertions. More...
 
- Public Member Functions inherited from ConstVectorView
constexpr ConstVectorView (const ConstVectorView &)=default
 
constexpr ConstVectorView (ConstVectorView &&)=default
 
ConstVectorViewoperator= (const ConstVectorView &)=default
 
ConstVectorViewoperator= (ConstVectorView &&)=default
 
bool empty () const ARTS_NOEXCEPT
 Returns true if variable size is zero. More...
 
Index nelem () const ARTS_NOEXCEPT
 Returns the number of elements. More...
 
Index size () const ARTS_NOEXCEPT
 
Numeric sum () const ARTS_NOEXCEPT
 The sum of all elements of a Vector. More...
 
Numeric operator[] (Index n) const ARTS_NOEXCEPT
 Plain const index operator. More...
 
Numeric get (Index n) const ARTS_NOEXCEPT
 Get element implementation without assertions. More...
 
ConstVectorView operator[] (const Range &r) const ARTS_NOEXCEPT
 Const index operator for subrange. More...
 
ConstIterator1D begin () const ARTS_NOEXCEPT
 Return const iterator to first element. More...
 
ConstIterator1D end () const ARTS_NOEXCEPT
 Return const iterator behind last element. More...
 
 operator ConstMatrixView () const
 Conversion to const 1 column matrix. More...
 
virtual ~ConstVectorView ()=default
 Destructor. More...
 
 ConstVectorView (const Numeric &a) ARTS_NOEXCEPT
 A special constructor, which allows to make a ConstVectorView from a scalar. More...
 

Protected Member Functions

 VectorView ()=default
 
 VectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT
 Explicit constructor. More...
 
 VectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT
 Recursive constructor. More...
 
- Protected Member Functions inherited from ConstVectorView
 ConstVectorView ()=default
 
 ConstVectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT
 Explicit constructor. More...
 
 ConstVectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT
 Recursive constructor. More...
 

Friends

class ConstIterator2D
 
class Iterator2D
 
class MatrixView
 
class Tensor3View
 
class Tensor4View
 
class Tensor5View
 
class Tensor6View
 
class Tensor7View
 
class ComplexVectorView
 

Additional Inherited Members

- Protected Attributes inherited from ConstVectorView
Range mrange {0, 0}
 The range of mdata that is actually used. More...
 
Numericmdata {nullptr}
 Pointer to the plain C array that holds the data. More...
 

Detailed Description

The VectorView class.

This contains the main implementation of a vector. The class Vector is just a special case of subvector which also allocates storage.

Unfortunately, names of element functions of derived classes hide the names of the original class, even if the arguments are different. This means that we have to redefine those element functions that can have different arguments, for example the constant index operators and iterators.

Definition at line 626 of file matpackI.h.

Member Typedef Documentation

◆ iterator

Definition at line 644 of file matpackI.h.

Constructor & Destructor Documentation

◆ VectorView() [1/7]

constexpr VectorView::VectorView ( const VectorView )
constexprdefault

◆ VectorView() [2/7]

VectorView::VectorView ( const Vector )

Bail out immediately if somebody tries to create a VectorView from a const Vector.

Definition at line 124 of file matpackI.cc.

References ARTS_ASSERT.

◆ VectorView() [3/7]

VectorView::VectorView ( Vector v)

Create VectorView from a Vector.

Definition at line 134 of file matpackI.cc.

References v.

◆ ~VectorView()

virtual VectorView::~VectorView ( )
virtualdefault

Destructor.

◆ VectorView() [4/7]

VectorView::VectorView ( Numeric a)

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

Definition at line 285 of file matpackI.cc.

◆ VectorView() [5/7]

VectorView::VectorView ( )
protecteddefault

◆ VectorView() [6/7]

VectorView::VectorView ( Numeric data,
const Range range 
)
protected

Explicit constructor.

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

Definition at line 289 of file matpackI.cc.

◆ VectorView() [7/7]

VectorView::VectorView ( Numeric 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
[in]*dataThe actual data.
[in]pPrevious range.
[in]nNew Range.

Definition at line 294 of file matpackI.cc.

Member Function Documentation

◆ begin() [1/2]

◆ begin() [2/2]

ConstIterator1D ConstVectorView::begin ( ) const

Return const iterator to first element.

Definition at line 544 of file matpackI.cc.

References ConstVectorView::begin(), and ConstVectorView::end().

◆ end() [1/2]

◆ end() [2/2]

ConstIterator1D ConstVectorView::end ( ) const

Return const iterator behind last element.

Definition at line 547 of file matpackI.cc.

◆ get() [1/2]

Numeric & VectorView::get ( Index  n)
inline

Get element implementation without assertions.

Definition at line 654 of file matpackI.h.

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

Referenced by interpweights(), MatrixView::operator()(), ConstMatrixView::operator()(), and operator[]().

◆ get() [2/2]

Numeric ConstVectorView::get ( Index  n) const
inline

Get element implementation without assertions.

Definition at line 530 of file matpackI.h.

◆ get_c_array() [1/2]

Numeric * VectorView::get_c_array ( )

Conversion to plain C-array, non-const version.

This function returns a pointer to the raw data. It fails if the VectorView is not pointing to the beginning of a Vector or the stride is not 1 because the caller expects to get a C array with continuous data.

Definition at line 278 of file matpackI.cc.

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

◆ get_c_array() [2/2]

const Numeric * VectorView::get_c_array ( ) const

Conversion to plain C-array, const-version.

This function returns a pointer to the raw data. It fails if the VectorView is not pointing to the beginning of a Vector or the stride is not 1 because the caller expects to get a C array with continuous data.

Definition at line 271 of file matpackI.cc.

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

Referenced by diagonalize(), fastem(), Reduce(), tmatrix_random_orientation(), and tmatrix_tmd_test().

◆ operator MatrixView()

VectorView::operator MatrixView ( )

Conversion to 1 column matrix.

Definition at line 262 of file matpackI.cc.

◆ operator*=() [1/2]

VectorView VectorView::operator*= ( const ConstVectorView x)

Element-vise multiplication by another vector.

Definition at line 214 of file matpackI.cc.

References ARTS_ASSERT, and Absorption::nelem().

◆ operator*=() [2/2]

VectorView VectorView::operator*= ( Numeric  x)

Multiplication by scalar.

Definition at line 190 of file matpackI.cc.

◆ operator+=() [1/2]

VectorView VectorView::operator+= ( const ConstVectorView x)

Element-vise addition of another vector.

Definition at line 238 of file matpackI.cc.

References ARTS_ASSERT, and Absorption::nelem().

◆ operator+=() [2/2]

VectorView VectorView::operator+= ( Numeric  x)

Addition of scalar.

Definition at line 202 of file matpackI.cc.

◆ operator-=() [1/2]

VectorView VectorView::operator-= ( const ConstVectorView x)

Element-vise subtraction of another vector.

Definition at line 250 of file matpackI.cc.

References ARTS_ASSERT, and Absorption::nelem().

◆ operator-=() [2/2]

VectorView VectorView::operator-= ( Numeric  x)

Subtraction of scalar.

Definition at line 208 of file matpackI.cc.

◆ operator/=() [1/2]

VectorView VectorView::operator/= ( const ConstVectorView x)

Element-vise division by another vector.

Definition at line 226 of file matpackI.cc.

References ARTS_ASSERT, and Absorption::nelem().

◆ operator/=() [2/2]

VectorView VectorView::operator/= ( Numeric  x)

Division by scalar.

Definition at line 196 of file matpackI.cc.

◆ operator=() [1/5]

VectorView & VectorView::operator= ( const Array< Numeric > &  v)

Assignment operator from Array<Numeric>.

This copies the data from an Array<Numeric> to this VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.

Array<Numeric> can be useful to collect things in, because there is a .push_back method for it. Then, after collecting we usually have to transfer the content to a Vector. With this assignment operator that's easy.

Definition at line 1649 of file matpackI.cc.

References ARTS_ASSERT, Range::mextent, ConstVectorView::mrange, and v.

◆ operator=() [2/5]

VectorView & VectorView::operator= ( const ConstVectorView v)

Assignment operator.

This copies the data from another VectorView to this VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.

Definition at line 152 of file matpackI.cc.

References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.

Referenced by Vector::operator=().

◆ operator=() [3/5]

VectorView & VectorView::operator= ( const Vector v)

Assignment from Vector.

This is important to avoid a bug when assigning a Vector to a VectorView.

Definition at line 174 of file matpackI.cc.

References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.

◆ operator=() [4/5]

VectorView & VectorView::operator= ( const VectorView v)

Assignment from VectorView to VectorView.

This is a tricky one. The problem is that since VectorView is derived from ConstVectorView, a default = operator is generated by the compiler, which does not do what we want. So we need this one to override the default.

Definition at line 163 of file matpackI.cc.

References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.

◆ operator=() [5/5]

VectorView & VectorView::operator= ( Numeric  x)

Assigning a scalar to a VectorView will set all elements to this value.

Definition at line 185 of file matpackI.cc.

References begin(), copy(), and end().

◆ operator[]() [1/2]

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

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 139 of file matpackI.cc.

◆ operator[]() [2/2]

Numeric & VectorView::operator[] ( Index  n)
inline

Plain Index operator.

Definition at line 647 of file matpackI.h.

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

Friends And Related Function Documentation

◆ ComplexVectorView

friend class ComplexVectorView
friend

Definition at line 751 of file matpackI.h.

◆ ConstIterator2D

friend class ConstIterator2D
friend

Definition at line 743 of file matpackI.h.

◆ Iterator2D

friend class Iterator2D
friend

Definition at line 744 of file matpackI.h.

◆ MatrixView

friend class MatrixView
friend

Definition at line 745 of file matpackI.h.

◆ Tensor3View

friend class Tensor3View
friend

Definition at line 746 of file matpackI.h.

◆ Tensor4View

friend class Tensor4View
friend

Definition at line 747 of file matpackI.h.

◆ Tensor5View

friend class Tensor5View
friend

Definition at line 748 of file matpackI.h.

◆ Tensor6View

friend class Tensor6View
friend

Definition at line 749 of file matpackI.h.

◆ Tensor7View

friend class Tensor7View
friend

Definition at line 750 of file matpackI.h.


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