ARTS  2.4.0(git:4fb77825)
Matrix Class Reference

The Matrix class. More...

#include <matpackI.h>

Inheritance diagram for Matrix:
MatrixView ConstMatrixView

Public Member Functions

 Matrix ()=default
 
 Matrix (Index r, Index c)
 Constructor setting size. More...
 
 Matrix (Index r, Index c, Numeric fill)
 Constructor setting size and filling with constant value. More...
 
 Matrix (const ConstMatrixView &v)
 Copy constructor from MatrixView. More...
 
 Matrix (const Matrix &v)
 Copy constructor from Matrix. More...
 
 Matrix (Matrix &&v) noexcept
 
Matrixoperator= (const Matrix &x)
 Assignment operator from another matrix. More...
 
Matrixoperator= (Matrix &&x) noexcept
 Move assignment operator from another matrix. More...
 
Matrixoperator= (Numeric x)
 Assignment operator from scalar. More...
 
Matrixoperator= (const ConstVectorView &v)
 Assignment from a vector. More...
 
void resize (Index r, Index c)
 Resize function. More...
 
virtual ~Matrix ()
 Destructor for Matrix. More...
 
Numericget_raw_data ()
 
- Public Member Functions inherited from MatrixView
constexpr MatrixView (const MatrixView &)=default
 
Numericoperator() (Index r, Index c)
 Plain index operator. More...
 
Numericget (Index r, Index c)
 Get element implementation without assertions. More...
 
MatrixView operator() (const Range &r, const Range &c)
 Index operator for subrange. More...
 
VectorView operator() (const Range &r, Index c)
 Index operator returning a column as an object of type VectorView. More...
 
VectorView operator() (Index r, const Range &c)
 Index operator returning a row as an object of type VectorView. More...
 
Iterator2D begin ()
 ‍** Return const iterator to first row. Has to be redefined here, since it is More...
 
Iterator2D end ()
 Return iterator behind last row. More...
 
MatrixViewoperator= (const ConstMatrixView &v)
 Assignment operator. More...
 
MatrixViewoperator= (const MatrixView &v)
 Assignment from MatrixView to MatrixView. More...
 
MatrixViewoperator= (const Matrix &v)
 Assignment from a Matrix. More...
 
MatrixViewoperator= (const ConstVectorView &v)
 Assignment from a vector. More...
 
MatrixViewoperator= (Numeric x)
 Assigning a scalar to a MatrixView will set all elements to this value. More...
 
MatrixViewoperator*= (Numeric x)
 Multiplication by scalar. More...
 
MatrixViewoperator/= (Numeric x)
 Division by scalar. More...
 
MatrixViewoperator+= (Numeric x)
 Addition of scalar. More...
 
MatrixViewoperator-= (Numeric x)
 Subtraction of scalar. More...
 
MatrixViewoperator*= (const ConstMatrixView &x)
 Element-vise multiplication by another Matrix. More...
 
MatrixViewoperator/= (const ConstMatrixView &x)
 Element-vise division by another Matrix. More...
 
MatrixViewoperator+= (const ConstMatrixView &x)
 Element-vise addition of another Matrix. More...
 
MatrixViewoperator-= (const ConstMatrixView &x)
 Element-vise subtraction of another Matrix. More...
 
MatrixViewoperator*= (const ConstVectorView &x)
 Element-vise multiplication by a Vector (acting like a 1-column Matrix). More...
 
MatrixViewoperator/= (const ConstVectorView &x)
 Element-vise division by a Vector (acting like a 1-column Matrix). More...
 
MatrixViewoperator+= (const ConstVectorView &x)
 Element-vise addition of a Vector (acting like a 1-column Matrix). More...
 
