ARTS
2.2.66
|
The MatrixView class. More...
#include <matpackI.h>
Public Types | |
typedef Iterator2D | iterator |
Public Types inherited from ConstMatrixView | |
typedef ConstIterator2D | const_iterator |
Public Member Functions | |
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... | |
Numeric & | operator() (Index r, Index c) |
Plain index operator. More... | |
Numeric & | get (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... | |
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... | |
MatrixView & | operator= (const ConstMatrixView &v) |
Assignment operator. More... | |
MatrixView & | operator= (const MatrixView &v) |
Assignment from MatrixView to MatrixView. More... | |
MatrixView & | operator= (const Matrix &v) |
Assignment from a Matrix. More... | |
MatrixView & | operator= (const ConstVectorView &v) |
Assignment from a vector. More... | |
MatrixView & | operator= (Numeric x) |
Assigning a scalar to a MatrixView will set all elements to this value. More... | |
MatrixView & | operator*= (Numeric x) |
Multiplication by scalar. More... | |
MatrixView & | operator/= (Numeric x) |
Division by scalar. More... | |
MatrixView & | operator+= (Numeric x) |
Addition of scalar. More... | |
MatrixView & | operator-= (Numeric x) |
Subtraction of scalar. More... | |
MatrixView & | operator*= (const ConstMatrixView &x) |
Element-vise multiplication by another Matrix. More... | |
MatrixView & | operator/= (const ConstMatrixView &x) |
Element-vise division by another Matrix. More... | |
MatrixView & | operator+= (const ConstMatrixView &x) |
Element-vise addition of another Matrix. More... | |
MatrixView & | operator-= (const ConstMatrixView &x) |
Element-vise subtraction of another Matrix. More... | |
MatrixView & | operator*= (const ConstVectorView &x) |
Element-vise multiplication by a Vector (acting like a 1-column Matrix). More... | |
MatrixView & | operator/= (const ConstVectorView &x) |
Element-vise division by a Vector (acting like a 1-column Matrix). More... | |
MatrixView & | operator+= (const ConstVectorView &x) |
Element-vise addition of a Vector (acting like a 1-column Matrix). More... | |
MatrixView & | operator-= (const ConstVectorView &x) |
Element-vise subtraction of a Vector (acting like a 1-column Matrix). More... | |
const Numeric * | get_c_array () const |
Conversion to plain C-array. More... | |
Numeric * | get_c_array () |
Conversion to plain C-array. More... | |
virtual | ~MatrixView () |
Destructor. 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... | |
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... | |
virtual | ~ConstMatrixView () |
Destructor. More... | |
Protected Member Functions | |
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... | |
Friends | |
class | VectorView |
class | Iterator3D |
class | Tensor3View |
class | Tensor4View |
class | Tensor5View |
class | Tensor6View |
class | Tensor7View |
ConstMatrixView | transpose (ConstMatrixView m) |
Const version of transpose. More... | |
MatrixView | transpose (MatrixView m) |
Returns the transpose. More... | |
Additional Inherited Members | |
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... | |
Numeric * | mdata |
Pointer to the plain C array that holds the data. More... | |
The MatrixView class.
This contains the main implementation of a Matrix. It defines the concepts of MatrixView. Plus additionally the recursive subrange operator, which makes it possible to create a MatrixView from a subrange of a MatrixView.
The class Matrix is just a special case of a MatrixView which also allocates storage.
Definition at line 679 of file matpackI.h.
typedef Iterator2D MatrixView::iterator |
Definition at line 682 of file matpackI.h.
|
inlinevirtual |
Destructor.
Definition at line 758 of file matpackI.h.
|
protected |
Default constructor.
This is necessary, so that we can have a default constructor for the derived class Matrix.
Definition at line 1380 of file matpackI.cc.
Referenced by transpose().
Explicit constructor.
This one is used by Matrix to initialize its own MatrixView part. The row range rr must have a stride to account for the length of one row.
Definition at line 1389 of file matpackI.cc.
|
protected |
Recursive constructor.
This is used to construct SubMatrices from SubMatrices. That means that the new ranges have to be interpreted relative to the original ranges.
The new ranges may contain -1 for the extent which acts as a joker. However, the used Range constructor converts this to an explicit range, consistent with the original Range.
Definition at line 1411 of file matpackI.cc.
ConstIterator2D MatrixView::begin | ( | ) | const |
Return const iterator to first row.
Has to be redefined here, since it is hiden by the non-const operator of the derived class.
Definition at line 1065 of file matpackI.cc.
References ConstMatrixView::begin().
Referenced by copy(), Matrix::Matrix(), mult(), VectorView::operator=(), operator=(), Matrix::operator=(), and transform().
Iterator2D MatrixView::begin | ( | ) |
Return iterator to first row.
Definition at line 1077 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
ConstIterator2D MatrixView::end | ( | ) | const |
Return const iterator behind last row.
Definition at line 1071 of file matpackI.cc.
References ConstMatrixView::end().
Referenced by copy(), Matrix::Matrix(), mult(), operator=(), and Matrix::operator=().
Iterator2D MatrixView::end | ( | ) |
Return iterator behind last row.
Definition at line 1084 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
Get element implementation without assertions.
Definition at line 691 of file matpackI.h.
References ConstMatrixView::get().
Referenced by interpweights().
Get element implementation without assertions.
Definition at line 710 of file matpackI.h.
References Range::mstride.
const Numeric * MatrixView::get_c_array | ( | ) | const |
Conversion to plain C-array.
This function returns a pointer to the raw data. It fails if the MatrixView is not pointing to the beginning of a Matrix or the stride is not 1 because the caller expects to get a C array with continuous data.
Definition at line 1214 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
Referenced by nca_get_data_Matrix(), nca_put_var_Matrix(), nca_read_from_file(), nca_write_to_file(), Reduce(), and test38().
Numeric * MatrixView::get_c_array | ( | ) |
Conversion to plain C-array.
This function returns a pointer to the raw data. It fails if the MatrixView is not pointing to the beginning of a Matrix or the stride is not 1 because the caller expects to get a C array with continuous data.
Definition at line 1229 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
Plain const index operator.
Has to be redefined here, since it is hiden by the non-const operator of the derived class.
Definition at line 687 of file matpackI.h.
References ConstMatrixView::operator()().
ConstMatrixView MatrixView::operator() | ( | const Range & | r, |
const Range & | c | ||
) | const |
Const index operator for subrange.
We have to also account for the case, that *this is already a subrange of a Matrix. This allows correct recursive behavior. Has to be redefined here, since it is hiden by the non-const operator of the derived class.
Definition at line 1000 of file matpackI.cc.
References ConstMatrixView::operator()().
ConstVectorView MatrixView::operator() | ( | const Range & | r, |
Index | c | ||
) | const |
Const index operator returning a column as an object of type ConstVectorView.
Has to be redefined here, since it is hiden by the non-const operator of the derived class.
r | A range of rows. |
c | Index of selected column |
Definition at line 1011 of file matpackI.cc.
References ConstMatrixView::operator()().
ConstVectorView MatrixView::operator() | ( | Index | r, |
const Range & | c | ||
) | const |
Const index operator returning a row as an object of type ConstVectorView.
Has to be redefined here, since it is hiden by the non-const operator of the derived class.
r | Index of selected row. |
c | Range of columns |
Definition at line 1022 of file matpackI.cc.
References ConstMatrixView::operator()().
Plain index operator.
Definition at line 699 of file matpackI.h.
MatrixView MatrixView::operator() | ( | const Range & | r, |
const Range & | c | ||
) |
Index operator for subrange.
We have to also account for the case, that *this is already a subrange of a Matrix. This allows correct recursive behavior.
Definition at line 1030 of file matpackI.cc.
References ConstMatrixView::MatrixView, ConstMatrixView::mcr, ConstMatrixView::mdata, and ConstMatrixView::mrr.
VectorView MatrixView::operator() | ( | const Range & | r, |
Index | c | ||
) |
Index operator returning a column as an object of type VectorView.
r | A range of rows. |
c | Index of selected column |
Definition at line 1039 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
VectorView MatrixView::operator() | ( | Index | r, |
const Range & | c | ||
) |
Index operator returning a row as an object of type VectorView.
r | Index of selected row. |
c | Range of columns |
Definition at line 1053 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
MatrixView & MatrixView::operator*= | ( | Numeric | x | ) |
Multiplication by scalar.
Definition at line 1157 of file matpackI.cc.
References ConstMatrixView::begin(), and ConstMatrixView::end().
MatrixView & MatrixView::operator*= | ( | const ConstMatrixView & | x | ) |
Element-vise multiplication by another Matrix.
Definition at line 1239 of file matpackI.cc.
References VectorView::begin(), ConstMatrixView::begin(), VectorView::end(), ConstMatrixView::end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator*= | ( | const ConstVectorView & | x | ) |
Element-vise multiplication by a Vector (acting like a 1-column Matrix).
Definition at line 1315 of file matpackI.cc.
References ConstVectorView::begin(), VectorView::begin(), ConstMatrixView::begin(), ConstMatrixView::end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator+= | ( | Numeric | x | ) |
Addition of scalar.
Definition at line 1183 of file matpackI.cc.
References ConstMatrixView::begin(), and ConstMatrixView::end().
MatrixView & MatrixView::operator+= | ( | const ConstMatrixView & | x | ) |
Element-vise addition of another Matrix.
Definition at line 1277 of file matpackI.cc.
References VectorView::begin(), ConstMatrixView::begin(), VectorView::end(), ConstMatrixView::end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator+= | ( | const ConstVectorView & | x | ) |
Element-vise addition of a Vector (acting like a 1-column Matrix).
Definition at line 1347 of file matpackI.cc.
References ConstVectorView::begin(), VectorView::begin(), ConstMatrixView::begin(), ConstMatrixView::end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator-= | ( | Numeric | x | ) |
Subtraction of scalar.
Definition at line 1196 of file matpackI.cc.
References ConstMatrixView::begin(), and ConstMatrixView::end().
MatrixView & MatrixView::operator-= | ( | const ConstMatrixView & | x | ) |
Element-vise subtraction of another Matrix.
Definition at line 1296 of file matpackI.cc.
References VectorView::begin(), ConstMatrixView::begin(), VectorView::end(), ConstMatrixView::end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator-= | ( | const ConstVectorView & | x | ) |
Element-vise subtraction of a Vector (acting like a 1-column Matrix).
Definition at line 1363 of file matpackI.cc.
References ConstVectorView::begin(), VectorView::begin(), ConstMatrixView::begin(), ConstMatrixView::end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator/= | ( | Numeric | x | ) |
Division by scalar.
Definition at line 1170 of file matpackI.cc.
References ConstMatrixView::begin(), and ConstMatrixView::end().
MatrixView & MatrixView::operator/= | ( | const ConstMatrixView & | x | ) |
Element-vise division by another Matrix.
Definition at line 1258 of file matpackI.cc.
References VectorView::begin(), ConstMatrixView::begin(), VectorView::end(), ConstMatrixView::end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator/= | ( | const ConstVectorView & | x | ) |
Element-vise division by a Vector (acting like a 1-column Matrix).
Definition at line 1331 of file matpackI.cc.
References ConstVectorView::begin(), VectorView::begin(), ConstMatrixView::begin(), ConstMatrixView::end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator= | ( | const ConstMatrixView & | m | ) |
Assignment operator.
This copies the data from another MatrixView 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 1095 of file matpackI.cc.
References ConstMatrixView::begin(), copy(), ConstMatrixView::end(), ConstMatrixView::mcr, Range::mextent, and ConstMatrixView::mrr.
MatrixView & MatrixView::operator= | ( | const MatrixView & | m | ) |
Assignment from MatrixView to MatrixView.
This is a tricky one. The problem is that since MatrixView is derived from ConstMatrixView, a default = operator is generated by the compiler, which does not do what we want. So we need this one to override the default.
Definition at line 1110 of file matpackI.cc.
References ConstMatrixView::begin(), begin(), copy(), end(), ConstMatrixView::mcr, Range::mextent, and ConstMatrixView::mrr.
MatrixView & MatrixView::operator= | ( | const Matrix & | m | ) |
Assignment from a Matrix.
This must exist to overide the automatically generated assignment operators, which don't copy the contents!
Definition at line 1123 of file matpackI.cc.
References ConstMatrixView::begin(), begin(), copy(), end(), ConstMatrixView::mcr, Range::mextent, and ConstMatrixView::mrr.
MatrixView & MatrixView::operator= | ( | const ConstVectorView & | v | ) |
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 1137 of file matpackI.cc.
References ConstMatrixView::begin(), copy(), ConstMatrixView::end(), ConstMatrixView::mcr, Range::mextent, ConstMatrixView::mrr, and ConstVectorView::nelem().
MatrixView & MatrixView::operator= | ( | Numeric | x | ) |
Assigning a scalar to a MatrixView will set all elements to this value.
Definition at line 1150 of file matpackI.cc.
References ConstMatrixView::begin(), copy(), and ConstMatrixView::end().
|
friend |
Definition at line 762 of file matpackI.h.
|
friend |
Definition at line 763 of file matpackI.h.
|
friend |
Definition at line 764 of file matpackI.h.
|
friend |
Definition at line 765 of file matpackI.h.
|
friend |
Definition at line 766 of file matpackI.h.
|
friend |
Definition at line 767 of file matpackI.h.
|
friend |
Const version of transpose.
Definition at line 1799 of file matpackI.cc.
Referenced by mult(), and transpose().
|
friend |
Returns the transpose.
This creates a special MatrixView for the transpose. The original is not changed!
Definition at line 1806 of file matpackI.cc.
|
friend |
Definition at line 761 of file matpackI.h.