ARTS  2.4.0(git:4fb77825)
Tensor3 Class Reference

The Tensor3 class. More...

#include <matpackIII.h>

Inheritance diagram for Tensor3:
Tensor3View ConstTensor3View

Public Member Functions

 Tensor3 ()=default
 
 Tensor3 (Index p, Index r, Index c)
 Constructor setting size. More...
 
 Tensor3 (Index p, Index r, Index c, Numeric fill)
 Constructor setting size and filling with constant value. More...
 
 Tensor3 (const ConstTensor3View &v)
 Copy constructor from Tensor3View. More...
 
 Tensor3 (const Tensor3 &v)
 Copy constructor from Tensor3. More...
 
 Tensor3 (Tensor3 &&v) noexcept
 
Tensor3operator= (const Tensor3 &x)
 Assignment operator from another tensor. More...
 
Tensor3operator= (Tensor3 &&x) noexcept
 Move assignment operator from another tensor. More...
 
Tensor3operator= (Numeric x)
 Assignment operator from scalar. More...
 
void resize (Index p, Index r, Index c)
 Resize function. More...
 
virtual ~Tensor3 ()
 Destructor for Tensor3. More...
 
- Public Member Functions inherited from Tensor3View
constexpr Tensor3View (const Tensor3View &)=default
 
Tensor3View operator() (const Range &p, const Range &r, const Range &c)
 Index operator for subrange. More...
 
