ARTS 2.5.0 (git: 9ee3ac6c)
Tensor4 Class Reference

The Tensor4 class. More...

#include <matpackIV.h>

Inheritance diagram for Tensor4:
Tensor4View ConstTensor4View

Public Member Functions

 Tensor4 ()=default
 
 Tensor4 (Index b, Index p, Index r, Index c)
 Constructor setting size. More...
 
 Tensor4 (Index b, Index p, Index r, Index c, Numeric fill)
 Constructor setting size and filling with constant value. More...
 
 Tensor4 (const ConstTensor4View &v)
 Copy constructor from Tensor4View. More...
 
 Tensor4 (const Tensor4 &v)
 Copy constructor from Tensor4. More...
 
 Tensor4 (Tensor4 &&v) noexcept
 
 Tensor4 (Numeric *d, const Range &r0, const Range &r1, const Range &r2, const Range &r3) ARTS_NOEXCEPT
 
Tensor4operator= (const Tensor4 &x)
 Assignment operator from another tensor. More...
 
Tensor4operator= (Tensor4 &&x) noexcept
 Move assignment operator from another tensor. More...
 
Tensor4operator= (Numeric x)
 Assignment operator from scalar. More...
 
void resize (Index b, Index p, Index r, Index c)
 Resize function. More...
 
virtual ~Tensor4 ()
 Destructor for Tensor4. More...
 
Index size () const noexcept
 
template<std::size_t dim0>
Vector reduce_rank () &&ARTS_NOEXCEPT
 
template<std::size_t dim0, std::size_t dim1>
Matrix reduce_rank () &&ARTS_NOEXCEPT
 
template<std::size_t dim0, std::size_t dim1, std::size_t dim2>
Tensor3 reduce_rank () &&ARTS_NOEXCEPT
 
- Public Member Functions inherited from Tensor4View
constexpr Tensor4View (const Tensor4View &)=default
 
Tensor4View operator() (const Range &b, const Range &p, const Range &r, const Range &c)
 Index operator for subrange. More...
 
Tensor3View operator() (const Range &b, const Range &p, const Range &r, Index c)
 Index operator returning an object of type Tensor3View. More...
 
Tensor3View operator() (const Range &b, const Range &p, Index r, const Range &c)
 Index operator returning an object of type Tensor3View. More...
 
Tensor3View operator() (const Range &b, Index p, const Range &r, const Range &c)
 Index operator returning an object of type Tensor3View. More...
 
Tensor3View operator() (Index b, const Range &p, const Range &r, const Range &c)
 Index operator returning an object of type Tensor3View. More...
 
