ARTS 2.5.10 (git: 2f1c442c)
|
#include <matpackI.h>
Public Member Functions | |
Vector ()=default | |
Vector (std::initializer_list< Numeric > init) | |
Initialization list constructor. | |
Vector (const matpack::vector_like_not_vector auto &init) | |
Initialization from a vector type. | |
Vector (Index n) | |
Constructor setting size. | |
Vector (Index n, Numeric fill) | |
Constructor setting size and filling with constant value. | |
Vector (Numeric start, Index extent, Numeric stride) | |
Constructor filling with values. | |
Vector (const ConstVectorView &v) | |
Copy constructor from VectorView. | |
Vector (const Vector &v) | |
Copy constructor from Vector. | |
Vector (Vector &&v) noexcept | |
Vector (const std::vector< Numeric > &) | |
Converting constructor from std::vector<Numeric>. | |
Vector (Numeric *d, const Range &r0) ARTS_NOEXCEPT | |
Vector & | operator= (const Vector &v) |
Assignment from another Vector. | |
Vector & | operator= (Vector &&v) ARTS_NOEXCEPT |
Move assignment from another Vector. | |
Vector & | operator= (std::initializer_list< Numeric > v) |
Assignment from an initializatoin list. | |
Vector & | operator= (const matpack::vector_like_not_vector auto &init) |
Set from a vector type. | |
Vector & | operator= (const Array< Numeric > &x) |
Assignment operator from Array<Numeric>. | |
Vector & | operator= (Numeric x) |
Assignment operator from scalar. | |
void | resize (Index n) |
Resize function. | |
~Vector () noexcept override | |
Destructor for Vector. | |
template<class F > | |
void | transform_elementwise (F &&func) |
![]() | |
constexpr | VectorView (const VectorView &)=default |
VectorView (const Vector &) | |
Bail out immediately if somebody tries to create a VectorView from a const Vector. | |
VectorView (Vector &v) ARTS_NOEXCEPT | |
Create VectorView from a Vector. | |
Numeric & | operator[] (Index n) ARTS_NOEXCEPT |
Plain Index operator. | |
Numeric & | get (Index n) ARTS_NOEXCEPT |
Get element implementation without assertions. | |
VectorView | operator[] (const Range &r) ARTS_NOEXCEPT |
Index operator for subrange. | |
Iterator1D | begin () ARTS_NOEXCEPT |
Return iterator to first element. | |
Iterator1D | end () ARTS_NOEXCEPT |
Return iterator behind last element. | |
VectorView & | operator= (const ConstVectorView &v) |
Assignment operator. | |
VectorView & | operator= (const VectorView &v) |
Assignment from VectorView to VectorView. | |
VectorView & | operator= (const Vector &v) |
Assignment from Vector. | |
VectorView & | operator= (const Array< Numeric > &v) |
Assignment operator from Array<Numeric>. | |
VectorView & | operator= (Numeric x) |
Assigning a scalar to a VectorView will set all elements to this value. | |
VectorView | operator*= (Numeric x) ARTS_NOEXCEPT |
Multiplication by scalar. | |
VectorView | operator/= (Numeric x) ARTS_NOEXCEPT |
Division by scalar. | |
VectorView | operator+= (Numeric x) ARTS_NOEXCEPT |
Addition of scalar. | |
VectorView | operator-= (Numeric x) ARTS_NOEXCEPT |
Subtraction of scalar. | |
VectorView | operator*= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise multiplication by another vector. | |
VectorView | operator/= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise division by another vector. | |
VectorView | operator+= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise addition of another vector. | |
VectorView | operator-= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise subtraction of another vector. | |
operator MatrixView () ARTS_NOEXCEPT | |
Conversion to 1 column matrix. | |
~VectorView () override=default | |
Destructor. | |
VectorView (Numeric &a) ARTS_NOEXCEPT | |
A special constructor, which allows to make a VectorView from a scalar. | |
ConstIterator1D | begin () const ARTS_NOEXCEPT |
Return const iterator to first element. | |
ConstIterator1D | end () const ARTS_NOEXCEPT |
Return const iterator behind last element. | |
Numeric | get (Index n) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
![]() | |
constexpr | ConstVectorView (const ConstVectorView &)=default |
constexpr | ConstVectorView (ConstVectorView &&)=default |
ConstVectorView & | operator= (const ConstVectorView &)=default |
ConstVectorView & | operator= (ConstVectorView &&)=default |
bool | empty () const noexcept |
Returns true if variable size is zero. | |
Index | nelem () const noexcept |
Returns the number of elements. | |
Index | size () const noexcept |
Shape< 1 > | shape () const |
Numeric | sum () const ARTS_NOEXCEPT |
The sum of all elements of a Vector. | |
Numeric | operator[] (Index n) const ARTS_NOEXCEPT |
Plain const index operator. | |
Numeric | get (Index n) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
ConstVectorView | operator[] (const Range &r) const ARTS_NOEXCEPT |
Const index operator for subrange. | |
ConstIterator1D | begin () const ARTS_NOEXCEPT |
Return const iterator to first element. | |
ConstIterator1D | end () const ARTS_NOEXCEPT |
Return const iterator behind last element. | |
operator ConstMatrixView () const | |
Conversion to const 1 column matrix. | |
virtual | ~ConstVectorView ()=default |
Destructor. | |
ConstVectorView (const Numeric &a) ARTS_NOEXCEPT | |
A special constructor, which allows to make a ConstVectorView from a scalar. | |
Index | selem () const noexcept |
Start element in memory. | |
Index | delem () const noexcept |
Steps in memory between elements. | |
Numeric * | get_c_array () const noexcept |
Conversion to plain C-array, const-version. | |
Friends | |
void | swap (Vector &v1, Vector &v2) noexcept |
Swaps two objects. | |
Additional Inherited Members | |
![]() | |
using | iterator = Iterator1D |
![]() | |
using | const_iterator = ConstIterator1D |
![]() | |
static constexpr bool | matpack_type {true} |
![]() | |
VectorView ()=default | |
VectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT | |
Explicit constructor. | |
VectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT | |
Recursive constructor. | |
![]() | |
ConstVectorView ()=default | |
ConstVectorView (Numeric *data, const Range &range) ARTS_NOEXCEPT | |
Explicit constructor. | |
ConstVectorView (Numeric *data, const Range &p, const Range &n) ARTS_NOEXCEPT | |
Recursive constructor. | |
![]() | |
Range | mrange {0, 0} |
The range of mdata that is actually used. | |
Numeric * | mdata {nullptr} |
Pointer to the plain C array that holds the data. | |
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 910 of file matpackI.h.
|
default |
Vector::Vector | ( | std::initializer_list< Numeric > | init | ) |
Initialization list constructor.
Definition at line 306 of file matpackI.cc.
References VectorView::begin().
|
inlineexplicit |
Initialization from a vector type.
Definition at line 919 of file matpackI.h.
|
explicit |
Constructor setting size.
Definition at line 311 of file matpackI.cc.
Constructor setting size and filling with constant value.
Definition at line 315 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 322 of file matpackI.cc.
References VectorView::begin(), and VectorView::end().
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 334 of file matpackI.cc.
References VectorView::begin(), copy(), and v.
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 339 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::nelem(), and v.
|
inlinenoexcept |
Definition at line 949 of file matpackI.h.
References v.
Vector::Vector | ( | const std::vector< Numeric > & | v | ) |
Converting constructor from std::vector<Numeric>.
Definition at line 344 of file matpackI.cc.
References VectorView::begin(), and v.
Construct from known data
Note that this will call delete on the pointer if it is still valid at the end of the lifetime of this variable
[in] | d | - A pointer to some raw data |
[in] | r0 | - The Range along the first dimension |
Definition at line 964 of file matpackI.h.
References ARTS_ASSERT.
|
overridenoexcept |
Destructor for Vector.
This is important, since Vector uses new to allocate storage.
Definition at line 407 of file matpackI.cc.
References ConstVectorView::mdata.
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] | x | The array to assign to this. |
Definition at line 379 of file matpackI.cc.
References Array< base >::nelem(), VectorView::operator=(), and resize().
|
inline |
Set from a vector type.
Definition at line 1003 of file matpackI.h.
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 360 of file matpackI.cc.
References ConstVectorView::mdata, ConstVectorView::nelem(), resize(), and v.
Assignment operator from scalar.
Assignment operators are not inherited.
Definition at line 385 of file matpackI.cc.
References ConstVectorView::mdata, and ConstVectorView::nelem().
Assignment from an initializatoin list.
Definition at line 354 of file matpackI.cc.
References VectorView::begin(), resize(), and v.
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 390 of file matpackI.cc.
References ARTS_ASSERT, ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, and Range::mstride.
Referenced by abs_xsec_per_speciesAddCIA(), AbsInputFromRteScalars(), GasAbsLookup::Adapt(), AngularGridsSetFluxCalc(), Append(), AtmosphereSet1D(), AtmosphereSet2D(), AtmosphereSet3D(), AtmRawRead(), AtmWithNLTERawRead(), calcBaselineFit(), cloud_RT_surface(), cloudbox_checkedCalc(), defocusing_general_sub(), dlosGauss(), do_gridcell_2d_byltest(), do_gridcell_3d_byltest(), DOAngularGridsSet(), DoitScatteringDataPrepare(), ExtractFromMetaSingleScatSpecies(), f_gridFromAbsorptionLines(), fastem(), find_effective_channel_boundaries(), FrequencyFromCGSAngularWavenumber(), FrequencyFromCGSKayserWavenumber(), FrequencyFromWavelength(), gas_scattering_matIsotropic(), gas_scattering_matRayleigh(), geompath_from_r1_to_r2(), get_direct_radiation(), get_iy_of_background(), get_ppath_atmvars(), get_refr_index_1d(), get_refr_index_2d(), get_refr_index_3d(), get_sun_background(), gsl_integration_glfixed_table_alloc(), iyb_calc(), iyClearsky(), iyEmissionHybrid(), iyEmissionStandard(), iyRadarSingleScat(), iySurfaceLambertian(), iyTransmissionStandard(), jacobianAddPointingZa(), jacobianSetFuncTransformation(), linreg(), linspace(), Sparse::list_elements(), MCGeneral(), MCRadar(), mirror_los(), mixer_matrix(), nlinspace(), nlogspace(), operator=(), opt_prop_sptFromData(), opt_prop_sptFromScat_data(), ArtsParser::parse_numvector(), ArtsParser::parse_numvector_from_string(), pha_mat_sptFromData(), pha_mat_sptFromScat_data(), ppath_init_structure(), propmat_clearskyAddCIA(), propmat_clearskyAddParticles(), propmat_clearskyAddXsecFit(), psd_cloudice_MH97(), psd_MY05(), psd_rain_W16(), psd_SB06(), psd_snow_F07(), CIARecord::ReadFromCIA(), Reduce(), refellipsoidEarth(), refellipsoidEuropa(), refellipsoidGanymede(), refellipsoidIo(), refellipsoidJupiter(), refellipsoidMars(), refellipsoidMoon(), refellipsoidSet(), refellipsoidVenus(), GriddedField1::resize(), retrievalErrorsExtract(), rte_poslosFromECEF(), rte_poslosFromGeodetic(), ScatSpeciesMerge(), ScatSpeciesSizeMassInfo(), sensor_aux_vectors(), sensor_responseGenericAMSU(), sensor_responseMultiMixerBackend(), sensor_responseSimpleAMSU(), set_vmr_from_first_species(), sorted_index_of_ppath_field(), sparse_f_gridFromFrequencyGrid(), specular_losCalc(), specular_losCalcNoTopography(), surface_rtpropFromTypesAverage(), surface_rtpropFromTypesManual(), surface_rtpropFromTypesNearest(), surface_scalar_reflectivityFromGriddedField4(), surface_scalar_reflectivityFromSurface_rmatrix(), telsemAtlasLookup(), tessem_read_ascii(), test1(), test_and_merge_two_channels(), TestTessem(), tmatrix_random_orientation(), transmittanceFromIy_aux(), VectorAdd(), VectorClip(), VectorCrop(), VectorDivide(), VectorFlip(), VectorGaussian(), VectorInsertGridPoints(), VectorMatrixMultiply(), VectorMultiply(), VectorSparseMultiply(), VectorSubtract(), VectorZtanToZa1D(), x2artsSensor(), xml_parse_from_stream(), yApplySensorPol(), ybatchMetProfiles(), ybatchMetProfilesClear(), yCalc(), yCalcAppend(), yColdAtmHot(), yRadar(), ySimpleSpectrometer(), and za_gridOpt().
|
inline |
Definition at line 1047 of file matpackI.h.
Swaps two objects.
Definition at line 401 of file matpackI.cc.