ARTS  2.0.49
VectorView Class Reference

The VectorView class. More...

#include <matpackI.h>

Inheritance diagram for VectorView:
ConstVectorView Vector MakeVector

Public Types

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

Public Member Functions

 VectorView (const Vector &)
 Bail out immediately if somebody tries to create a VectorView from a const Vector. More...
 
 VectorView (Vector &v)
 Create VectorView from a Vector. More...
 
Numeric operator[] (Index n) const
 Plain const index operator. More...
 
ConstVectorView operator[] (const Range &r) const
 Const index operator for subrange. More...
 
Numericoperator[] (Index n)
 Plain Index operator. More...
 
VectorView operator[] (const Range &r)
 Index operator for subrange. More...
 
ConstIterator1D begin () const
 Return const iterator to first element. More...
 
ConstIterator1D end () const
 Return const iterator behind last element. More...
 
Iterator1D begin ()
 Return iterator to first element. More...
 
Iterator1D end ()
 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)
 Multiplication by scalar. More...
 
VectorView operator/= (Numeric x)
 Division by scalar. More...
 
VectorView operator+= (Numeric x)
 Addition of scalar. More...
 
VectorView operator-= (Numeric x)
 Subtraction of scalar. More...
 
VectorView operator*= (const ConstVectorView &x)
 Element-vise multiplication by another vector. More...
 
VectorView operator/= (const ConstVectorView &x)
 Element-vise division by another vector. More...
 
VectorView operator+= (const ConstVectorView &x)
 Element-vise addition of another vector. More...
 
VectorView operator-= (const ConstVectorView &x)
 Element-vise subtraction of another vector. More...
 
 operator MatrixView ()
 Conversion to 1 column matrix. More...
 
const Numericget_c_array () const
 Conversion to plain C-array. More...
 
Numericget_c_array ()
 Conversion to plain C-array. More...
 
virtual ~VectorView ()
 Destructor. More...
 
 VectorView (Numeric &a)
 A special constructor, which allows to make a VectorView from a scalar. More...
 
- Public Member Functions inherited from ConstVectorView
Index nelem () const
 Returns the number of elements. More...
 
Numeric sum () const
 The sum of all elements of a Vector. More...
 
Numeric operator[] (Index n) const
 Plain const index operator. More...
 
ConstVectorView operator[] (const Range &r) const
 Const index operator for subrange. More...
 
ConstIterator1D begin () const
 Return const iterator to first element. More...
 
ConstIterator1D end () const
 Return const iterator behind last element. More...
 
 operator ConstMatrixView () const
 Conversion to const 1 column matrix. More...
 
virtual ~ConstVectorView ()
 Destructor. More...
 
 ConstVectorView (const Numeric &a)
 A special constructor, which allows to make a ConstVectorView from a scalar. More...
 

Protected Member Functions

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

Friends

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

Additional Inherited Members

- Protected Attributes inherited from ConstVectorView
Range mrange
 The range of mdata that is actually used. More...
 
Numericmdata
 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 373 of file matpackI.h.

Member Typedef Documentation

◆ iterator

Definition at line 379 of file matpackI.h.

Constructor & Destructor Documentation

◆ VectorView() [1/6]

VectorView::VectorView ( const Vector )

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

Definition at line 299 of file matpackI.cc.

◆ VectorView() [2/6]

VectorView::VectorView ( Vector v)

Create VectorView from a Vector.

Definition at line 310 of file matpackI.cc.

References ConstVectorView::mdata, and ConstVectorView::mrange.

◆ ~VectorView()

virtual VectorView::~VectorView ( )
inlinevirtual

Destructor.

Definition at line 433 of file matpackI.h.

◆ VectorView() [3/6]

VectorView::VectorView ( Numeric a)

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

Definition at line 552 of file matpackI.cc.

◆ VectorView() [4/6]

VectorView::VectorView ( )
protected

Default constructor.

This is necessary, so that we can have a default constructor for the derived class Vector.

Definition at line 560 of file matpackI.cc.

Referenced by operator[]().

◆ VectorView() [5/6]

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

◆ VectorView() [6/6]

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
*dataThe actual data.
pPrevious range.
nNew Range.

Definition at line 585 of file matpackI.cc.

Member Function Documentation

◆ begin() [1/2]

Iterator1D VectorView::begin ( )

Return iterator to first element.

Definition at line 350 of file matpackI.cc.

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

◆ begin() [2/2]

ConstIterator1D VectorView::begin ( ) const

Return const iterator to first element.

Has to be redefined here, since it is hiden by the non-const operator of the derived class.

