ARTS 2.5.10 (git: 2f1c442c)
|
The VectorView class. More...
#include <matpackI.h>
Public Types | |
using | iterator = Iterator1D |
![]() | |
using | const_iterator = ConstIterator1D |
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. | |
VectorView (Vector &v) ARTS_NOEXCEPT | |
Create VectorView from a Vector. | |
Numeric & | operator[] (Index n) ARTS_NOEXCEPT |
Plain Index operator. | |
Numeric & | get (Index n) ARTS_NOEXCEPT |
Get element implementation without assertions. | |
VectorView | operator[] (const Range &r) ARTS_NOEXCEPT |
Index operator for subrange. | |
Iterator1D | begin () ARTS_NOEXCEPT |
Return iterator to first element. | |
Iterator1D | end () ARTS_NOEXCEPT |
Return iterator behind last element. | |
VectorView & | operator= (const ConstVectorView &v) |
Assignment operator. | |
VectorView & | operator= (const VectorView &v) |
Assignment from VectorView to VectorView. | |
VectorView & | operator= (const Vector &v) |
Assignment from Vector. | |
VectorView & | operator= (const Array< Numeric > &v) |
Assignment operator from Array<Numeric>. | |
VectorView & | operator= (Numeric x) |
Assigning a scalar to a VectorView will set all elements to this value. | |
VectorView | operator*= (Numeric x) ARTS_NOEXCEPT |
Multiplication by scalar. | |
VectorView | operator/= (Numeric x) ARTS_NOEXCEPT |
Division by scalar. | |
VectorView | operator+= (Numeric x) ARTS_NOEXCEPT |
Addition of scalar. | |
VectorView | operator-= (Numeric x) ARTS_NOEXCEPT |
Subtraction of scalar. | |
VectorView | operator*= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise multiplication by another vector. | |
VectorView | operator/= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise division by another vector. | |
VectorView | operator+= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise addition of another vector. | |
VectorView | operator-= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise subtraction of another vector. | |
operator MatrixView () ARTS_NOEXCEPT | |
Conversion to 1 column matrix. | |
~VectorView () override=default | |
Destructor. | |
VectorView (Numeric &a) ARTS_NOEXCEPT | |
A special constructor, which allows to make a VectorView from a scalar. | |
ConstIterator1D | begin () const ARTS_NOEXCEPT |
Return const iterator to first element. | |
ConstIterator1D | end () const ARTS_NOEXCEPT |
Return const iterator behind last element. | |
Numeric | get (Index n) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
![]() | |
constexpr | ConstVectorView (const ConstVectorView &)=default |
constexpr | ConstVectorView (ConstVectorView &&)=default |
ConstVectorView & | operator= (const ConstVectorView &)=default |
ConstVectorView & | operator= (ConstVectorView &&)=default |
bool | empty () const noexcept |
Returns true if variable size is zero. | |
Index | nelem () const noexcept |
Returns the number of elements. | |
Index | size () const noexcept |
Shape< 1 > | shape () const |
Numeric | sum () const ARTS_NOEXCEPT |
The sum of all elements of a Vector. | |
Numeric | operator[] (Index n) const ARTS_NOEXCEPT |
Plain const index operator. | |
Numeric | get (Index n) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
ConstVectorView | operator[] (const Range &r) const ARTS_NOEXCEPT |
Const index operator for subrange. | |
ConstIterator1D | begin () const ARTS_NOEXCEPT |
Return const iterator to first element. | |
ConstIterator1D | end () const ARTS_NOEXCEPT |
Return const iterator behind last element. | |
operator ConstMatrixView () const | |
Conversion to const 1 column matrix. | |
virtual | ~ConstVectorView ()=default |
Destructor. | |
ConstVectorView (const Numeric &a) ARTS_NOEXCEPT | |
A special constructor, which allows to make a ConstVectorView from a scalar. | |
Index | selem () const noexcept |
Start element in memory. | |
Index | delem () const noexcept |
Steps in memory between elements. | |
Numeric * | get_c_array () const noexcept |
Conversion to plain C-array, const-version. | |
Protected Member Functions | |
VectorView ()=default | |
VectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT | |
Explicit constructor. | |
VectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT | |
Recursive constructor. | |
![]() | |
ConstVectorView ()=default | |
ConstVectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT | |
Explicit constructor. | |
ConstVectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT | |
Recursive constructor. | |
Friends | |
class | ConstIterator2D |
class | Iterator2D |
class | MatrixView |
class | Tensor3View |
class | Tensor4View |
class | Tensor5View |
class | Tensor6View |
class | Tensor7View |
class | ComplexVectorView |
Additional Inherited Members | |
![]() | |
static constexpr bool | matpack_type {true} |
![]() | |
Range | mrange {0, 0} |
The range of mdata that is actually used. | |
Numeric * | mdata {nullptr} |
Pointer to the plain C array that holds the data. | |
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 674 of file matpackI.h.
using VectorView::iterator = Iterator1D |
Definition at line 692 of file matpackI.h.
|
constexprdefault |
VectorView::VectorView | ( | const Vector & | ) |
Bail out immediately if somebody tries to create a VectorView from a const Vector.
Definition at line 126 of file matpackI.cc.
References ARTS_ASSERT.
VectorView::VectorView | ( | Vector & | v | ) |
|
overridedefault |
Destructor.
VectorView::VectorView | ( | Numeric & | a | ) |
A special constructor, which allows to make a VectorView from a scalar.
Definition at line 272 of file matpackI.cc.
|
protecteddefault |
Explicit constructor.
This one is used by Vector to initialize its own VectorView part.
Definition at line 276 of file matpackI.cc.
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.
[in] | *data | The actual data. |
[in] | p | Previous range. |
[in] | n | New Range. |
Definition at line 281 of file matpackI.cc.
Iterator1D VectorView::begin | ( | ) |
Return iterator to first element.
Definition at line 144 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by copy(), Raw::Average::nanstd(), EnergyLevelMap::OK(), MatrixView::operator*=(), MatrixView::operator+=(), MatrixView::operator-=(), MatrixView::operator/=(), operator=(), Vector::operator=(), predefined_model_dataAddWaterMTCKD400(), Raw::Average::std(), test46(), transform(), and Vector::Vector().
ConstIterator1D ConstVectorView::begin | ( | ) | const |
Return const iterator to first element.
Definition at line 582 of file matpackI.cc.
Iterator1D VectorView::end | ( | ) |
Return iterator behind last element.
Definition at line 148 of file matpackI.cc.
References ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by Raw::Average::nanstd(), EnergyLevelMap::OK(), MatrixView::operator*=(), MatrixView::operator+=(), MatrixView::operator-=(), MatrixView::operator/=(), operator=(), predefined_model_dataAddWaterMTCKD400(), Raw::Average::std(), test46(), and Vector::Vector().
ConstIterator1D ConstVectorView::end | ( | ) | const |
Return const iterator behind last element.
Definition at line 585 of file matpackI.cc.
Get element implementation without assertions.
Definition at line 703 of file matpackI.h.
References GETFUN.
Referenced by interpweights().
Get element implementation without assertions.
Definition at line 567 of file matpackI.h.
VectorView::operator MatrixView | ( | ) |
Conversion to 1 column matrix.
Definition at line 263 of file matpackI.cc.
VectorView VectorView::operator*= | ( | const ConstVectorView & | x | ) |
Element-vise multiplication by another vector.
Definition at line 215 of file matpackI.cc.
References ARTS_ASSERT.
VectorView VectorView::operator*= | ( | Numeric | x | ) |
Multiplication by scalar.
Definition at line 191 of file matpackI.cc.
VectorView VectorView::operator+= | ( | const ConstVectorView & | x | ) |
Element-vise addition of another vector.
Definition at line 239 of file matpackI.cc.
References ARTS_ASSERT.
VectorView VectorView::operator+= | ( | Numeric | x | ) |
Addition of scalar.
Definition at line 203 of file matpackI.cc.
VectorView VectorView::operator-= | ( | const ConstVectorView & | x | ) |
Element-vise subtraction of another vector.
Definition at line 251 of file matpackI.cc.
References ARTS_ASSERT.
VectorView VectorView::operator-= | ( | Numeric | x | ) |
Subtraction of scalar.
Definition at line 209 of file matpackI.cc.
VectorView VectorView::operator/= | ( | const ConstVectorView & | x | ) |
Element-vise division by another vector.
Definition at line 227 of file matpackI.cc.
References ARTS_ASSERT.
VectorView VectorView::operator/= | ( | Numeric | x | ) |
Division by scalar.
Definition at line 197 of file matpackI.cc.
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 1614 of file matpackI.cc.
References ARTS_ASSERT, begin(), Range::mextent, ConstVectorView::mrange, and v.
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 153 of file matpackI.cc.
References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.
Referenced by Vector::operator=().
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 175 of file matpackI.cc.
References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.
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 164 of file matpackI.cc.
References ARTS_ASSERT, begin(), copy(), Range::mextent, ConstVectorView::mrange, and v.
VectorView & VectorView::operator= | ( | Numeric | x | ) |
Assigning a scalar to a VectorView will set all elements to this value.
Definition at line 186 of file matpackI.cc.
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 140 of file matpackI.cc.
Plain Index operator.
Definition at line 696 of file matpackI.h.
References ARTS_ASSERT, GETFUN, Range::mextent, and ConstVectorView::mrange.
|
friend |
Definition at line 785 of file matpackI.h.
|
friend |
Definition at line 777 of file matpackI.h.
|
friend |
Definition at line 778 of file matpackI.h.
|
friend |
Definition at line 779 of file matpackI.h.
|
friend |
Definition at line 780 of file matpackI.h.
|
friend |
Definition at line 781 of file matpackI.h.
|
friend |
Definition at line 782 of file matpackI.h.
|
friend |
Definition at line 783 of file matpackI.h.
|
friend |
Definition at line 784 of file matpackI.h.