ARTS
2.3.1285(git:92a29ea9-dirty)
|
The ComplexVectorView class. More...
#include <complex.h>
Public Types | |
typedef ComplexIterator1D | iterator |
Public Types inherited from ConstComplexVectorView | |
typedef ConstComplexIterator1D | const_iterator |
Public Member Functions | |
constexpr | ComplexVectorView (const ComplexVectorView &)=default |
ComplexVectorView (const ComplexVector &) | |
Bail out immediately if somebody tries to create a ComplexVectorView from a const Complex*Vector. More... | |
ComplexVectorView (ComplexVector &v) | |
Create ComplexVectorView from a ComplexVector. More... | |
Complex & | operator[] (Index n) |
Plain Index operator. More... | |
Complex & | get (Index n) |
Get element implementation without assertions. More... | |
Numeric & | get_real (Index n) |
Get element implementation without assertions. More... | |
Numeric & | get_imag (Index n) |
Get element implementation without assertions. More... | |
VectorView | real () |
Get a view of the real part of the vector. More... | |
VectorView | imag () |
Get a view of the imaginary part of the vector. More... | |
ComplexVectorView | operator[] (const Range &r) |
Index operator for subrange. More... | |
ComplexIterator1D | begin () |
Return iterator to first element. More... | |
ComplexIterator1D | end () |
Return iterator behind last element. More... | |
ComplexVectorView & | operator= (const ConstComplexVectorView &v) |
Assignment operator. More... | |
ComplexVectorView & | operator= (const ComplexVectorView &v) |
Assignment from ComplexVectorView to ComplexVectorView. More... | |
ComplexVectorView & | operator= (const ComplexVector &v) |
Assignment from ComplexVector. More... | |
ComplexVectorView & | operator= (const Array< Complex > &v) |
Assignment operator from Array<Complex>. More... | |
ComplexVectorView & | operator= (Complex x) |
Assigning a scalar to a ComplexVectorView will set all elements to this value. More... | |
ComplexVectorView & | operator= (const ConstVectorView &v) |
ComplexVectorView & | operator= (const VectorView &v) |
ComplexVectorView & | operator= (const Vector &v) |
ComplexVectorView & | operator= (const Array< Numeric > &v) |
ComplexVectorView & | operator= (Numeric x) |
ComplexVectorView | operator*= (Complex x) |
Multiplication by scalar. More... | |
ComplexVectorView | operator/= (Complex x) |
Division by scalar. More... | |
ComplexVectorView | operator+= (Complex x) |
Addition of scalar. More... | |
ComplexVectorView | operator-= (Complex x) |
Subtraction of scalar. More... | |
ComplexVectorView | operator*= (Numeric x) |
Multiplication by scalar. More... | |
ComplexVectorView | operator/= (Numeric x) |
Division by scalar. More... | |
ComplexVectorView | operator+= (Numeric x) |
Addition of scalar. More... | |
ComplexVectorView | operator-= (Numeric x) |
Subtraction of scalar. More... | |
ComplexVectorView | operator*= (const ConstComplexVectorView &x) |
Element-vise multiplication by another vector. More... | |
ComplexVectorView | operator/= (const ConstComplexVectorView &x) |
Element-vise division by another vector. More... | |
ComplexVectorView | operator+= (const ConstComplexVectorView &x) |
Element-vise addition of another vector. More... | |
ComplexVectorView | operator-= (const ConstComplexVectorView &x) |
Element-vise subtraction of another vector. More... | |
ComplexVectorView | operator*= (const ConstVectorView &x) |
Element-vise multiplication by another vector. More... | |
ComplexVectorView | operator/= (const ConstVectorView &x) |
Element-vise division by another vector. More... | |
ComplexVectorView | operator+= (const ConstVectorView &x) |
Element-vise addition of another vector. More... | |
ComplexVectorView | operator-= (const ConstVectorView &x) |
Element-vise subtraction of another vector. More... | |
operator ComplexMatrixView () | |
Conversion to 1 column matrix. More... | |
const Complex * | get_c_array () const |
Conversion to plain C-array. More... | |
Complex * | get_c_array () |
Conversion to plain C-array. More... | |
virtual | ~ComplexVectorView ()=default |
Destructor. More... | |
ComplexVectorView (Complex &a) | |
A special constructor, which allows to make a VectorView from a scalar. More... | |
Public Member Functions inherited from ConstComplexVectorView | |
constexpr | ConstComplexVectorView (const ConstComplexVectorView &)=default |
constexpr | ConstComplexVectorView (ConstComplexVectorView &&)=default |
ConstComplexVectorView & | operator= (const ConstComplexVectorView &)=default |
ConstComplexVectorView & | operator= (ConstComplexVectorView &&)=default |
bool | empty () const |
Index | nelem () const |
Complex | sum () const |
Returns true if variable size is zero. More... | |
const Complex & | operator[] (Index n) const |
Plain const index operator. More... | |
const Complex & | get (Index n) const |
Get element implementation without assertions. More... | |
const Numeric & | get_real (Index n) const |
Get element implementation without assertions. More... | |
const Numeric & | get_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... | |
Protected Member Functions | |
ComplexVectorView ()=default | |
ComplexVectorView (Complex *data, const Range &range) | |
Explicit constructor. More... | |
ComplexVectorView (Complex *data, const Range &p, const Range &n) | |
Recursive constructor. More... | |
Protected Member Functions inherited from ConstComplexVectorView | |
ConstComplexVectorView ()=default | |
ConstComplexVectorView (Complex *data, const Range &range) | |
Explicit constructor. More... | |
ConstComplexVectorView (Complex *data, const Range &p, const Range &n) | |
Recursive constructor. More... | |
Friends | |
class | ConstComplexIterator2D |
class | ComplexIterator2D |
class | ComplexMatrixView |
Additional Inherited Members | |
Protected Attributes inherited from ConstComplexVectorView | |
Range | mrange {0, 0} |
The range of mdata that is actually used. More... | |
Complex * | mdata {nullptr} |
Pointer to the plain C array that holds the data. More... | |
The ComplexVectorView class.
This contains the main implementation of a complex vector. The class ComplexVector 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.
|
default |
ComplexVectorView::ComplexVectorView | ( | const ComplexVector & | ) |
Bail out immediately if somebody tries to create a ComplexVectorView from a const Complex*Vector.
Definition at line 154 of file complex.cc.
ComplexVectorView::ComplexVectorView | ( | ComplexVector & | v | ) |
Create ComplexVectorView from a ComplexVector.
Definition at line 165 of file complex.cc.
References ConstComplexVectorView::mdata, and ConstComplexVectorView::mrange.
|
virtualdefault |
Destructor.
ComplexVectorView::ComplexVectorView | ( | Complex & | a | ) |
A special constructor, which allows to make a VectorView from a scalar.
Definition at line 446 of file complex.cc.
|
protecteddefault |
Explicit constructor.
This one is used by Vector to initialize its own VectorView part.
Definition at line 452 of file complex.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.
*data | The actual data. |
p | Previous range. |
n | New Range. |
Definition at line 467 of file complex.cc.
ComplexIterator1D ComplexVectorView::begin | ( | ) |
Return iterator to first element.
Definition at line 178 of file complex.cc.
References ConstComplexVectorView::mdata, ConstComplexVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by ComplexVector::ComplexVector(), copy(), and operator=().
ComplexIterator1D ComplexVectorView::end | ( | ) |
Return iterator behind last element.
Definition at line 183 of file complex.cc.
References ConstComplexVectorView::mdata, Range::mextent, ConstComplexVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by ComplexVector::ComplexVector(), copy(), and operator=().
const Complex * ComplexVectorView::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 421 of file complex.cc.
References ConstComplexVectorView::mdata, ConstComplexVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by diagonalize(), and inv().
Complex * ComplexVectorView::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 435 of file complex.cc.
References ConstComplexVectorView::mdata, ConstComplexVectorView::mrange, Range::mstart, and Range::mstride.
|
inline |
Get a view of the imaginary part of the vector.
Definition at line 412 of file complex.h.
References Zeeman::end(), operator+=(), and r.
ComplexVectorView::operator ComplexMatrixView | ( | ) |
Conversion to 1 column matrix.
Definition at line 406 of file complex.cc.
References ConstComplexVectorView::mdata, and ConstComplexVectorView::mrange.
ComplexVectorView ComplexVectorView::operator*= | ( | Complex | x | ) |
Multiplication by scalar.
Definition at line 242 of file complex.cc.
ComplexVectorView ComplexVectorView::operator*= | ( | Numeric | x | ) |
Multiplication by scalar.
Definition at line 249 of file complex.cc.
ComplexVectorView ComplexVectorView::operator*= | ( | const ConstComplexVectorView & | x | ) |
Element-vise multiplication by another vector.
Definition at line 298 of file complex.cc.
References ConstComplexVectorView::begin(), i, and ConstComplexVectorView::nelem().
ComplexVectorView ComplexVectorView::operator*= | ( | const ConstVectorView & | x | ) |
Element-vise multiplication by another vector.
Definition at line 312 of file complex.cc.
References ConstComplexVectorView::begin(), ConstVectorView::begin(), i, ConstComplexVectorView::nelem(), and ConstVectorView::nelem().
ComplexVectorView ComplexVectorView::operator+= | ( | Complex | x | ) |
Addition of scalar.
Definition at line 270 of file complex.cc.
ComplexVectorView ComplexVectorView::operator+= | ( | Numeric | x | ) |
Addition of scalar.
Definition at line 277 of file complex.cc.
ComplexVectorView ComplexVectorView::operator+= | ( | const ConstComplexVectorView & | x | ) |
Element-vise addition of another vector.
Definition at line 352 of file complex.cc.
References ConstComplexVectorView::begin(), i, and ConstComplexVectorView::nelem().
ComplexVectorView ComplexVectorView::operator+= | ( | const ConstVectorView & | x | ) |
Element-vise addition of another vector.
Definition at line 366 of file complex.cc.
References ConstComplexVectorView::begin(), ConstVectorView::begin(), i, ConstComplexVectorView::nelem(), and ConstVectorView::nelem().
ComplexVectorView ComplexVectorView::operator-= | ( | Complex | x | ) |
Subtraction of scalar.
Definition at line 284 of file complex.cc.
ComplexVectorView ComplexVectorView::operator-= | ( | Numeric | x | ) |
Subtraction of scalar.
Definition at line 291 of file complex.cc.
ComplexVectorView ComplexVectorView::operator-= | ( | const ConstComplexVectorView & | x | ) |
Element-vise subtraction of another vector.
Definition at line 379 of file complex.cc.
References ConstComplexVectorView::begin(), i, and ConstComplexVectorView::nelem().
ComplexVectorView ComplexVectorView::operator-= | ( | const ConstVectorView & | x | ) |
Element-vise subtraction of another vector.
Definition at line 393 of file complex.cc.
References ConstComplexVectorView::begin(), ConstVectorView::begin(), i, ConstComplexVectorView::nelem(), and ConstVectorView::nelem().
ComplexVectorView ComplexVectorView::operator/= | ( | Complex | x | ) |
Division by scalar.
Definition at line 256 of file complex.cc.
ComplexVectorView ComplexVectorView::operator/= | ( | Numeric | x | ) |
Division by scalar.
Definition at line 263 of file complex.cc.
ComplexVectorView ComplexVectorView::operator/= | ( | const ConstComplexVectorView & | x | ) |
Element-vise division by another vector.
Definition at line 325 of file complex.cc.
References ConstComplexVectorView::begin(), i, and ConstComplexVectorView::nelem().
ComplexVectorView ComplexVectorView::operator/= | ( | const ConstVectorView & | x | ) |
Element-vise division by another vector.
Definition at line 339 of file complex.cc.
References ConstComplexVectorView::begin(), ConstVectorView::begin(), i, ConstComplexVectorView::nelem(), and ConstVectorView::nelem().
ComplexVectorView & ComplexVectorView::operator= | ( | const ConstComplexVectorView & | v | ) |
Assignment operator.
This copies the data from another VectorView t o this Complex*VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.
Definition at line 193 of file complex.cc.
References ConstComplexVectorView::begin(), copy(), ConstComplexVectorView::end(), Range::mextent, and ConstComplexVectorView::mrange.
Referenced by ComplexVector::operator=().
ComplexVectorView & ComplexVectorView::operator= | ( | const ComplexVectorView & | v | ) |
Assignment from ComplexVectorView to ComplexVectorView.
This is a tricky one. The problem is that since ComplexVectorView is derived from ConstComplexVectorView, 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 210 of file complex.cc.
References ConstComplexVectorView::begin(), begin(), copy(), end(), Range::mextent, and ConstComplexVectorView::mrange.
ComplexVectorView & ComplexVectorView::operator= | ( | const ComplexVector & | v | ) |
Assignment from ComplexVector.
This is important to avoid a bug when assigning a Vector to a Complex*VectorView.
Definition at line 223 of file complex.cc.
References ConstComplexVectorView::begin(), begin(), copy(), end(), Range::mextent, and ConstComplexVectorView::mrange.
ComplexVectorView & ComplexVectorView::operator= | ( | const Array< Complex > & | v | ) |
Assignment operator from Array<Complex>.
This copies the data from an Array<Complex> to this VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.
Array<Complex> 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 1534 of file complex.cc.
References i, and Array< base >::nelem().
ComplexVectorView & ComplexVectorView::operator= | ( | Complex | x | ) |
Assigning a scalar to a ComplexVectorView will set all elements to this value.
Definition at line 236 of file complex.cc.
References ConstComplexVectorView::begin(), copy(), and ConstComplexVectorView::end().
ComplexVectorView& ComplexVectorView::operator= | ( | const ConstVectorView & | v | ) |
ComplexVectorView& ComplexVectorView::operator= | ( | const VectorView & | v | ) |
ComplexVectorView& ComplexVectorView::operator= | ( | const Vector & | v | ) |
ComplexVectorView& ComplexVectorView::operator= | ( | const Array< Numeric > & | v | ) |
ComplexVectorView& ComplexVectorView::operator= | ( | Numeric | x | ) |
ComplexVectorView ComplexVectorView::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 173 of file complex.cc.
References ConstComplexVectorView::ComplexVectorView, ConstComplexVectorView::mdata, and ConstComplexVectorView::mrange.
|
inline |
|
friend |
|
friend |
|
friend |
Definition at line 461 of file complex.h.
Referenced by ConstComplexMatrixView::begin(), and ConstComplexMatrixView::end().