MatrixView operator() (const Range &b, const Range &p, Index r, Index c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (const Range &b, Index p, const Range &r, Index c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (const Range &b, Index p, Index r, const Range &c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (Index b, const Range &p, Index r, const Range &c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (Index b, const Range &p, const Range &r, Index c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (Index b, Index p, const Range &r, const Range &c)
 Index operator returning an object of type MatrixView. More...
 
VectorView operator() (const Range &b, Index p, Index r, Index c)
 Index operator returning an object of type VectorView. More...
 
VectorView operator() (Index b, const Range &p, Index r, Index c)
 Index operator returning an object of type VectorView. More...
 
VectorView operator() (Index b, Index p, const Range &r, Index c)
 Index operator returning an object of type VectorView. More...
 
VectorView operator() (Index b, Index p, Index r, const Range &c)
 Index operator returning an object of type VectorView. More...
 
Numericoperator() (Index b, Index p, Index r, Index c)
 Plain non-const index operator. More...
 
Numericget (Index b, Index p, Index r, Index c)
 Get element implementation without assertions. More...
 
const Numericget_c_array () const ARTS_NOEXCEPT
 Conversion to plain C-array. More...
 
Numericget_c_array () ARTS_NOEXCEPT
 Conversion to plain C-array. More...
 
Iterator4D begin ()
 Return iterator to first book. More...
 
Iterator4D end ()
 Return iterator behind last book. More...
 
Tensor4Viewoperator= (const ConstTensor4View &v)
 Assignment operator. More...
 
Tensor4Viewoperator= (const Tensor4View &v)
 Assignment from Tensor4View to Tensor4View. More...
 
Tensor4Viewoperator= (const Tensor4 &v)
 Assignment from a Tensor4. More...
 
Tensor4Viewoperator= (Numeric x)
 Assigning a scalar to a Tensor4View will set all elements to this value. More...
 
Tensor4Viewoperator*= (Numeric x)
 Multiplication by scalar. More...
 
Tensor4Viewoperator/= (Numeric x)
 Division by scalar. More...
 
Tensor4Viewoperator+= (Numeric x)
 Addition of scalar. More...
 
Tensor4Viewoperator-= (Numeric x)
 Subtraction of scalar. More...
 
Tensor4Viewoperator*= (const ConstTensor4View &x)
 Element-vise multiplication by another Tensor4. More...
 
Tensor4Viewoperator/= (const ConstTensor4View &x)
 Element-vise division by another Tensor4. More...
 
Tensor4Viewoperator+= (const ConstTensor4View &x)
 Element-vise addition of another Tensor4. More...
 
Tensor4Viewoperator-= (const ConstTensor4View &x)
 Element-vise subtraction of another Tensor4. More...
 
virtual ~Tensor4View ()=default
 Destructor. More...
 
 Tensor4View (const Tensor3View &a)
 Special constructor to make a Tensor4 view of a Tensor3. More...
 
ConstIterator4D begin () const
 Return const iterator to first book. More...
 
ConstIterator4D end () const
 Return const iterator behind last book. More...
 
Numeric get (Index b, Index p, Index r, Index c) const
 Get element implementation without assertions. More...
 
- Public Member Functions inherited from ConstTensor4View
constexpr ConstTensor4View (const ConstTensor4View &)=default
 
constexpr ConstTensor4View (ConstTensor4View &&)=default
 
ConstTensor4Viewoperator= (const ConstTensor4View &)=default
 
ConstTensor4Viewoperator= (ConstTensor4View &&)=default
 
bool empty () const
 Check if variable is empty. More...
 
Index nbooks () const
 Returns the number of books. More...
 
Index npages () const
 Returns the number of pages. More...
 
Index nrows () const
 Returns the number of rows. More...
 
Index ncols () const
 Returns the number of columns. More...
 
ConstTensor4View operator() (const Range &b, const Range &p, const Range &r, const Range &c) const
 Const index operator for subrange. More...
 
ConstTensor3View operator() (const Range &b, const Range &p, const Range &r, Index c) const
 Const index operator returning an object of type ConstTensor3View. More...
 
ConstTensor3View operator() (const Range &b, const Range &p, Index r, const Range &c) const
 Const index operator returning an object of type ConstTensor3View. More...
 
ConstTensor3View operator() (const Range &b, Index p, const Range &r, const Range &c) const
 Const index operator returning an object of type ConstTensor3View. More...
 
ConstTensor3View operator() (Index b, const Range &p, const Range &r, const Range &c) const
 Const index operator returning an object of type ConstTensor3View. More...
 
ConstMatrixView operator() (const Range &b, const Range &p, Index r, Index c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (const Range &b, Index p, const Range &r, Index c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (const Range &b, Index p, Index r, const Range &c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (Index b, const Range &p, Index r, const Range &c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (Index b, const Range &p, const Range &r, Index c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (Index b, Index p, const Range &r, const Range &c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstVectorView operator() (const Range &b, Index p, Index r, Index c) const
 Const index operator returning an object of type ConstVectorView. More...
 
ConstVectorView operator() (Index b, const Range &p, Index r, Index c) const
 Const index operator returning an object of type ConstVectorView. More...
 
ConstVectorView operator() (Index b, Index p, const Range &r, Index c) const
 Const index operator returning an object of type ConstVectorView. More...
 
ConstVectorView operator() (Index b, Index p, Index r, const Range &c) const
 Const index operator returning an object of type ConstVectorView. More...
 
Numeric operator() (Index b, Index p, Index r, Index c) const
 Plain const index operator. More...
 
Numeric get (Index b, Index p, Index r, Index c) const
 Get element implementation without assertions. More...
 
ConstIterator4D begin () const
 Return const iterator to first book. More...
 
ConstIterator4D end () const
 Return const iterator behind last book. More...
 
virtual ~ConstTensor4View ()=default
 Destructor. More...
 
 ConstTensor4View (const ConstTensor3View &a)
 Special constructor to make a Tensor4 view of a Tensor3. More...
 

Friends

void swap (Tensor4 &t1, Tensor4 &t2)
 Swaps two objects. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Tensor4View
 Tensor4View ()=default
 
 Tensor4View (Numeric *data, const Range &b, const Range &p, const Range &r, const Range &c)
 Explicit constructor. More...
 
 Tensor4View (Numeric *data, const Range &pb, const Range &pp, const Range &pr, const Range &pc, const Range &nb, const Range &np, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Member Functions inherited from ConstTensor4View
 ConstTensor4View ()=default
 
 ConstTensor4View (Numeric *data, const Range &b, const Range &p, const Range &r, const Range &c)
 Explicit constructor. More...
 
 ConstTensor4View (Numeric *data, const Range &pb, const Range &pp, const Range &pr, const Range &pc, const Range &nb, const Range &np, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Attributes inherited from ConstTensor4View
Range mbr {0, 0, 1}
 The book range of mdata that is actually used. More...
 
Range mpr {0, 0, 1}
 The page range of mdata that is actually used. More...
 
Range mrr {0, 0, 1}
 The row range of mdata that is actually used. More...
 
Range mcr {0, 0, 1}
 The column range of mdata that is actually used. More...
 
Numericmdata {nullptr}
 Pointer to the plain C array that holds the data. More...
 

Detailed Description

The Tensor4 class.

This is a Tensor4View that also allocates storage automatically, and deallocates it when it is destroyed. We take all the functionality from Tensor4View. Additionally defined here are:

  1. Constructors and destructor.
  2. Assignment operators.
  3. Resize function.

Definition at line 421 of file matpackIV.h.

Constructor & Destructor Documentation

◆ Tensor4() [1/7]

Tensor4::Tensor4 ( )
default

◆ Tensor4() [2/7]

Tensor4::Tensor4 ( Index  b,
Index  p,
Index  r,
Index  c 
)

Constructor setting size.

This constructor has to set the strides in the book, page and row ranges correctly!

Definition at line 946 of file matpackIV.cc.

◆ Tensor4() [3/7]

Tensor4::Tensor4 ( Index  b,
Index  p,
Index  r,
Index  c,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 956 of file matpackIV.cc.

References b, c, and ConstTensor4View::mdata.

◆ Tensor4() [4/7]

Tensor4::Tensor4 ( const ConstTensor4View m)

Copy constructor from Tensor4View.

This automatically sets the size and copies the data.

Definition at line 969 of file matpackIV.cc.

References Tensor4View::begin(), ConstTensor4View::begin(), copy(), and ConstTensor4View::end().

◆ Tensor4() [5/7]

Tensor4::Tensor4 ( const Tensor4 m)

Copy constructor from Tensor4.

This automatically sets the size and copies the data.

Definition at line 980 of file matpackIV.cc.

References ConstTensor4View::mdata, ConstTensor4View::nbooks(), ConstTensor4View::ncols(), ConstTensor4View::npages(), and ConstTensor4View::nrows().

◆ Tensor4() [6/7]

Tensor4::Tensor4 ( Tensor4 &&  v)
inlinenoexcept

Definition at line 429 of file matpackIV.h.

References v.

◆ Tensor4() [7/7]

Tensor4::Tensor4 ( Numeric d,
const Range r0,
const Range r1,
const Range r2,
const Range r3 
)
inline

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

Parameters
[in]d- A pointer to some raw data
[in]r0- The Range along the first dimension
[in]r1- The Range along the second dimension
[in]r2- The Range along the third dimension
[in]r3- The Range along the fourth dimension

Definition at line 444 of file matpackIV.h.

References ARTS_ASSERT, and IGRF::r0.

◆ ~Tensor4()

Tensor4::~Tensor4 ( )
virtual

Destructor for Tensor4.

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

Definition at line 1098 of file matpackIV.cc.

References ConstTensor4View::mdata.

Member Function Documentation

◆ operator=() [1/3]

Tensor4 & Tensor4::operator= ( const Tensor4 x)

Assignment operator from another tensor.

While dimensions of views can not be adjusted, dimensions of tensors 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 tensors 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 (Tensor = Tensor). It implicitly covers the cases Tensor=TensorView, etc, because there is a default constructor for Tensor from TensorView. (See C++ Primer Plus, page 571ff.)

Parameters
mThe other tensor to assign to this one.
Returns
This tensor, by tradition.
Author
Stefan Buehler
Date
2002-12-19

Definition at line 1020 of file matpackIV.cc.

References ConstTensor4View::mdata, ConstTensor4View::nbooks(), ConstTensor4View::ncols(), ConstTensor4View::npages(), ConstTensor4View::nrows(), and resize().

◆ operator=() [2/3]

Tensor4 & Tensor4::operator= ( Numeric  x)

Assignment operator from scalar.

Assignment operators are not inherited.

Definition at line 1050 of file matpackIV.cc.

References ConstTensor4View::mdata, ConstTensor4View::nbooks(), ConstTensor4View::ncols(), ConstTensor4View::npages(), and ConstTensor4View::nrows().

◆ operator=() [3/3]

Tensor4 & Tensor4::operator= ( Tensor4 &&  x)
noexcept

Move assignment operator from another tensor.

Definition at line 1031 of file matpackIV.cc.

References ConstTensor4View::mdata.

◆ reduce_rank() [1/3]

template<std::size_t dim0>
Vector Tensor4::reduce_rank ( ) &&
inline

◆ reduce_rank() [2/3]

template<std::size_t dim0, std::size_t dim1>
Matrix Tensor4::reduce_rank ( ) &&
inline

◆ reduce_rank() [3/3]

template<std::size_t dim0, std::size_t dim1, std::size_t dim2>
Tensor3 Tensor4::reduce_rank ( ) &&
inline

◆ resize()

void Tensor4::resize ( Index  b,
Index  p,
Index  r,
Index  c 
)

Resize function.

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

Definition at line 1058 of file matpackIV.cc.

References ARTS_ASSERT, b, c, ConstTensor4View::mbr, ConstTensor4View::mcr, ConstTensor4View::mdata, Range::mextent, ConstTensor4View::mpr, ConstTensor4View::mrr, Range::mstart, and Range::mstride.

Referenced by GasAbsLookup::Adapt(), antenna_responseGaussian(), antenna_responseVaryingGaussian(), Append(), atm_fields_compactCreateFromField(), AtmFieldPRegrid(), AtmFieldsAndParticleBulkPropFieldFromCompact(), AtmFieldsCalcExpand1D(), AtmFieldsExpand1D(), AtmFieldsExtract1D(), cloudboxOff(), Extract(), FieldFromGriddedField(), irradiance_fieldFromRadiance(), iyEmissionStandard(), iyHybrid(), iyIndependentBeamApproximation(), iyTransmissionStandard(), nca_get_data_Tensor4(), nca_read_from_file(), StokesVector::operator=(), operator=(), particle_bulkpropRadarOnionPeeling(), pha_matCalc(), pnd_fieldCalcFromParticleBulkProps(), pnd_fieldCalcFrompnd_field_raw(), pnd_fieldExpand1D(), pnd_fieldZero(), PropagationMatrix::PropagationMatrix(), RadiationFieldSpectralIntegrate(), Reduce(), GriddedField4::resize(), ScatSpeciesMerge(), StokesVector::StokesVector(), SurfaceBlackbody(), surfaceBlackbody(), surfaceFastem(), surfaceFlatReflectivity(), surfaceFlatRefractiveIndex(), surfaceFlatRvRh(), surfaceFlatScalarReflectivity(), surfaceLambertianSimple(), surfaceSplitSpecularTo3beams(), Tensor4Add(), Tensor4Multiply(), Tensor4SetConstant(), and xml_read_from_stream().

◆ size()

Friends And Related Function Documentation

◆ swap

void swap ( Tensor4 t1,
Tensor4 t2 
)
friend

Swaps two objects.

Definition at line 1088 of file matpackIV.cc.


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