ARTS
2.3.1285(git:92a29ea9-dirty)
|
#include <matpackI.h>
Public Member Functions | |
Vector ()=default | |
Vector (std::initializer_list< Numeric > init) | |
Initialization list 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... | |
Vector (Vector &&v) noexcept | |
Vector (const std::vector< Numeric > &) | |
Converting constructor from std::vector<Numeric>. More... | |
Vector & | operator= (const Vector &v) |
Assignment from another Vector. More... | |
Vector & | operator= (Vector &&v) noexcept |
Move assignment from another Vector. More... | |
Vector & | operator= (std::initializer_list< Numeric > v) |
Assignment from an initializatoin list. More... | |
Vector & | operator= (const Array< Numeric > &v) |
Assignment operator from Array<Numeric>. More... | |
Vector & | operator= (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 | |
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... | |
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... | |
Friends | |
void | swap (Vector &v1, Vector &v2) |
Swaps two objects. 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 | |
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... | |
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 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:
Definition at line 860 of file matpackI.h.
|
default |
Vector::Vector | ( | std::initializer_list< Numeric > | init | ) |
Initialization list constructor.
Definition at line 320 of file matpackI.cc.
References VectorView::begin(), and copy().
|
explicit |
Constructor setting size.
Definition at line 325 of file matpackI.cc.
Constructor setting size and filling with constant value.
Definition at line 329 of file matpackI.cc.
References ConstVectorView::mdata.
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 336 of file matpackI.cc.
References VectorView::begin(), i, and Zeeman::start().
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 348 of file matpackI.cc.
References ConstVectorView::begin(), VectorView::begin(), copy(), and ConstVectorView::end().
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 353 of file matpackI.cc.
References ConstVectorView::mdata, and ConstVectorView::nelem().
|
inlinenoexcept |
Definition at line 893 of file matpackI.h.
References ConstVectorView::mdata, swap(), v1, and v2.
Vector::Vector | ( | const std::vector< Numeric > & | v | ) |
Converting constructor from std::vector<Numeric>.
Definition at line 358 of file matpackI.cc.
References VectorView::begin(), and VectorView::end().
|
virtual |
Destructor for Vector.
This is important, since Vector uses new to allocate storage.
Definition at line 420 of file matpackI.cc.
References ConstVectorView::mdata.
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.)
[in] | v | The other vector to copy to this one. |
Definition at line 374 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::nelem(), and resize().
Move assignment from another Vector.
Definition at line 382 of file matpackI.cc.
References ConstVectorView::mdata, and ConstVectorView::mrange.
Assignment from an initializatoin list.
Definition at line 368 of file matpackI.cc.
References VectorView::begin(), copy(), and resize().
Assignment operator from Array<Numeric>.
This copies the data from an 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.
[in] | v | The array to assign to this. |
Definition at line 393 of file matpackI.cc.
References Array< base >::nelem(), VectorView::operator=(), and resize().
Assignment operator from scalar.
Assignment operators are not inherited.
Definition at line 399 of file matpackI.cc.
References ConstVectorView::mdata, and ConstVectorView::nelem().
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 404 of file matpackI.cc.
References ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, Range::mstride, and n.
Referenced by abs_lookupCalc(), abs_lookupSetup(), abs_lookupSetupWide(), abs_lookupTestAccMC(), abs_xsec_per_speciesAddCIA(), abs_xsec_per_speciesAddConts(), abs_xsec_per_speciesAddHitranXsec(), AbsInputFromRteScalars(), AngularGridsSetFluxCalc(), Append(), AtmosphereSet1D(), AtmosphereSet2D(), AtmosphereSet3D(), AtmRawRead(), AtmWithNLTERawRead(), calculate_weights_linear(), cloud_RT_surface(), cloudbox_checkedCalc(), cum_l_stepCalc(), defocusing_general_sub(), do_gridcell_2d_byltest(), do_gridcell_3d(), do_gridcell_3d_byltest(), DOAngularGridsSet(), DoitScatteringDataPrepare(), ExtractFromMetaSingleScatSpecies(), f_gridFromabs_linesSet(), f_gridFromGasAbsLookup(), f_gridMetMM(), fastem(), find_effective_channel_boundaries(), LineMixingData::FirstOrderData2Vector(), FrequencyFromCGSAngularWavenumber(), FrequencyFromCGSKayserWavenumber(), FrequencyFromWavelength(), gaussian_response(), geo_posEndOfPpath(), geo_posLowestAltitudeOfPpath(), geo_posWherePpathPassesZref(), geompath_from_r1_to_r2(), get_iy_of_background(), get_ppath_atmvars(), get_refr_index_1d(), get_refr_index_2d(), get_refr_index_3d(), get_stepwise_f_partials(), PartitionFunctionData::GetVectorFromData(), LineMixingData::GetVectorFromData(), PressureBroadeningData::GetVectorFromData(), gsl_integration_glfixed_table_alloc(), iyActiveSingleScat(), iyActiveSingleScat2(), iyb_calc(), iyEmissionStandard(), iyEmissionStandardSequential(), iyHybrid(), iyHybrid2(), iyTransmissionStandard(), jacobianAddPointingZa(), jacobianSetFuncTransformation(), LineMixingData::LBLRTM_O2NonResonantData2Vector(), LineMixingData::LBLRTMData2Vector(), linreg(), linspace(), Sparse::list_elements(), MCGeneral(), MCIPA(), MCRadar(), mirror_los(), mixer_matrix(), nca_get_data_Vector(), nca_read_from_file(), nlinspace(), nlogspace(), OEM(), operator=(), opt_prop_sptFromData(), opt_prop_sptFromScat_data(), p_gridDensify(), p_gridFromGasAbsLookup(), p_gridRefine(), ArtsParser::parse_numvector(), ArtsParser::parse_numvector_from_string(), pha_mat_sptFromData(), pha_mat_sptFromScat_data(), polynomial_basis_func(), ppath_init_structure(), propmat_clearskyAddParticles(), psd_cloudice_MH97(), psd_MY05(), psd_rain_W16(), psd_snow_F07(), CIARecord::ReadFromCIA(), readppdata(), Reduce(), refellipsoidEarth(), refellipsoidEuropa(), refellipsoidGanymede(), refellipsoidIo(), refellipsoidJupiter(), refellipsoidMars(), refellipsoidMoon(), refellipsoidVenus(), retrievalErrorsExtract(), rte_losGeometricFromRtePosToRtePos2(), rte_losSet(), rte_posSet(), ScatSpeciesMerge(), ScatSpeciesSizeMassInfo(), LineMixingData::SecondOrderData2Vector(), sensor_aux_vectors(), sensor_responseFrequencySwitching(), sensor_responseGenericAMSU(), sensor_responseSimpleAMSU(), InteractiveWorkspace::set_vector_variable(), set_vmr_from_first_species(), sorted_index_of_ppath_field(), specular_losCalc(), specular_losCalcNoTopography(), ssd_tinterp_parameters(), surface_scalar_reflectivityFromGriddedField4(), surface_scalar_reflectivityFromSurface_rmatrix(), TangentPointExtract(), telsemAtlasLookup(), tessem_read_ascii(), test1(), test_and_merge_two_channels(), test_empty(), test_insert_row(), TestTessem(), tmatrix_random_orientation(), transmittanceFromIy_aux(), VectorAddScalar(), VectorExtractFromMatrix(), VectorFlip(), VectorInsertGridPoints(), VectorMatrixMultiply(), VectorReshapeMatrix(), VectorScale(), VectorSetConstant(), VectorVectorMultiply(), VectorZtanToZa1D(), VectorZtanToZaRefr1D(), x2artsSpectroscopy(), xaStandard(), xml_parse_from_stream(), yActive(), yApplySensorPol(), ybatchMetProfiles(), ybatchMetProfilesClear(), yCalc(), yCalcAppend(), yColdAtmHot(), ySimpleSpectrometer(), and za_gridOpt().
Swaps two objects.
Definition at line 415 of file matpackI.cc.