ARTS 2.5.4 (git: 4c0d3b4d)
ComplexVector Class Reference

The ComplexVector class. More...

#include <matpack_complex.h>

Inheritance diagram for ComplexVector:
ComplexVectorView ConstComplexVectorView

Public Member Functions

 ComplexVector ()=default
 
 ComplexVector (ComplexVector &&cv) noexcept
 
 ComplexVector (Index n)
 Constructor setting size. More...
 
 ComplexVector (Index n, Complex fill)
 Constructor setting size and filling with constant value. More...
 
 ComplexVector (Index n, Numeric fill)
 Constructor setting size and filling with constant value. More...
 
 ComplexVector (Complex start, Index extent, Complex stride)
 Constructor filling with values. More...
 
 ComplexVector (Complex start, Index extent, Numeric stride)
 Constructor filling with values. More...
 
 ComplexVector (Numeric start, Index extent, Complex stride)
 Constructor filling with values. More...
 
 ComplexVector (Numeric start, Index extent, Numeric stride)
 Constructor filling with values. More...
 
 ComplexVector (const ConstComplexVectorView &v)
 Copy constructor from ComplexVectorView. More...
 
 ComplexVector (const ComplexVector &v)
 Copy constructor from ComplexVector. More...
 
 ComplexVector (const Vector &v)
 
 ComplexVector (const std::vector< Complex > &)
 Converting constructor from std::vector. More...
 
 ComplexVector (const std::vector< Numeric > &)
 Converting constructor from std::vector. More...
 
 ComplexVector (Complex *c, const Range &r0) ARTS_NOEXCEPT
 
ComplexVectoroperator= (const ComplexVector &v)
 Assignment from another Vector. More...
 
ComplexVectoroperator= (const Array< Complex > &v)
 Assignment operator from Array<Numeric>. More...
 
ComplexVectoroperator= (Complex x)
 Assignment operator from scalar. More...
 
ComplexVectoroperator= (ComplexVector &&v) noexcept
 
void resize (Index n)
 Resize function. More...
 
 ~ComplexVector () override
 Destructor for ComplexVector. More...
 
Index size () const noexcept
 
- Public Member Functions inherited from ComplexVectorView
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...
 
Complexoperator[] (Index n)
 Plain Index operator. More...
 
Complexget (Index n)
 Get element implementation without assertions. More...
 
Numericget_real (Index n)
 Get element implementation without assertions. More...
 
Numericget_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...
 
ComplexVectorViewoperator= (const ConstComplexVectorView &v)
 Assignment operator. More...
 
ComplexVectorViewoperator= (const ComplexVectorView &v)
 Assignment from ComplexVectorView to ComplexVectorView. More...
 
ComplexVectorViewoperator= (const ComplexVector &v)
 Assignment from ComplexVector. More...
 
ComplexVectorViewoperator= (const Array< Complex > &v)
 Assignment operator from Array<Complex>. More...
 
ComplexVectorViewoperator= (Complex x)
 Assigning a scalar to a ComplexVectorView will set all elements to this value. More...
 
ComplexVectorViewoperator= (const ConstVectorView &v)
 
ComplexVectorViewoperator= (const VectorView &v)
 
ComplexVectorViewoperator= (const Vector &v)
 
ComplexVectorViewoperator= (const Array< Numeric > &v)
 
ComplexVectorViewoperator= (Numeric x)
 Assigning a scalar to a ComplexVectorView will set all elements to this value. More...
 
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 Complexget_c_array () const ARTS_NOEXCEPT
 Conversion to plain C-array. More...
 
Complexget_c_array () ARTS_NOEXCEPT
 Conversion to plain C-array. More...
 
 ~ComplexVectorView () override=default
 Destructor. More...
 
 ComplexVectorView (Complex &a)
 A special constructor, which allows to make a VectorView from a scalar. More...
 
ConstComplexIterator1D begin () const
 Return const iterator to first element. More...
 
ConstComplexIterator1D end () const
 Return const iterator behind last element. More...
 