MatrixView operator() (const Range &p, const Range &r, Index c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (const Range &p, Index r, const Range &c)
 Index operator returning an object of type MatrixView. More...
 
MatrixView operator() (Index p, const Range &r, const Range &c)
 Index operator returning an object of type MatrixView. More...
 
VectorView operator() (Index p, Index r, const Range &c)
 Index operator returning an object of type VectorView. More...
 
VectorView operator() (Index p, const Range &r, Index c)
 Index operator returning an object of type VectorView. More...
 
VectorView operator() (const Range &p, Index r, Index c)
 Index operator returning an object of type VectorView. More...
 
Numericoperator() (Index p, Index r, Index c)
 Plain non-const index operator. More...
 
Numericget (Index p, Index r, Index c)
 Get element implementation without assertions. More...
 
const Numericget_c_array () const
 Conversion to plain C-array. More...
 
Numericget_c_array ()
 Conversion to plain C-array. More...
 
Iterator3D begin ()
 Return iterator to first page. More...
 
Iterator3D end ()
 Return iterator behind last page. More...
 
Tensor3Viewoperator= (const ConstTensor3View &v)
 Assignment operator. More...
 
Tensor3Viewoperator= (const Tensor3View &v)
 Assignment from Tensor3View to Tensor3View. More...
 
Tensor3Viewoperator= (const Tensor3 &v)
 Assignment from a Tensor3. More...
 
Tensor3Viewoperator= (Numeric x)
 Assigning a scalar to a Tensor3View will set all elements to this value. More...
 
Tensor3Viewoperator*= (Numeric x)
 Multiplication by scalar. More...
 
Tensor3Viewoperator/= (Numeric x)
 Division by scalar. More...
 
Tensor3Viewoperator+= (Numeric x)
 Addition of scalar. More...
 
Tensor3Viewoperator-= (Numeric x)
 Subtraction of scalar. More...
 
Tensor3Viewoperator*= (const ConstTensor3View &x)
 Element-vise multiplication by another Tensor3. More...
 
Tensor3Viewoperator/= (const ConstTensor3View &x)
 Element-vise division by another Tensor3. More...
 
Tensor3Viewoperator+= (const ConstTensor3View &x)
 Element-vise addition of another Tensor3. More...
 
Tensor3Viewoperator-= (const ConstTensor3View &x)
 Element-vise subtraction of another Tensor3. More...
 
virtual ~Tensor3View ()=default
 Destructor. More...
 
 Tensor3View (const MatrixView &a)
 Special constructor to make a Tensor3 view of a matrix. More...
 
ConstIterator3D begin () const
 Return const iterator to first page. More...
 
ConstIterator3D end () const
 Return const iterator behind last page. More...
 
Numeric get (Index p, Index r, Index c) const
 Get element implementation without assertions. More...
 
- Public Member Functions inherited from ConstTensor3View
constexpr ConstTensor3View (const ConstTensor3View &)=default
 
constexpr ConstTensor3View (ConstTensor3View &&)=default
 
ConstTensor3Viewoperator= (const ConstTensor3View &)=default
 
ConstTensor3Viewoperator= (ConstTensor3View &&)=default
 
bool empty () const
 Check if variable is empty. 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...
 
ConstTensor3View operator() (const Range &p, const Range &r, const Range &c) const
 Const index operator for subrange. More...
 
ConstMatrixView operator() (const Range &p, const Range &r, Index c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (const Range &p, Index r, const Range &c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstMatrixView operator() (Index p, const Range &r, const Range &c) const
 Const index operator returning an object of type ConstMatrixView. More...
 
ConstVectorView operator() (Index p, Index r, const Range &c) const
 Const index operator returning an object of type ConstVectorView. More...
 
ConstVectorView operator() (Index p, const Range &r, Index c) const
 Const index operator returning an object of type ConstVectorView. More...
 
ConstVectorView operator() (const Range &p, Index r, Index c) const
 Const index operator returning an object of type ConstVectorView. More...
 
Numeric operator() (Index p, Index r, Index c) const
 Plain const index operator. More...
 
Numeric get (Index p, Index r, Index c) const
 Get element implementation without assertions. More...
 
ConstIterator3D begin () const
 Return const iterator to first page. More...
 
ConstIterator3D end () const
 Return const iterator behind last page. More...
 
virtual ~ConstTensor3View ()=default
 Destructor. More...
 
 ConstTensor3View (const ConstMatrixView &a)
 Special constructor to make a Tensor3 view of a matrix. More...
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from Tensor3View
 Tensor3View ()=default
 
 Tensor3View (Numeric *data, const Range &p, const Range &r, const Range &c)
 Explicit constructor. More...
 
 Tensor3View (Numeric *data, const Range &pp, const Range &pr, const Range &pc, const Range &np, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Member Functions inherited from ConstTensor3View
 ConstTensor3View ()=default
 
 ConstTensor3View (Numeric *data, const Range &p, const Range &r, const Range &c)
 Explicit constructor. More...
 
 ConstTensor3View (Numeric *data, const Range &pp, const Range &pr, const Range &pc, const Range &np, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Attributes inherited from ConstTensor3View
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 Tensor3 class.

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

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

Definition at line 339 of file matpackIII.h.

Constructor & Destructor Documentation

◆ Tensor3() [1/6]

Tensor3::Tensor3 ( )
default

◆ Tensor3() [2/6]

Tensor3::Tensor3 ( Index  p,
Index  r,
Index  c 
)

Constructor setting size.

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

Definition at line 562 of file matpackIII.cc.

◆ Tensor3() [3/6]

Tensor3::Tensor3 ( Index  p,
Index  r,
Index  c,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 571 of file matpackIII.cc.

◆ Tensor3() [4/6]

Tensor3::Tensor3 ( const ConstTensor3View m)

Copy constructor from Tensor3View.

This automatically sets the size and copies the data.

Definition at line 583 of file matpackIII.cc.

References Tensor3View::begin(), ConstTensor3View::begin(), copy(), and ConstTensor3View::end().

◆ Tensor3() [5/6]

Tensor3::Tensor3 ( const Tensor3 m)

Copy constructor from Tensor3.

This automatically sets the size and copies the data.

Definition at line 593 of file matpackIII.cc.

References ConstTensor3View::mdata, ConstTensor3View::ncols(), ConstTensor3View::npages(), and ConstTensor3View::nrows().

◆ Tensor3() [6/6]

Tensor3::Tensor3 ( Tensor3 &&  v)
inlinenoexcept

Definition at line 347 of file matpackIII.h.

◆ ~Tensor3()

Tensor3::~Tensor3 ( )
virtual

Destructor for Tensor3.

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

Definition at line 697 of file matpackIII.cc.

References ConstTensor3View::mdata.

Member Function Documentation

◆ operator=() [1/3]

Tensor3 & Tensor3::operator= ( const Tensor3 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 630 of file matpackIII.cc.

References ConstTensor3View::mdata, ConstTensor3View::ncols(), ConstTensor3View::npages(), ConstTensor3View::nrows(), resize(), and ARTS::Var::x().

◆ operator=() [2/3]

Tensor3 & Tensor3::operator= ( Numeric  x)

Assignment operator from scalar.

Assignment operators are not inherited.

Definition at line 656 of file matpackIII.cc.

References ConstTensor3View::mdata, ConstTensor3View::ncols(), ConstTensor3View::npages(), ConstTensor3View::nrows(), and ARTS::Var::x().

◆ operator=() [3/3]

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

Move assignment operator from another tensor.

Definition at line 639 of file matpackIII.cc.

References ARTS::Var::x().

◆ resize()

void Tensor3::resize ( Index  p,
Index  r,
Index  c 
)

Friends And Related Function Documentation

◆ swap

void swap ( Tensor3 t1,
Tensor3 t2 
)
friend

Swaps two objects.

Definition at line 688 of file matpackIII.cc.


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