MatrixViewoperator-= (const ConstVectorView &x)
 Element-vise subtraction of a Vector (acting like a 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 ~MatrixView ()=default
 Destructor. More...
 
ConstIterator2D begin () const
 Return const iterator to first row. More...
 
ConstIterator2D end () const
 Return const iterator behind last row. More...
 
Numeric get (Index r, Index c) const
 Get element implementation without assertions. More...
 
- Public Member Functions inherited from ConstMatrixView
constexpr ConstMatrixView (const ConstMatrixView &)=default
 
constexpr ConstMatrixView (ConstMatrixView &&)=default
 
ConstMatrixViewoperator= (const ConstMatrixView &)=default
 
ConstMatrixViewoperator= (ConstMatrixView &&)=default
 
bool empty () const
 Returns true if variable size is zero. More...
 
Index nrows () const
 Returns the number of rows. More...
 
Index ncols () const
 Returns the number of columns. More...
 
Numeric operator() (Index r, Index c) const
 Plain const index operator. More...
 
Numeric get (Index r, Index c) const
 Get element implementation without assertions. More...
 
ConstMatrixView operator() (const Range &r, const Range &c) const
 Const index operator for subrange. More...
 
ConstVectorView operator() (const Range &r, Index c) const
 Const index operator returning a column as an object of type ConstVectorView. More...
 
ConstVectorView operator() (Index r, const Range &c) const
 Const index operator returning a row as an object of type ConstVectorView. More...
 
ConstIterator2D begin () const
 Return const iterator to first row. More...
 
ConstIterator2D end () const
 Return const iterator behind last row. More...
 
ConstVectorView diagonal () const
 Matrix diagonal as vector. More...
 
virtual ~ConstMatrixView ()=default
 Destructor. More...
 

Friends

void swap (Matrix &m1, Matrix &m2)
 Swaps two objects. More...
 

Additional Inherited Members

- Public Types inherited from MatrixView
typedef Iterator2D iterator
 
- Public Types inherited from ConstMatrixView
typedef ConstIterator2D const_iterator
 
- Protected Member Functions inherited from MatrixView
 MatrixView ()=default
 
 MatrixView (Numeric *data, const Range &r, const Range &c)
 Explicit constructor. More...
 
 MatrixView (Numeric *data, const Range &pr, const Range &pc, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Member Functions inherited from ConstMatrixView
 ConstMatrixView ()=default
 
 ConstMatrixView (Numeric *data, const Range &r, const Range &c)
 Explicit constructor. More...
 
 ConstMatrixView (Numeric *data, const Range &pr, const Range &pc, const Range &nr, const Range &nc)
 Recursive constructor. More...
 
- Protected Attributes inherited from ConstMatrixView
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 Matrix class.

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

  1. Constructors and destructor.
  2. Assignment operator from scalar.
  3. Resize function.

Definition at line 1193 of file matpackI.h.

Constructor & Destructor Documentation

◆ Matrix() [1/6]

Matrix::Matrix ( )
default

◆ Matrix() [2/6]

Matrix::Matrix ( Index  r,
Index  c 
)

Constructor setting size.

This constructor has to set the stride in the row range correctly!

Definition at line 944 of file matpackI.cc.

◆ Matrix() [3/6]

Matrix::Matrix ( Index  r,
Index  c,
Numeric  fill 
)

Constructor setting size and filling with constant value.

Definition at line 950 of file matpackI.cc.

◆ Matrix() [4/6]

Matrix::Matrix ( const ConstMatrixView m)

Copy constructor from MatrixView.

This automatically sets the size and copies the data.

Definition at line 959 of file matpackI.cc.

References MatrixView::begin(), ConstMatrixView::begin(), copy(), and ConstMatrixView::end().

◆ Matrix() [5/6]

Matrix::Matrix ( const Matrix m)

Copy constructor from Matrix.

This automatically sets the size and copies the data.

Definition at line 968 of file matpackI.cc.

References ConstMatrixView::mdata, ConstMatrixView::ncols(), and ConstMatrixView::nrows().

◆ Matrix() [6/6]

Matrix::Matrix ( Matrix &&  v)
inlinenoexcept

Definition at line 1201 of file matpackI.h.

◆ ~Matrix()

Matrix::~Matrix ( )
virtual

Destructor for Matrix.

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

Definition at line 1083 of file matpackI.cc.

References ConstMatrixView::mdata.

Member Function Documentation

◆ get_raw_data()

Numeric* Matrix::get_raw_data ( )
inline

Definition at line 1220 of file matpackI.h.

References ConstMatrixView::mdata.

◆ operator=() [1/4]

Matrix & Matrix::operator= ( const ConstVectorView v)

Assignment from a vector.

This copies the data from a VectorView to this MatrixView.

The dimension is adjusted automatically.

Parameters
vThe vector to assign to this matrix.
Returns
This matrix, by tradition.
Author
Stefan Buehler
Date
2002-12-19

Definition at line 1046 of file matpackI.cc.

◆ operator=() [2/4]

Matrix & Matrix::operator= ( const Matrix m)

Assignment operator from another matrix.

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

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

Definition at line 1004 of file matpackI.cc.

References ConstMatrixView::mdata, ConstMatrixView::ncols(), ConstMatrixView::nrows(), and resize().

◆ operator=() [3/4]

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

Move assignment operator from another matrix.

Definition at line 1013 of file matpackI.cc.

References ConstMatrixView::mdata.

◆ operator=() [4/4]

Matrix & Matrix::operator= ( Numeric  x)

Assignment operator from scalar.

Assignment operators also seem to be not inherited.

Definition at line 1028 of file matpackI.cc.

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

◆ resize()

void Matrix::resize ( Index  r,
Index  c 
)

Resize function.

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

Definition at line 1056 of file matpackI.cc.

Referenced by abs_xsec_per_speciesAddConts(), AddZaAa(), ampmat_to_phamat(), Append(), AtmFieldPRegridHelper(), complex_n_ice_matzler06(), complex_n_water_liebe93(), DiagonalMatrix(), DiffZaAa(), FastemStandAlone(), get_ppath_atmvars(), get_ppath_cloudvars(), get_ppath_f(), get_refr_index_2d(), get_refr_index_3d(), GriddedFieldPRegridHelper(), GriddedFieldZToPRegridHelper(), insert_elements(), integrate_phamat_theta0_phi_alpha6(), interp_atmfield_gp2itw(), interp_atmsurface_gp2itw(), iy_transmission_mult(), iyb_calc(), iyIndependentBeamApproximation(), Matrix1ColFromVector(), Matrix1RowFromVector(), Matrix2ColFromVectors(), Matrix2RowFromVectors(), Matrix3ColFromVectors(), Matrix3RowFromVectors(), MatrixAddScalar(), MatrixCBR(), MatrixCopySparse(), MatrixExtractFromTensor3(), MatrixIdentity(), MatrixMatrixMultiply(), MatrixPlanck(), MatrixScale(), MatrixUnitIntensity(), nca_get_data_Matrix(), nca_read_from_file(), operator=(), opt_prop_NScatElems(), pha_mat_NScatElems(), TelsemAtlas::read(), Reduce(), regrid_atmsurf_by_gp(), regrid_atmsurf_by_gp_oem(), GriddedField2::resize(), rslope_crossing2d(), rslope_crossing3d(), rtmethods_jacobian_finalisation(), sensor_responseMetMM(), InteractiveWorkspace::set_matrix_variable(), ssd_tinterp_parameters(), telsemStandalone(), tessem_read_ascii(), test29(), test30(), test_dense_sparse_multiplication(), test_empty(), test_identity(), test_insert_row(), test_sparse_dense_multiplication(), test_workspace_methods(), xml_read_from_stream(), and za_gridOpt().

Friends And Related Function Documentation

◆ swap

void swap ( Matrix m1,
Matrix m2 
)
friend

Swaps two objects.

Definition at line 1075 of file matpackI.cc.


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