ARTS 2.5.10 (git: 2f1c442c)
|
The MatrixView class. More...
#include <matpackI.h>
Public Types | |
using | iterator = Iterator2D |
![]() | |
using | const_iterator = ConstIterator2D |
Public Member Functions | |
constexpr | MatrixView (const MatrixView &)=default |
Numeric & | operator() (Index r, Index c) ARTS_NOEXCEPT |
Plain index operator. | |
Numeric & | get (Index r, Index c) ARTS_NOEXCEPT |
Get element implementation without assertions. | |
MatrixView | operator() (const Range &r, const Range &c) ARTS_NOEXCEPT |
Index operator for subrange. | |
VectorView | operator() (const Range &r, Index c) ARTS_NOEXCEPT |
Index operator returning a column as an object of type VectorView. | |
VectorView | operator() (Index r, const Range &c) ARTS_NOEXCEPT |
Index operator returning a row as an object of type VectorView. | |
Iterator2D | begin () ARTS_NOEXCEPT |
** Return const iterator to first row. Has to be redefined here, since it is | |
Iterator2D | end () ARTS_NOEXCEPT |
Return iterator behind last row. | |
MatrixView & | operator= (const ConstMatrixView &m) |
Assignment operator. | |
MatrixView & | operator= (const MatrixView &m) |
Assignment from MatrixView to MatrixView. | |
MatrixView & | operator= (const Matrix &m) |
Assignment from a Matrix. | |
MatrixView & | operator= (const ConstVectorView &m) |
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) ARTS_NOEXCEPT |
Multiplication by scalar. | |
MatrixView & | operator/= (Numeric x) ARTS_NOEXCEPT |
Division by scalar. | |
MatrixView & | operator+= (Numeric x) ARTS_NOEXCEPT |
Addition of scalar. | |
MatrixView & | operator-= (Numeric x) ARTS_NOEXCEPT |
Subtraction of scalar. | |
MatrixView & | operator*= (const ConstMatrixView &x) ARTS_NOEXCEPT |
Element-vise multiplication by another Matrix. | |
MatrixView & | operator/= (const ConstMatrixView &x) ARTS_NOEXCEPT |
Element-vise division by another Matrix. | |
MatrixView & | operator+= (const ConstMatrixView &x) ARTS_NOEXCEPT |
Element-vise addition of another Matrix. | |
MatrixView & | operator-= (const ConstMatrixView &x) ARTS_NOEXCEPT |
Element-vise subtraction of another Matrix. | |
MatrixView & | operator*= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise multiplication by a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator/= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise division by a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator+= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise addition of a Vector (acting like a 1-column Matrix). | |
MatrixView & | operator-= (const ConstVectorView &x) ARTS_NOEXCEPT |
Element-vise subtraction of a Vector (acting like a 1-column Matrix). | |
~MatrixView () override=default | |
Destructor. | |
ConstIterator2D | begin () const ARTS_NOEXCEPT |
Return const iterator to first row. | |
ConstIterator2D | end () const ARTS_NOEXCEPT |
Return const iterator behind last row. | |
Numeric | get (Index r, Index c) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
![]() | |
constexpr | ConstMatrixView (const ConstMatrixView &)=default |
constexpr | ConstMatrixView (ConstMatrixView &&)=default |
ConstMatrixView & | operator= (const ConstMatrixView &)=default |
ConstMatrixView & | operator= (ConstMatrixView &&)=default |
Index | selem () const noexcept |
Index | nrows () const noexcept |
Index | ncols () const noexcept |
Index | drows () const noexcept |
Index | dcols () const noexcept |
Index | size () const noexcept |
bool | empty () const noexcept |
Shape< 2 > | shape () const |
Numeric | operator() (Index r, Index c) const ARTS_NOEXCEPT |
Plain const index operator. | |
Numeric | get (Index r, Index c) const ARTS_NOEXCEPT |
Get element implementation without assertions. | |
ConstMatrixView | operator() (const Range &r, const Range &c) const ARTS_NOEXCEPT |
Const index operator for subrange. | |
ConstVectorView | operator() (const Range &r, Index c) const ARTS_NOEXCEPT |
Const index operator returning a column as an object of type ConstVectorView. | |
ConstVectorView | operator() (Index r, const Range &c) const ARTS_NOEXCEPT |
Const index operator returning a row as an object of type ConstVectorView. | |
ConstIterator2D | begin () const ARTS_NOEXCEPT |
Return const iterator to first row. | |
ConstIterator2D | end () const ARTS_NOEXCEPT |
Return const iterator behind last row. | |
ConstVectorView | diagonal () const ARTS_NOEXCEPT |
Matrix diagonal as vector. | |
virtual | ~ConstMatrixView ()=default |
Destructor. | |
Numeric * | get_c_array () const noexcept |
Protected Member Functions | |
MatrixView ()=default | |
MatrixView (Numeric *data, const Range &rr, const Range &cr) ARTS_NOEXCEPT | |
Explicit constructor. | |
MatrixView (Numeric *data, const Range &pr, const Range &pc, const Range &nr, const Range &nc) ARTS_NOEXCEPT | |
Recursive constructor. | |
![]() | |
ConstMatrixView ()=default | |
ConstMatrixView (Numeric *data, const Range &r, const Range &c) ARTS_NOEXCEPT | |
Explicit constructor. | |
ConstMatrixView (Numeric *data, const Range &pr, const Range &pc, const Range &nr, const Range &nc) ARTS_NOEXCEPT | |
Recursive constructor. | |
Friends | |
class | VectorView |
class | Iterator3D |
class | Tensor3View |
class | Tensor4View |
class | Tensor5View |
class | Tensor6View |
class | Tensor7View |
class | ComplexMatrixView |
ConstMatrixView | transpose (ConstMatrixView m) ARTS_NOEXCEPT |
Const version of transpose. | |
MatrixView | transpose (MatrixView m) ARTS_NOEXCEPT |
Returns the transpose. | |
void | mult (MatrixView, const ConstMatrixView &, const ConstMatrixView &) |
Matrix-Matrix Multiplication. | |
Additional Inherited Members | |
![]() | |
static constexpr bool | matpack_type {true} |
![]() | |
Range | mrr {0, 0, 1} |
The row range of mdata that is actually used. | |
Range | mcr {0, 0, 1} |
The column range of mdata that is actually used. | |
Numeric * | mdata {nullptr} |
Pointer to the plain C array that holds the data. | |
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 1188 of file matpackI.h.
using MatrixView::iterator = Iterator2D |
Definition at line 1199 of file matpackI.h.
|
constexprdefault |
|
overridedefault |
Destructor.
|
protecteddefault |
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 835 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 856 of file matpackI.cc.
Iterator2D MatrixView::begin | ( | ) |
** Return const iterator to first row. Has to be redefined here, since it is
** Return const iterator behind last row. */ Return iterator to first row.
Definition at line 601 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
Referenced by copy(), Matrix::Matrix(), operator=(), Matrix::operator=(), and transform().
ConstIterator2D ConstMatrixView::begin | ( | ) | const |
Return const iterator to first row.
Definition at line 1115 of file matpackI.cc.
Iterator2D MatrixView::end | ( | ) |
Return iterator behind last row.
Definition at line 606 of file matpackI.cc.
References ConstMatrixView::mcr, ConstMatrixView::mdata, Range::mextent, ConstMatrixView::mrr, Range::mstart, Range::mstride, and VectorView.
Referenced by copy(), and operator=().
ConstIterator2D ConstMatrixView::end | ( | ) | const |
Return const iterator behind last row.
Definition at line 1116 of file matpackI.cc.
Get element implementation without assertions.
Definition at line 1216 of file matpackI.h.
Referenced by interpweights().
Get element implementation without assertions.
Definition at line 1104 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 558 of file matpackI.cc.
References c.
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 567 of file matpackI.cc.
References ARTS_ASSERT, and c.
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 579 of file matpackI.cc.
References ARTS_ASSERT.
Plain index operator.
Definition at line 1205 of file matpackI.h.
References ARTS_ASSERT, c, and GETFUN.
MatrixView & MatrixView::operator*= | ( | const ConstMatrixView & | x | ) |
Element-vise multiplication by another Matrix.
Definition at line 713 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), ConstVectorView::begin(), c, and VectorView::end().
MatrixView & MatrixView::operator*= | ( | const ConstVectorView & | x | ) |
Element-vise multiplication by a Vector (acting like a 1-column Matrix).
Definition at line 777 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), and c.
MatrixView & MatrixView::operator*= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator+= | ( | const ConstMatrixView & | x | ) |
Element-vise addition of another Matrix.
Definition at line 745 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), ConstVectorView::begin(), c, and VectorView::end().
MatrixView & MatrixView::operator+= | ( | const ConstVectorView & | x | ) |
Element-vise addition of a Vector (acting like a 1-column Matrix).
Definition at line 805 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), and c.
MatrixView & MatrixView::operator+= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator-= | ( | const ConstMatrixView & | x | ) |
Element-vise subtraction of another Matrix.
Definition at line 761 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), ConstVectorView::begin(), c, and VectorView::end().
MatrixView & MatrixView::operator-= | ( | const ConstVectorView & | x | ) |
Element-vise subtraction of a Vector (acting like a 1-column Matrix).
Definition at line 819 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), and c.
MatrixView & MatrixView::operator-= | ( | Numeric | x | ) |
MatrixView & MatrixView::operator/= | ( | const ConstMatrixView & | x | ) |
Element-vise division by another Matrix.
Definition at line 729 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), ConstVectorView::begin(), c, and VectorView::end().
MatrixView & MatrixView::operator/= | ( | const ConstVectorView & | x | ) |
Element-vise division by a Vector (acting like a 1-column Matrix).
Definition at line 791 of file matpackI.cc.
References ARTS_ASSERT, VectorView::begin(), and c.
MatrixView & MatrixView::operator/= | ( | Numeric | x | ) |
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 616 of file matpackI.cc.
References ARTS_ASSERT, begin(), ConstMatrixView::begin(), copy(), ConstMatrixView::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 655 of file matpackI.cc.
References ARTS_ASSERT, begin(), ConstMatrixView::begin(), copy(), ConstMatrixView::end(), ConstMatrixView::mcr, Range::mextent, ConstMatrixView::mrr, and v.
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 642 of file matpackI.cc.
References ARTS_ASSERT, begin(), copy(), 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 630 of file matpackI.cc.
References ARTS_ASSERT, begin(), copy(), end(), ConstMatrixView::mcr, Range::mextent, and ConstMatrixView::mrr.
MatrixView & MatrixView::operator= | ( | Numeric | x | ) |
Assigning a scalar to a MatrixView will set all elements to this value.
Definition at line 667 of file matpackI.cc.
|
friend |
Definition at line 1261 of file matpackI.h.
|
friend |
Definition at line 1255 of file matpackI.h.
|
friend |
Matrix-Matrix Multiplication.
Performs the matrix multiplication A = B * C. The dimensions must match, i.e. A must be a m times n matrix, B a m times k matrix and C a k times c matrix. No memory reallocation takes place, only the data is copied. Using this function on overlapping MatrixViews belonging to the same Matrix will lead to unpredictable results. In particular, this means that A and B must not be the same matrix!
If the memory layout allows it, the multiplication is performed using BLAS' _dgemm, which leads to a significant speed up of the operation. To be compatible with BLAS the matrix views A, B and C must satisfy:
That means that A and B can be ConstMatrixView objects corresponding to transposed/non-transposed submatrices of a matrix, that are continuous along their first/second dimension. C must correspond to a non-transposed submatrix of a matrix, that is continuous along its second dimension.
[in,out] | A | The matrix A, that will hold the result of the multiplication. |
[in] | B | The matrix B |
[in] | C | The matrix C |
Definition at line 1199 of file matpackI.cc.
|
friend |
Definition at line 1256 of file matpackI.h.
|
friend |
Definition at line 1257 of file matpackI.h.
|
friend |
Definition at line 1258 of file matpackI.h.
|
friend |
Definition at line 1259 of file matpackI.h.
|
friend |
Definition at line 1260 of file matpackI.h.
|
friend |
Const version of transpose.
Definition at line 1403 of file matpackI.cc.
|
friend |
Returns the transpose.
This creates a special MatrixView for the transpose. The original is not changed!
Definition at line 1409 of file matpackI.cc.
|
friend |
Definition at line 1254 of file matpackI.h.