const Complexget (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_imag (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_real (Index n) const
 Get element implementation without assertions. More...
 
ConstVectorView imag () const
 Get a view of the imaginary part of the vector. More...
 
ConstVectorView real () const
 Get a view of the real part of the vector. More...
 
- Public Member Functions inherited from ConstComplexVectorView
constexpr ConstComplexVectorView (const ConstComplexVectorView &)=default
 
constexpr ConstComplexVectorView (ConstComplexVectorView &&)=default
 
ConstComplexVectorViewoperator= (const ConstComplexVectorView &)=default
 
ConstComplexVectorViewoperator= (ConstComplexVectorView &&)=default
 
bool empty () const noexcept
 
Index nelem () const noexcept
 
Complex sum () const
 Returns true if variable size is zero. More...
 
const Complexoperator[] (Index n) const
 Plain const index operator. More...
 
const Complexget (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_real (Index n) const
 Get element implementation without assertions. More...
 
const Numericget_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...
 

Friends

void swap (ComplexVector &v1, ComplexVector &v2)
 Swaps two objects. More...
 

Additional Inherited Members

- Public Types inherited from ComplexVectorView
using iterator = ComplexIterator1D
 
- Public Types inherited from ConstComplexVectorView
using const_iterator = ConstComplexIterator1D
 
- Protected Member Functions inherited from ComplexVectorView
 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...
 
- Protected Attributes inherited from ConstComplexVectorView
Range mrange {0, 0}
 The range of mdata that is actually used. More...
 
Complexmdata {nullptr}
 Pointer to the plain C array that holds the data. More...
 

Detailed Description

The ComplexVector class.

This is a subvector that also allocates storage automatically, and deallocates it when it is destroyed. We take * all the functionality from ComplexVectorView. Additionally defined in this class are:

  1. Constructors and destructors (allocating memory).
  2. Assignment operator
  3. Assignment operator from scalar.
  4. Resize function.

Definition at line 592 of file matpack_complex.h.

Constructor & Destructor Documentation

◆ ComplexVector() [1/15]

ComplexVector::ComplexVector ( )
default

◆ ComplexVector() [2/15]

ComplexVector::ComplexVector ( ComplexVector &&  cv)
inlinenoexcept

Definition at line 596 of file matpack_complex.h.

◆ ComplexVector() [3/15]

ComplexVector::ComplexVector ( Index  n)
explicit

Constructor setting size.

Definition at line 499 of file matpack_complex.cc.

◆ ComplexVector() [4/15]

ComplexVector::ComplexVector ( Index  n,
Complex  fill 
)

Constructor setting size and filling with constant value.

Definition at line 505 of file matpack_complex.cc.

References ConstComplexVectorView::mdata.

◆ ComplexVector() [5/15]

ComplexVector::ComplexVector ( Index  n,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 514 of file matpack_complex.cc.

References ConstComplexVectorView::mdata.

◆ ComplexVector() [6/15]

ComplexVector::ComplexVector ( Complex  start,
Index  extent,
Complex  stride 
)

Constructor filling with values.

Examples:

Vector v(1,5,1); // 1, 2, 3, 4, 5 Vector v(1,5,.5); // 1, 1.5, 2, 2.5, 3 Vector v(5,5,-1); // 5, 4, 3, 2, 1

Definition at line 530 of file matpack_complex.cc.

References ComplexVectorView::begin(), and Zeeman::start().

◆ ComplexVector() [7/15]

ComplexVector::ComplexVector ( Complex  start,
Index  extent,
Numeric  stride 
)

Constructor filling with values.

Examples:

Vector v(1,5,1); // 1, 2, 3, 4, 5 Vector v(1,5,.5); // 1, 1.5, 2, 2.5, 3 Vector v(5,5,-1); // 5, 4, 3, 2, 1

Definition at line 570 of file matpack_complex.cc.

References ComplexVectorView::begin(), and Zeeman::start().

◆ ComplexVector() [8/15]

ComplexVector::ComplexVector ( Numeric  start,
Index  extent,
Complex  stride 
)

Constructor filling with values.

Examples:

Vector v(1,5,1); // 1, 2, 3, 4, 5 Vector v(1,5,.5); // 1, 1.5, 2, 2.5, 3 Vector v(5,5,-1); // 5, 4, 3, 2, 1

Definition at line 550 of file matpack_complex.cc.

References ComplexVectorView::begin(), and Zeeman::start().

◆ ComplexVector() [9/15]

ComplexVector::ComplexVector ( Numeric  start,
Index  extent,
Numeric  stride 
)

Constructor filling with values.

Examples:

Vector v(1,5,1); // 1, 2, 3, 4, 5 Vector v(1,5,.5); // 1, 1.5, 2, 2.5, 3 Vector v(5,5,-1); // 5, 4, 3, 2, 1

Definition at line 590 of file matpack_complex.cc.

References ComplexVectorView::begin(), and Zeeman::start().

◆ ComplexVector() [10/15]

ComplexVector::ComplexVector ( const ConstComplexVectorView v)
explicit

Copy constructor from ComplexVectorView.

This automatically sets the size and copies the data. The vector created will have start zero and stride 1, independent on how these parameters are set for the original. So, what is copied is the data, not the shape of the selection.

Definition at line 607 of file matpack_complex.cc.

References ComplexVectorView::begin(), copy(), and v.

◆ ComplexVector() [11/15]

ComplexVector::ComplexVector ( const ComplexVector v)

Copy constructor from ComplexVector.

This is important to override the automatically generated shallow constructor. We want deep copies!

Definition at line 614 of file matpack_complex.cc.

References ComplexVectorView::begin(), copy(), and v.

◆ ComplexVector() [12/15]

ComplexVector::ComplexVector ( const Vector v)
explicit

Definition at line 619 of file matpack_complex.cc.

References ConstComplexVectorView::nelem(), and v.

◆ ComplexVector() [13/15]

ComplexVector::ComplexVector ( const std::vector< Complex > &  v)
explicit

Converting constructor from std::vector.

Definition at line 624 of file matpack_complex.cc.

References ComplexVectorView::begin(), and v.

◆ ComplexVector() [14/15]

ComplexVector::ComplexVector ( const std::vector< Numeric > &  v)
explicit

Converting constructor from std::vector.

Definition at line 635 of file matpack_complex.cc.

References ComplexVectorView::begin(), and v.

◆ ComplexVector() [15/15]

ComplexVector::ComplexVector ( Complex c,
const Range r0 
)
inline

Definition at line 611 of file matpack_complex.h.

References ARTS_ASSERT, and IGRF::r0.

◆ ~ComplexVector()

ComplexVector::~ComplexVector ( )
override

Destructor for ComplexVector.

This is important, since Vector uses new to allocate storage.

Definition at line 750 of file matpack_complex.cc.

References ConstComplexVectorView::mdata.

Member Function Documentation

◆ operator=() [1/4]

ComplexVector & ComplexVector::operator= ( Complex  x)

Assignment operator from scalar.

Assignment operators are not inherited.

Definition at line 712 of file matpack_complex.cc.

◆ operator=() [2/4]

ComplexVector & ComplexVector::operator= ( ComplexVector &&  v)
inlinenoexcept

◆ operator=() [3/4]

ComplexVector & ComplexVector::operator= ( const Array< Complex > &  x)

Assignment operator from Array<Numeric>.

This copies the data from a Array<Numeric> to this VectorView. The size is adjusted automatically.

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.

Parameters
xThe array to assign to this.
Returns
This vector, by tradition.
Author
Stefan Buehler
Date
2002-12-19

Definition at line 704 of file matpack_complex.cc.

References Array< base >::nelem(), ComplexVectorView::operator=(), and resize().

◆ operator=() [4/4]

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

Assignment from another Vector.

While dimensions of VectorViews can not be adjusted, dimensions of Vectors can be adjusted. Hence, the behavior of the assignment operator is different.

In this case the size of the target is automatically adjusted. This is important, so that structures containing Vectors are copied correctly.

This is a deviation from the old ARTS paradigm that sizes must match exactly before copying!

Note: It is sufficient to have only this one version of the assignment (Vector = Vector). It implicitly covers the cases Vector=VectorView, etc, because there is a default constructor for Vector from VectorView. (See C++ Primer Plus, page 571ff.)

Parameters
vThe other vector to copy to this one.
Returns
This vector, by tradition.
Author
Stefan Buehler
Date
2002-12-19

Definition at line 670 of file matpack_complex.cc.

References ComplexVectorView::end(), ConstComplexVectorView::mdata, resize(), and v.

◆ resize()

void ComplexVector::resize ( Index  n)

Resize function.

If the size is already correct this function does nothing. All data is lost after resizing! The new Vector is not initialized, so it will contain random values.

Definition at line 731 of file matpack_complex.cc.

References ARTS_ASSERT, Range::mextent, and ConstComplexVectorView::mrange.

Referenced by operator=().

◆ size()

Index ComplexVector::size ( ) const
inlinenoexcept

Definition at line 642 of file matpack_complex.h.

References ConstComplexVectorView::nelem().

Friends And Related Function Documentation

◆ swap

void swap ( ComplexVector v1,
ComplexVector v2 
)
friend

Swaps two objects.

Definition at line 743 of file matpack_complex.cc.


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