ARTS
2.4.0(git:4fb77825)
|
The VectorView class. More...
#include <matpackI.h>
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) | |
Create VectorView from a Vector. More... | |
Numeric & | operator[] (Index n) |
Plain Index operator. More... | |
Numeric & | get (Index n) |
Get element implementation without assertions. More... | |
VectorView | operator[] (const Range &r) |
Index operator for subrange. More... | |
Iterator1D | begin () |
Return iterator to first element. More... | |
Iterator1D | end () |
Return iterator behind last element. More... | |
VectorView & | operator= (const ConstVectorView &v) |
Assignment operator. More... | |
VectorView & | operator= (const VectorView &v) |
Assignment from VectorView to VectorView. More... | |
VectorView & | operator= (const Vector &v) |
Assignment from Vector. More... | |
VectorView & | operator= (const Array< Numeric > &v) |
Assignment operator from Array<Numeric>. More... | |
VectorView & | operator= (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 Numeric * | get_c_array () const |
Conversion to plain C-array, const-version. More... | |
Numeric * | get_c_array () |
Conversion to plain C-array, non-const version. More... | |
virtual | ~VectorView ()=default |
Destructor. More... | |
VectorView (Numeric &a) | |
A special constructor, which allows to make a VectorView from a scalar. More... | |
ConstIterator1D | begin () const |
Return const iterator to first element. More... | |
ConstIterator1D | end () const |
Return const iterator behind last element. More... | |
Numeric | get (Index n) const |
Get element implementation without assertions. More... | |
Public Member Functions inherited from ConstVectorView | |
constexpr | ConstVectorView (const ConstVectorView &)=default |
constexpr | ConstVectorView (ConstVectorView &&)=default |
ConstVectorView & | operator= (const ConstVectorView &)=default |
ConstVectorView & | operator= (ConstVectorView &&)=default |
bool | empty () const |
Returns true if variable size is zero. More... | |
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... | |
Numeric | get (Index n) const |
Get element implementation without assertions. 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 ()=default |
Destructor. More... | |
ConstVectorView (const Numeric &a) | |
A special constructor, which allows to make a ConstVectorView from a scalar. More... | |
Protected Member Functions | |
VectorView ()=default | |
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 | |
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 |
class | ComplexVectorView |
Additional Inherited Members | |
Protected Attributes inherited from ConstVectorView | |
Range | mrange {0, 0} |
The range of mdata that is actually used. More... | |
Numeric * | mdata {nullptr} |
Pointer to the plain C array that holds the data. More... | |
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 610 of file matpackI.h.
typedef Iterator1D VectorView::iterator |
Definition at line 628 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 125 of file matpackI.cc.
VectorView::VectorView | ( | Vector & | v | ) |
Create VectorView from a Vector.
Definition at line 135 of file matpackI.cc.
References ConstVectorView::mdata, and ConstVectorView::mrange.
|
virtualdefault |
Destructor.
VectorView::VectorView | ( | Numeric & | a | ) |
A special constructor, which allows to make a VectorView from a scalar.
Definition at line 288 of file matpackI.cc.
|
protecteddefault |
Referenced by operator[]().
Explicit constructor.
This one is used by Vector to initialize its own VectorView part.
Definition at line 292 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 297 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(), mult_general(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), Vector::operator=(), test03(), test1(), test46(), transform(), and Vector::Vector().
ConstIterator1D ConstVectorView::begin |
Return const iterator to first element.
Definition at line 528 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 mult_general(), operator=(), test03(), test46(), and Vector::Vector().
ConstIterator1D ConstVectorView::end |
Return const iterator behind last element.
Definition at line 531 of file matpackI.cc.
Get element implementation without assertions.
Definition at line 638 of file matpackI.h.
References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.
|
inline |
Get element implementation without assertions.
Definition at line 514 of file matpackI.h.
References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by operator[]().
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 280 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.
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 272 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by diagonalize(), fastem(), get_variable_value(), nca_get_data_Vector(), nca_put_var_Vector(), nca_read_from_file(), nca_write_to_file(), Reduce(), test38(), tmatrix_random_orientation(), and tmatrix_tmd_test().
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 begin(), ConstVectorView::nelem(), and ARTS::Var::x().
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 begin(), ConstVectorView::nelem(), and ARTS::Var::x().
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 begin(), ConstVectorView::nelem(), and ARTS::Var::x().
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 begin(), ConstVectorView::nelem(), and ARTS::Var::x().
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 1632 of file matpackI.cc.
References Range::mextent, ConstVectorView::mrange, and Array< base >::nelem().
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 begin(), ConstVectorView::begin(), copy(), ConstVectorView::end(), Range::mextent, and ConstVectorView::mrange.
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 begin(), copy(), end(), Range::mextent, and ConstVectorView::mrange.
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 begin(), copy(), end(), Range::mextent, and ConstVectorView::mrange.
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.
References begin(), copy(), end(), and ARTS::Var::x().
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.
References ConstVectorView::mdata, ConstVectorView::mrange, and VectorView().
Plain Index operator.
Definition at line 631 of file matpackI.h.
References get(), Range::mextent, and ConstVectorView::mrange.
|
friend |
Definition at line 735 of file matpackI.h.
|
friend |
Definition at line 727 of file matpackI.h.
|
friend |
Definition at line 728 of file matpackI.h.
|
friend |
Definition at line 729 of file matpackI.h.
|
friend |
Definition at line 730 of file matpackI.h.
|
friend |
Definition at line 731 of file matpackI.h.
|
friend |
Definition at line 732 of file matpackI.h.
|
friend |
Definition at line 733 of file matpackI.h.
|
friend |
Definition at line 734 of file matpackI.h.