ARTS  2.0.49
Vector Class Reference

The Vector class. More...

#include <matpackI.h>

Inheritance diagram for Vector:
VectorView ConstVectorView MakeVector

Public Member Functions

 Vector ()
 Default constructor. More...
 
 Vector (Index n)
 Constructor setting size. More...
 
 Vector (Index n, Numeric fill)
 Constructor setting size and filling with constant value. More...
 
 Vector (Numeric start, Index extent, Numeric stride)
 Constructor filling with values. More...
 
 Vector (const ConstVectorView &v)
 Copy constructor from VectorView. More...
 
 Vector (const Vector &v)
 Copy constructor from Vector. More...
 
Vectoroperator= (const Vector &v)
 Assignment from another Vector. More...
 
Vectoroperator= (const Array< Numeric > &v)
 Assignment operator from Array<Numeric>. More...
 
Vectoroperator= (Numeric x)
 Assignment operator from scalar. More...
 
void resize (Index n)
 Resize function. More...
 
virtual ~Vector ()
 Destructor for Vector. More...
 
- Public Member Functions inherited from VectorView
 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) const
 Plain const index operator. More...
 
ConstVectorView operator[] (const Range &r) const
 Const index operator for subrange. More...
 
Numericoperator[] (Index n)
 Plain Index operator. More...
 
VectorView operator[] (const Range &r)
 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...
 
Iterator1D begin ()
 Return iterator to first element. More...
 
Iterator1D end ()
 Return iterator behind last element. More...
 
VectorViewoperator= (const ConstVectorView &v)
 Assignment operator. More...
 
VectorViewoperator= (const VectorView &v)
 Assignment from VectorView to VectorView. More...
 
VectorViewoperator= (const Vector &v)
 Assignment from Vector. More...
 
VectorViewoperator= (const Array< Numeric > &v)
 Assignment operator from Array<Numeric>. More...
 
VectorViewoperator= (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 Numericget_c_array () const
 Conversion to plain C-array. More...
 
Numericget_c_array ()
 Conversion to plain C-array. More...
 
virtual ~VectorView ()
 Destructor. More...
 
 VectorView (Numeric &a)
 A special constructor, which allows to make a VectorView from a scalar. More...
 
- Public Member Functions inherited from ConstVectorView
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...
 
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 ()
 Destructor. More...
 
 ConstVectorView (const Numeric &a)
 A special constructor, which allows to make a ConstVectorView from a scalar. More...
 

Additional Inherited Members

- Public Types inherited from VectorView
typedef Iterator1D iterator
 
- Public Types inherited from ConstVectorView
typedef ConstIterator1D const_iterator
 
- Protected Member Functions inherited from VectorView
 VectorView ()
 Default constructor. More...
 
 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 constructor. More...
 
 ConstVectorView (Numeric *data, const Range &range)
 Explicit constructor. More...
 
 ConstVectorView (Numeric *data, const Range &p, const Range &n)
 Recursive constructor. More...
 
- Protected Attributes inherited from ConstVectorView
Range mrange
 The range of mdata that is actually used. More...
 
Numericmdata
 Pointer to the plain C array that holds the data. More...
 

Detailed Description

The Vector class.

This is a subvector that also allocates storage automatically, and deallocates it when it is destroyed. We take all the functionality from VectorView. 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 555 of file matpackI.h.

Constructor & Destructor Documentation

◆ Vector() [1/6]

Vector::Vector ( )

Default constructor.

Definition at line 624 of file matpackI.cc.

◆ Vector() [2/6]

Vector::Vector ( Index  n)
explicit

Constructor setting size.

Definition at line 630 of file matpackI.cc.

◆ Vector() [3/6]

Vector::Vector ( Index  n,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 638 of file matpackI.cc.

References ConstVectorView::mdata.

◆ Vector() [4/6]

Vector::Vector ( 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 657 of file matpackI.cc.

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

◆ Vector() [5/6]

Vector::Vector ( const ConstVectorView v)

Copy constructor from VectorView.

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 677 of file matpackI.cc.

References ConstVectorView::begin(), VectorView::begin(), copy(), and ConstVectorView::end().

◆ Vector() [6/6]

Vector::Vector ( const Vector v)

Copy constructor from Vector.

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

Definition at line 686 of file matpackI.cc.

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

◆ ~Vector()

Vector::~Vector ( )
virtual

Destructor for Vector.

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

Definition at line 786 of file matpackI.cc.

References ConstVectorView::mdata.

Member Function Documentation

◆ operator=() [1/3]

Vector & Vector::operator= ( const Array< Numeric > &  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 742 of file matpackI.cc.

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

◆ operator=() [2/3]

Vector & Vector::operator= ( const Vector 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 718 of file matpackI.cc.

References VectorView::begin(), copy(), VectorView::end(), ConstVectorView::nelem(), and resize().

◆ operator=() [3/3]

Vector & Vector::operator= ( Numeric  x)

Assignment operator from scalar.

Assignment operators are not inherited.

Definition at line 751 of file matpackI.cc.

References VectorView::operator=().

◆ resize()

void Vector::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 771 of file matpackI.cc.

References ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, and Range::mstride.

Referenced by abs_h2oSet(), abs_lookupSetup(), abs_lookupSetupBatch(), abs_lookupSetupWide(), abs_lookupTestAccMC(), abs_n2Set(), AbsInputFromRteScalars(), GasAbsLookup::Adapt(), AntennaConstantGaussian1D(), AntennaOff(), AntennaSet1D(), Append(), AtmosphereSet1D(), AtmosphereSet2D(), cloud_RT_surface(), cum_l_stepCalc(), do_gridcell_3d(), emissionPlanck(), GasAbsLookup::Extract(), f_gridFromGasAbsLookup(), f_gridSelectFIndex(), find_effective_channel_boundaries(), findZ11max(), FrequencyFromWavelength(), gaussian_response(), geompath_from_r1_to_r2(), get_iy_of_background(), get_ppath_atmvars(), get_ppath_rtvars(), get_refr_index_1d(), get_refr_index_2d(), get_refr_index_3d(), interpolate_raytracing_points(), iyb_calc(), iyBeerLambertStandardClearsky(), iyEmissionStandardClearsky(), jacobianAddPointingZa(), linspace(), MCGeneral(), MCIPA(), mirror_los(), mixer_matrix(), nlinspace(), nlogspace(), operator=(), opt_prop_sptFromData(), p_gridFromGasAbsLookup(), ArtsParser::parse_numvector(), ArtsParser::parse_numvector_from_string(), polynomial_basis_func(), ppath_calc(), ppath_end_1d(), ppath_end_2d(), ppath_end_3d(), ppath_init_structure(), ppath_start_stepping(), readppdata(), refr_index_Boudouris(), refr_index_BoudourisDryAir(), GriddedField1::resize(), rte_losSet(), rte_posSet(), sensor_aux_vectors(), sensor_responseBeamSwitching(), sensor_responseFrequencySwitching(), sensor_responseMultiMixerBackend(), sensor_responseSimpleAMSU(), test1(), test_and_merge_two_channels(), VectorAddScalar(), VectorExtractFromMatrix(), VectorFlip(), VectorInsertGridPoints(), VectorMatrixMultiply(), VectorScale(), VectorSetConstant(), VectorZtanToZa1D(), VectorZtanToZaRefr1D(), xml_parse_from_stream(), ybatchMetProfiles(), ybatchMetProfilesClear(), yCalc(), yCalc2(), and za_gridOpt().


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