ARTS  2.3.1285(git:92a29ea9-dirty)
ComplexVector Class Reference

The ComplexVector class. More...

#include <complex.h>

Inheritance diagram for ComplexVector:
ComplexVectorView ConstComplexVectorView

Public Member Functions

 ComplexVector ()
 Default constructor. More...
 
 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...
 
ComplexVectoroperator= (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...
 
void resize (Index n)
 Assignment operator from VectorView. More...
 
virtual ~ComplexVector ()
 Destructor for ComplexVector. More...
 
- 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)
 
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
 Conversion to plain C-array. More...
 
Complexget_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
 
ConstComplexVectorViewoperator= (const ConstComplexVectorView &)=default
 
ConstComplexVectorViewoperator= (ConstComplexVectorView &&)=default
 
bool empty () const
 
Index nelem () const
 
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
typedef ComplexIterator1D iterator
 
- Public Types inherited from ConstComplexVectorView
typedef ConstComplexIterator1D const_iterator
 
- 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 573 of file complex.h.

Constructor & Destructor Documentation

◆ ComplexVector() [1/13]

ComplexVector::ComplexVector ( )

Default constructor.

Definition at line 498 of file complex.cc.

◆ ComplexVector() [2/13]

ComplexVector::ComplexVector ( Index  n)
explicit

Constructor setting size.

Definition at line 503 of file complex.cc.

◆ ComplexVector() [3/13]

ComplexVector::ComplexVector ( Index  n,
Complex  fill 
)

Constructor setting size and filling with constant value.

Definition at line 509 of file complex.cc.

References ConstComplexVectorView::mdata, and n.

◆ ComplexVector() [4/13]

ComplexVector::ComplexVector ( Index  n,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 518 of file complex.cc.

References ConstComplexVectorView::mdata, and n.

◆ ComplexVector() [5/13]

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 534 of file complex.cc.

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

◆ ComplexVector() [6/13]

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 574 of file complex.cc.

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

◆ ComplexVector() [7/13]

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 554 of file complex.cc.

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

◆ ComplexVector() [8/13]

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 594 of file complex.cc.

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

◆ ComplexVector() [9/13]

ComplexVector::ComplexVector ( const ConstComplexVectorView v)

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 611 of file complex.cc.

References ConstComplexVectorView::begin(), ComplexVectorView::begin(), copy(), and ConstComplexVectorView::end().

◆ ComplexVector() [10/13]

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 618 of file complex.cc.

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

◆ ComplexVector() [11/13]

ComplexVector::ComplexVector ( const Vector v)

◆ ComplexVector() [12/13]

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

Converting constructor from std::vector.

Definition at line 624 of file complex.cc.

References ComplexVectorView::begin(), and ComplexVectorView::end().

◆ ComplexVector() [13/13]

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

Converting constructor from std::vector.

Definition at line 635 of file complex.cc.

References ComplexVectorView::begin(), and ComplexVectorView::end().

◆ ~ComplexVector()

ComplexVector::~ComplexVector ( )
virtual

Destructor for ComplexVector.

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

Definition at line 738 of file complex.cc.

References ConstComplexVectorView::mdata.

Member Function Documentation

◆ operator=() [1/3]

ComplexVector & ComplexVector::operator= ( 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 complex.cc.

References swap.

◆ operator=() [2/3]

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 692 of file complex.cc.

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

◆ operator=() [3/3]

ComplexVector & ComplexVector::operator= ( Complex  x)

Assignment operator from scalar.

Assignment operators are not inherited.

Definition at line 700 of file complex.cc.

References ComplexVectorView::operator=().

◆ resize()

void ComplexVector::resize ( Index  n)

Assignment operator from VectorView.

Assignment operators are not inherited. 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 719 of file complex.cc.

References ConstComplexVectorView::mdata, Range::mextent, ConstComplexVectorView::mrange, Range::mstart, Range::mstride, and n.

Referenced by operator=().

Friends And Related Function Documentation

◆ swap

void swap ( ComplexVector v1,
ComplexVector v2 
)
friend

Swaps two objects.

Definition at line 731 of file complex.cc.

Referenced by operator=().


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