#include <matpackI.h>
Public Types | |
typedef Iterator2D | iterator |
Public Member Functions | |
Numeric | operator() (Index r, Index c) const |
Plain const index operator. | |
ConstMatrixView | operator() (const Range &r, const Range &c) const |
Const index operator for subrange. | |
ConstVectorView | operator() (const Range &r, Index c) const |
Const index operator returning a column as an object of type ConstVectorView. | |
ConstVectorView | operator() (Index r, const Range &c) const |
Const index operator returning a row as an object of type ConstVectorView. | |
Numeric & | operator() (Index r, Index c) |
Plain index operator. | |
MatrixView | operator() (const Range &r, const Range &c) |
Index operator for subrange. | |
VectorView | operator() (const Range &r, Index c) |
Index operator returning a column as an object of type VectorView. | |
VectorView | operator() (Index r, const Range &c) |
Index operator returning a row as an object of type VectorView. | |
ConstIterator2D | begin () const |
Return const iterator to first row. | |
ConstIterator2D | end () const |
Return const iterator behind last row. | |
Iterator2D | begin () |
Return iterator to first row. | |
Iterator2D | end () |
Return iterator behind last row. | |
MatrixView & | operator= (const ConstMatrixView &v) |
Assignment operator. | |
MatrixView & | operator= (const MatrixView &v) |
Assignment from MatrixView to MatrixView. | |
MatrixView & | operator= (const Matrix &v) |
Assignment from a Matrix. | |
MatrixView & | operator= (const ConstVectorView &v) |
Assignment from a vector. | |
MatrixView & | operator= (Numeric x) |
Assigning a scalar to a MatrixView will set all elements to this value. | |
MatrixView & | operator*= (Numeric x) |
Multiplication by scalar. | |
MatrixView & | operator/= (Numeric x) |
Division by scalar. | |
MatrixView & | operator+= (Numeric x) |
Addition of scalar. | |
MatrixView & | operator-= (Numeric x) |
Subtraction of scalar. | |
MatrixView & | operator*= (const ConstMatrixView &x) |
Element-vise multiplication by another Matrix. | |
MatrixView & | operator/= (const ConstMatrixView &x) |
Element-vise division by another Matrix. | |
MatrixView & | operator+= (const ConstMatrixView &x) |
Element-vise addition of another Matrix. | |
MatrixView & | operator-= (const ConstMatrixView &x) |
Element-vise subtraction of another Matrix. | |
MatrixView & | operator*= (const ConstVectorView &x) |
Element-vise multiplication by a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator/= (const ConstVectorView &x) |
Element-vise division by a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator+= (const ConstVectorView &x) |
Element-vise addition of a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator-= (const ConstVectorView &x) |
Element-vise subtraction of a Vector (acting like a 1-column Matrix). | |
const Numeric * | get_c_array () const |
Conversion to plain C-array. | |
Numeric * | get_c_array () |
Conversion to plain C-array. | |
virtual | ~MatrixView () |
Destructor. | |
Protected Member Functions | |
MatrixView () | |
Default constructor. | |
MatrixView (Numeric *data, const Range &r, const Range &c) | |
Explicit constructor. | |
MatrixView (Numeric *data, const Range &pr, const Range &pc, const Range &nr, const Range &nc) | |
Recursive constructor. | |
Friends | |
class | VectorView |
class | Iterator3D |
class | Tensor3View |
class | Tensor4View |
class | Tensor5View |
class | Tensor6View |
class | Tensor7View |
ConstMatrixView | transpose (ConstMatrixView m) |
Const version of transpose. | |
MatrixView | transpose (MatrixView m) |
Returns the transpose. |
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 659 of file matpackI.h.
typedef Iterator2D MatrixView::iterator |
Definition at line 662 of file matpackI.h.
virtual MatrixView::~MatrixView | ( | ) | [inline, virtual] |
MatrixView::MatrixView | ( | ) | [protected] |
Default constructor.
This is necessary, so that we can have a default constructor for the derived class Matrix.
Definition at line 1335 of file matpackI.cc.
Referenced by operator()(), and 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 1344 of file matpackI.cc.
MatrixView::MatrixView | ( | Numeric * | data, | |
const Range & | pr, | |||
const Range & | pc, | |||
const Range & | nr, | |||
const Range & | nc | |||
) | [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.
*data | The actual data. | |
pr | Previous range. | |
pc | Previous range. | |
nr | New Range. | |
nc | New Range. |
Definition at line 1366 of file matpackI.cc.
Plain const index operator.
Has to be redefined here, since it is hiden by the non-const operator of the derived class.
Reimplemented from ConstMatrixView.
Definition at line 667 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.
Reimplemented from ConstMatrixView.
Definition at line 955 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 |
Reimplemented from ConstMatrixView.
Definition at line 966 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 |
Reimplemented from ConstMatrixView.
Definition at line 977 of file matpackI.cc.
References ConstMatrixView::operator()().
Plain index operator.
Definition at line 675 of file matpackI.h.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
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 985 of file matpackI.cc.
References 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 994 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
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 1008 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
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.
Reimplemented from ConstMatrixView.
Definition at line 1020 of file matpackI.cc.
References ConstMatrixView::begin().
Referenced by Matrix::Matrix(), mult(), operator*=(), operator+=(), operator-=(), operator/=(), Matrix::operator=(), operator=(), and transform().
ConstIterator2D MatrixView::end | ( | ) | const |
Return const iterator behind last row.
Reimplemented from ConstMatrixView.
Definition at line 1026 of file matpackI.cc.
References ConstMatrixView::end().
Referenced by Matrix::Matrix(), mult(), operator*=(), operator+=(), operator-=(), operator/=(), Matrix::operator=(), and operator=().
Iterator2D MatrixView::begin | ( | ) |
Return iterator to first row.
Definition at line 1032 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
Iterator2D MatrixView::end | ( | ) |
Return iterator behind last row.
Definition at line 1039 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
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 1050 of file matpackI.cc.
References begin(), 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 1065 of file matpackI.cc.
References 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!
Reimplemented in Matrix.
Definition at line 1078 of file matpackI.cc.
References 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.
Reimplemented in Matrix.
Definition at line 1092 of file matpackI.cc.
References begin(), 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.
Reimplemented in Matrix.
Definition at line 1105 of file matpackI.cc.
MatrixView & MatrixView::operator*= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator/= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator+= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator-= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator*= | ( | const ConstMatrixView & | x | ) |
Element-vise multiplication by another Matrix.
Definition at line 1194 of file matpackI.cc.
References begin(), ConstMatrixView::begin(), end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator/= | ( | const ConstMatrixView & | x | ) |
Element-vise division by another Matrix.
Definition at line 1213 of file matpackI.cc.
References begin(), ConstMatrixView::begin(), end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator+= | ( | const ConstMatrixView & | x | ) |
Element-vise addition of another Matrix.
Definition at line 1232 of file matpackI.cc.
References begin(), ConstMatrixView::begin(), end(), ConstMatrixView::ncols(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator-= | ( | const ConstMatrixView & | x | ) |
Element-vise subtraction of another Matrix.
Definition at line 1251 of file matpackI.cc.
References begin(), ConstMatrixView::begin(), 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 1270 of file matpackI.cc.
References begin(), ConstVectorView::begin(), end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator/= | ( | const ConstVectorView & | x | ) |
Element-vise division by a Vector (acting like a 1-column Matrix).
Definition at line 1286 of file matpackI.cc.
References begin(), ConstVectorView::begin(), end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator+= | ( | const ConstVectorView & | x | ) |
Element-vise addition of a Vector (acting like a 1-column Matrix).
Definition at line 1302 of file matpackI.cc.
References begin(), ConstVectorView::begin(), end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
MatrixView & MatrixView::operator-= | ( | const ConstVectorView & | x | ) |
Element-vise subtraction of a Vector (acting like a 1-column Matrix).
Definition at line 1318 of file matpackI.cc.
References begin(), ConstVectorView::begin(), end(), ConstMatrixView::ncols(), ConstVectorView::nelem(), and ConstMatrixView::nrows().
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 1169 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
Referenced by nc_read_from_file(), nc_write_to_file(), 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 1184 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, and Range::mstride.
friend class VectorView [friend] |
friend class Iterator3D [friend] |
Definition at line 732 of file matpackI.h.
friend class Tensor3View [friend] |
Definition at line 733 of file matpackI.h.
friend class Tensor4View [friend] |
Definition at line 734 of file matpackI.h.
friend class Tensor5View [friend] |
Definition at line 735 of file matpackI.h.
friend class Tensor6View [friend] |
Definition at line 736 of file matpackI.h.
friend class Tensor7View [friend] |
Definition at line 737 of file matpackI.h.
ConstMatrixView transpose | ( | ConstMatrixView | m | ) | [friend] |
Const version of transpose.
Reimplemented from ConstMatrixView.
Definition at line 1680 of file matpackI.cc.
Referenced by mult().
MatrixView transpose | ( | MatrixView | m | ) | [friend] |
Returns the transpose.
This creates a special MatrixView for the transpose. The original is not changed!
Definition at line 1687 of file matpackI.cc.