ARTS  1.0.222
Public Member Functions | List of all members
Matrix Class Reference

The Matrix class. More...

#include <matpackI.h>

Inheritance diagram for Matrix:
MatrixView ConstMatrixView

Public Member Functions

 Matrix ()
 Default constructor. More...
 
 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...
 
Matrixoperator= (const Matrix &x)
 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...
 
 ~Matrix ()
 Destructor for Matrix. More...
 
- Public Member Functions inherited from MatrixView
Numeric operator() (Index r, Index c) const
 Plain const index operator. 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...
 
Numericoperator() (Index r, Index c)
 Plain index operator. 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...
 
ConstIterator2D begin () const
 Return const iterator to first row. More...
 
ConstIterator2D end () const
 Return const iterator behind last row. More...
 
Iterator2D begin ()
 Return iterator to first row. 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...
 
- Public Member Functions inherited from ConstMatrixView
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...
 
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...
 

Additional Inherited Members

- Protected Member Functions inherited from MatrixView
 MatrixView ()
 Default constructor. More...
 
 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 constructor. More...
 
 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
 The row range of mdata that is actually used. More...
 
Range mcr
 The column range of mdata that is actually used. More...
 
Numericmdata
 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 544 of file matpackI.h.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

Matrix::Matrix ( )
inline

Default constructor.

Definition at line 2123 of file matpackI.h.

◆ Matrix() [2/5]

Matrix::Matrix ( Index  r,
Index  c 
)
inline

Constructor setting size.

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

Definition at line 2134 of file matpackI.h.

◆ Matrix() [3/5]

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

Constructor setting size and filling with constant value.

Definition at line 2143 of file matpackI.h.

◆ Matrix() [4/5]

Matrix::Matrix ( const ConstMatrixView m)
inline

Copy constructor from MatrixView.

This automatically sets the size and copies the data.

Definition at line 2156 of file matpackI.h.

◆ Matrix() [5/5]

Matrix::Matrix ( const Matrix m)
inline

Copy constructor from Matrix.

This automatically sets the size and copies the data.

Definition at line 2166 of file matpackI.h.

◆ ~Matrix()

Matrix::~Matrix ( )
inline

Destructor for Matrix.

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

Definition at line 2259 of file matpackI.h.

Member Function Documentation

◆ operator=() [1/3]

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

Assignment from a vector.

This copies the data from a VectorView to this MatrixView. Dimensions must agree! Resizing would destroy the selection that we might have done in this MatrixView by setting its range.

Definition at line 2223 of file matpackI.h.

◆ operator=() [2/3]

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

Assignment operator from another matrix.

It is important that this operator exists. Otherwise the = operator seems to copy references instead of content in some cases.

The Behavior of this one is a bit special: If the size of the target Matrix is 0 then it will be automatically resized to match (this is needed to have the correct initialization for constructed classes that use the assignment operator to initialize their data).

Definition at line 2188 of file matpackI.h.

◆ operator=() [3/3]

Matrix & Matrix::operator= ( Numeric  x)
inline

Assignment operator from scalar.

Assignment operators also seem to be not inherited.

Definition at line 2213 of file matpackI.h.

◆ resize()

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

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 2237 of file matpackI.h.


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