Definition at line 336 of file matpackI.cc.

References ConstVectorView::begin().

Referenced by copy(), mult(), MatrixView::operator*=(), operator*=(), MatrixView::operator+=(), operator+=(), MatrixView::operator-=(), operator-=(), MatrixView::operator/=(), operator/=(), operator=(), Vector::operator=(), test03(), test1(), transform(), and Vector::Vector().

◆ end() [1/2]

Iterator1D VectorView::end ( )

Return iterator behind last element.

Definition at line 356 of file matpackI.cc.

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

◆ end() [2/2]

ConstIterator1D VectorView::end ( ) const

Return const iterator behind last element.

Has to be redefined here, since it is hiden by the non-const operator of the derived class.

Definition at line 344 of file matpackI.cc.

References ConstVectorView::end().

Referenced by copy(), mult(), MatrixView::operator*=(), operator*=(), MatrixView::operator+=(), operator+=(), MatrixView::operator-=(), operator-=(), MatrixView::operator/=(), operator/=(), Vector::operator=(), operator=(), test03(), and Vector::Vector().

◆ get_c_array() [1/2]

Numeric * VectorView::get_c_array ( )

Conversion to plain C-array.

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

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

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

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

Referenced by test38().

◆ operator MatrixView()

VectorView::operator MatrixView ( )

Conversion to 1 column matrix.

Definition at line 516 of file matpackI.cc.

◆ operator*=() [1/2]

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

Element-vise multiplication by another vector.

Definition at line 456 of file matpackI.cc.

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

◆ operator*=() [2/2]

VectorView VectorView::operator*= ( Numeric  x)

Multiplication by scalar.

Definition at line 420 of file matpackI.cc.

References begin(), and end().

◆ operator+=() [1/2]

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

Element-vise addition of another vector.

Definition at line 486 of file matpackI.cc.

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

◆ operator+=() [2/2]

VectorView VectorView::operator+= ( Numeric  x)

Addition of scalar.

Definition at line 438 of file matpackI.cc.

References begin(), and end().

◆ operator-=() [1/2]

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

Element-vise subtraction of another vector.

Definition at line 501 of file matpackI.cc.

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

◆ operator-=() [2/2]

VectorView VectorView::operator-= ( Numeric  x)

Subtraction of scalar.

Definition at line 447 of file matpackI.cc.

References begin(), and end().

◆ operator/=() [1/2]

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

Element-vise division by another vector.

Definition at line 471 of file matpackI.cc.

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

◆ operator/=() [2/2]

VectorView VectorView::operator/= ( Numeric  x)

Division by scalar.

Definition at line 429 of file matpackI.cc.

References begin(), and end().

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

References begin(), Range::mextent, ConstVectorView::mrange, and Array< base >::nelem().

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

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

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

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

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

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

◆ operator=() [5/5]

VectorView & VectorView::operator= ( Numeric  x)

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

Definition at line 413 of file matpackI.cc.

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

◆ operator[]() [1/4]

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

References ConstVectorView::mdata, ConstVectorView::mrange, and VectorView().

◆ operator[]() [2/4]

ConstVectorView VectorView::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. Has to be redifined here, because the one from ConstVectorView is hidden.

Definition at line 320 of file matpackI.cc.

References ConstVectorView::operator[]().

◆ operator[]() [3/4]

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

Plain Index operator.

Definition at line 390 of file matpackI.h.

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

◆ operator[]() [4/4]

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

Plain const index operator.

Has to be redifined here, because the one from ConstVectorView is hidden.

Definition at line 384 of file matpackI.h.

References ConstVectorView::operator[]().

Referenced by MakeVector::MakeVector().

Friends And Related Function Documentation

◆ ConstIterator2D

friend class ConstIterator2D
friend

Definition at line 436 of file matpackI.h.

◆ Iterator2D

friend class Iterator2D
friend

Definition at line 437 of file matpackI.h.

◆ MatrixView

friend class MatrixView
friend

Definition at line 438 of file matpackI.h.

◆ Tensor3View

friend class Tensor3View
friend

Definition at line 439 of file matpackI.h.

◆ Tensor4View

friend class Tensor4View
friend

Definition at line 440 of file matpackI.h.

◆ Tensor5View

friend class Tensor5View
friend

Definition at line 441 of file matpackI.h.

◆ Tensor6View

friend class Tensor6View
friend

Definition at line 442 of file matpackI.h.

◆ Tensor7View

friend class Tensor7View
friend

Definition at line 443 of file matpackI.h.


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