ARTS
2.4.0(git:4fb77825)
|
A constant view of a Matrix. More...
#include <matpackI.h>
Public Types | |
typedef ConstIterator2D | const_iterator |
Public Member Functions | |
constexpr | ConstMatrixView (const ConstMatrixView &)=default |
constexpr | ConstMatrixView (ConstMatrixView &&)=default |
ConstMatrixView & | operator= (const ConstMatrixView &)=default |
ConstMatrixView & | operator= (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... | |
Protected Member Functions | |
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 | |
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... | |
Numeric * | mdata {nullptr} |
Pointer to the plain C array that holds the data. More... | |
A constant view of a Matrix.
This, together with the derived class MatrixView, 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 982 of file matpackI.h.
Definition at line 990 of file matpackI.h.
|
constexprdefault |
|
constexprdefault |
|
virtualdefault |
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 498 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 519 of file matpackI.cc.
ConstIterator2D ConstMatrixView::begin | ( | ) | const |
Return const iterator to first row.
Definition at line 469 of file matpackI.cc.
References ConstVectorView, mcr, mdata, mrr, Range::mstart, and Range::mstride.
Referenced by copy(), Matrix::Matrix(), mult_general(), operator<<(), and MatrixView::operator=().
ConstVectorView ConstMatrixView::diagonal | ( | ) | const |
Matrix diagonal as vector.
Returns a ConstMatrixView on the diagonal entries of the matrix. For a given (n,m) matrix M the diagonal vector v is the vector of length min{n,m} with entries
v[i] = M(i,i)
Definition at line 489 of file matpackI.cc.
References ConstVectorView, mcr, mdata, Range::mextent, min(), mrr, Range::mstart, and Range::mstride.
Referenced by test_diagonal().
bool ConstMatrixView::empty | ( | ) | const |
Returns true if variable size is zero.
Definition at line 426 of file matpackI.cc.
References ncols(), and nrows().
Referenced by get_variable_value(), RetrievalQuantity::HasAffine(), MCGeneral(), test_empty(), and xsec_species().
ConstIterator2D ConstMatrixView::end | ( | ) | const |
Return const iterator behind last row.
Definition at line 474 of file matpackI.cc.
References ConstVectorView, mcr, mdata, Range::mextent, mrr, Range::mstart, and Range::mstride.
Referenced by copy(), Matrix::Matrix(), operator<<(), and MatrixView::operator=().
Get element implementation without assertions.
Definition at line 1009 of file matpackI.h.
Index ConstMatrixView::ncols | ( | ) | const |
Returns the number of columns.
Definition at line 432 of file matpackI.cc.
References mcr, and Range::mextent.
Referenced by abs_xsec_per_speciesAddCIA(), AddZaAa(), antenna2d_gridded_dlos(), antenna2d_interp_response(), AntennaMultiBeamsToPencilBeams(), Append(), atm_fields_compactFromMatrix(), BF86_CIA_N2(), calc_lookup_error(), calcSingleScatteringDataProperties(), GriddedField2::checksize(), GriddedField2::checksize_strict(), chk_met_mm_backend(), CKD24_H20(), CKD_222_foreign_h2o(), CKD_222_self_h2o(), CKD_241_co2(), CKD_242_foreign_h2o(), CKD_242_self_h2o(), CKD_mt_100_foreign_h2o(), CKD_mt_100_self_h2o(), CKD_mt_250_CIAfun_n2(), CKD_mt_250_CIArot_n2(), CKD_mt_250_co2(), CKD_mt_250_foreign_h2o(), CKD_mt_250_o2_vis(), CKD_mt_250_self_h2o(), CKD_mt_320_foreign_h2o(), CKD_mt_320_self_h2o(), CKD_mt_CIAfun_n2(), CKD_mt_CIAfun_o2(), CKD_mt_CIArot_n2(), CKD_mt_co2(), CKD_mt_v0v0_o2(), CKD_mt_v1v0_o2(), Compare(), complex_n_interp(), CP98H2OAbsModel(), det(), diagonalize(), DiffZaAa(), ELL07WaterDropletAbs(), empty(), ext2trans(), flat(), get_dtauc_ssalb(), get_gasoptprop(), get_maximum_error(), get_paroptprop(), get_parZ(), get_variable_value(), GriddedFieldLatLonExpand(), Ho66_CO2_foreign_continuum(), Ho66_CO2_self_continuum(), id_mat(), interp_atmfield_by_itw(), interp_atmsurface_by_itw(), InterpGriddedField2ToPosition(), inv(), is_diagonal(), is_singular(), itw2p(), iy_transmission_mult(), iyActiveSingleScat(), iyActiveSingleScat2(), jac_ranges_indices(), MapToEigen(), MaTipping_H2O_foreign_continuum(), Matrix::Matrix(), matrix_exp(), matrix_exp_dmatrix_exp(), MatrixAddScalar(), MatrixMatrixMultiply(), MatrixScale(), mgd_with_derivatives(), MPM02H2OAbsModel(), MPM85O2AbsModel(), MPM87H2OAbsModel(), MPM87O2AbsModel(), MPM89H2OAbsModel(), MPM89O2AbsModel(), MPM92O2AbsModel(), MPM93_H2O_continuum(), MPM93_N2_continuum(), MPM93_O2_continuum(), MPM93H2OAbsModel(), MPM93IceCrystalAbs(), MPM93O2AbsModel(), MPM93RainExt(), MPM93WaterDropletAbs(), mult(), mult_general(), nca_def_Matrix(), nca_put_var_Matrix(), nca_write_to_file(), norm_inf(), MatrixView::operator*=(), MatrixView::operator+=(), MatrixView::operator-=(), MatrixView::operator/=(), operator<<(), Matrix::operator=(), opt_prop_1ScatElem(), opt_prop_ScatSpecBulk(), Pardo_ATM_H2O_ForeignContinuum(), Pardo_ATM_N2_dry_continuum(), pha_mat_labCalc(), pha_mat_ScatSpecBulk(), pha_matTransform(), PWR93O2AbsModel(), PWR98H2OAbsModel(), random_fill_matrix(), random_fill_matrix_pos_def(), random_submatrix(), Reduce(), regrid_atmsurf_by_gp_oem(), reshape(), Rosenkranz_CO2_foreign_continuum(), Rosenkranz_CO2_self_continuum(), Rosenkranz_N2_self_continuum(), Rosenkranz_O2_continuum(), run_oem_matlab(), Select(), select_dims_by_size(), sensor_losGeometricFromSensorPosToOtherPositions(), solve(), Standard_H2O_foreign_continuum(), Standard_H2O_self_continuum(), Standard_N2_self_continuum(), Standard_O2_continuum(), surfaceSplitSpecularTo3beams(), test30(), test47(), test_diagonal(), TRE05O2AbsModel(), VectorExtractFromMatrix(), VectorReshapeMatrix(), write_matrix(), xml_write_to_stream(), xsec_continuum_tag(), yApplySensorPol(), and yCalcAppend().
Index ConstMatrixView::nrows | ( | ) | const |
Returns the number of rows.
Definition at line 429 of file matpackI.cc.
References Range::mextent, and mrr.
Referenced by _cr_internal_(), abs_xsec_per_speciesAddCIA(), AddZaAa(), antenna2d_gridded_dlos(), antenna2d_interp_response(), Append(), atm_fields_compactFromMatrix(), BF86_CIA_N2(), calcSingleScatteringDataProperties(), GriddedField2::checksize(), GriddedField2::checksize_strict(), chk_met_mm_backend(), CKD24_H20(), CKD_222_foreign_h2o(), CKD_222_self_h2o(), CKD_241_co2(), CKD_242_foreign_h2o(), CKD_242_self_h2o(), CKD_mt_100_foreign_h2o(), CKD_mt_100_self_h2o(), CKD_mt_250_CIAfun_n2(), CKD_mt_250_CIArot_n2(), CKD_mt_250_co2(), CKD_mt_250_foreign_h2o(), CKD_mt_250_o2_vis(), CKD_mt_250_self_h2o(), CKD_mt_320_foreign_h2o(), CKD_mt_320_self_h2o(), CKD_mt_CIAfun_n2(), CKD_mt_CIAfun_o2(), CKD_mt_CIArot_n2(), CKD_mt_co2(), CKD_mt_v0v0_o2(), CKD_mt_v1v0_o2(), cloud_RT_no_background(), cloudbox_fieldSetConstPerFreq(), Compare(), complex_n_interp(), CP98H2OAbsModel(), det(), diagonalize(), DiffZaAa(), ELL07WaterDropletAbs(), empty(), ext2trans(), f_gridMetMM(), flat(), get_dtauc_ssalb(), get_gasoptprop(), get_maximum_error(), get_paroptprop(), get_variable_value(), GriddedFieldLatLonExpand(), Ho66_CO2_foreign_continuum(), Ho66_CO2_self_continuum(), id_mat(), InterpGriddedField2ToPosition(), inv(), is_diagonal(), is_singular(), itw2p(), iy_transmission_mult(), iyActiveSingleScat(), iyActiveSingleScat2(), jacobianSetAffineTransformation(), lubacksub(), ludcmp(), MapToEigen(), MaTipping_H2O_foreign_continuum(), Matrix::Matrix(), matrix_exp2(), MatrixAddScalar(), MatrixMatrixMultiply(), MatrixScale(), mgd_with_derivatives(), MPM02H2OAbsModel(), MPM85O2AbsModel(), MPM87H2OAbsModel(), MPM87O2AbsModel(), MPM89H2OAbsModel(), MPM89O2AbsModel(), MPM92O2AbsModel(), MPM93_H2O_continuum(), MPM93_N2_continuum(), MPM93_O2_continuum(), MPM93H2OAbsModel(), MPM93IceCrystalAbs(), MPM93O2AbsModel(), MPM93RainExt(), MPM93WaterDropletAbs(), mult(), mult_general(), nca_def_Matrix(), nca_put_var_Matrix(), nca_write_to_file(), norm_inf(), MatrixView::operator*=(), MatrixView::operator+=(), MatrixView::operator-=(), MatrixView::operator/=(), operator<<(), Matrix::operator=(), opt_prop_1ScatElem(), opt_prop_NScatElems(), opt_prop_ScatSpecBulk(), Pardo_ATM_H2O_ForeignContinuum(), Pardo_ATM_N2_dry_continuum(), pha_mat_1ScatElem(), pha_mat_NScatElems(), pha_mat_ScatSpecBulk(), PWR93O2AbsModel(), PWR98H2OAbsModel(), random_fill_matrix(), random_fill_matrix_pos_def(), random_submatrix(), Reduce(), regrid_atmsurf_by_gp_oem(), reshape(), Rosenkranz_CO2_foreign_continuum(), Rosenkranz_CO2_self_continuum(), Rosenkranz_N2_self_continuum(), Rosenkranz_O2_continuum(), run_oem_matlab(), Select(), select_dims_by_size(), sensor_losGeometricFromSensorPosToOtherPositions(), sensor_responseMetMM(), solve(), Standard_H2O_foreign_continuum(), Standard_H2O_self_continuum(), Standard_N2_self_continuum(), Standard_O2_continuum(), surfaceSemiSpecularBy3beams(), test30(), test47(), test_diagonal(), TRE05O2AbsModel(), VectorExtractFromMatrix(), VectorReshapeMatrix(), write_matrix(), xml_write_to_stream(), xsec_continuum_tag(), and xsec_species().
ConstMatrixView ConstMatrixView::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.
Definition at line 437 of file matpackI.cc.
ConstVectorView ConstMatrixView::operator() | ( | const Range & | r, |
Index | c | ||
) | const |
Const index operator returning a column as an object of type ConstVectorView.
r | A range of rows. |
c | Index of selected column |
Definition at line 447 of file matpackI.cc.
ConstVectorView ConstMatrixView::operator() | ( | Index | r, |
const Range & | c | ||
) | const |
Const index operator returning a row as an object of type ConstVectorView.
r | Index of selected row. |
c | Range of columns |
Definition at line 460 of file matpackI.cc.
Plain const index operator.
Definition at line 999 of file matpackI.h.
|
default |
|
default |
|
friend |
Definition at line 1037 of file matpackI.h.
|
friend |
Definition at line 1030 of file matpackI.h.
|
friend |
Definition at line 1032 of file matpackI.h.
|
friend |
Definition at line 1033 of file matpackI.h.
|
friend |
Definition at line 1034 of file matpackI.h.
|
friend |
Definition at line 1035 of file matpackI.h.
|
friend |
Definition at line 1036 of file matpackI.h.
|
friend |
Definition at line 1031 of file matpackI.h.
Referenced by begin(), diagonal(), and end().
|
friend |
Matrix Diagonalization.
Return P and W from A in the statement diag(P^-1*A*P)-W == 0. The real function will require some manipulation if the eigenvalues are imaginary.
The real version returns WR and WI as returned by dgeev. The complex version just returns W.
The function makes many copies and is thereby not fast. There are no tests on the condition of the returned matrix, so nan and inf can occur.
[out] | P | The right eigenvectors. |
[out] | WR | The real eigenvalues. |
[out] | WI | The imaginary eigenvalues. |
[in] | A | The matrix to diagonalize. |
Definition at line 245 of file lin_alg.cc.
|
friend |
Matrix Inverse.
Compute the inverse of a matrix such that I = Ainv*A = A*Ainv. Both MatrixViews must be square and have the same size n. During the inversion one additional n times n Matrix is allocated and work space memory for faster inversion is allocated and freed.
[out] | Ainv | The MatrixView to contain the inverse of A. |
[in] | A | The matrix to be inverted. |
Definition at line 167 of file lin_alg.cc.
|
friend |
LU backsubstitution.
Solves a set of linear equations Ax=b. It is neccessairy to do a L decomposition using the function ludcp before using this function. The backsubstitution is in-place, i.e. x and b may be the same vector.
x | Output: Solution vector of the equation system. |
LU | Input: LU decomposition of the matrix (output of function ludcp). |
b | Input: Right-hand-side vector of equation system. |
indx | Input: Pivoting information (output of function ludcp). |
Definition at line 91 of file lin_alg.cc.
|
friend |
LU decomposition.
This function performes a LU Decomposition of the matrix A. (Compare Numerical Recipies in C, pages 36-48.)
LU | Output: returns L and U in one matrix |
indx | Output: Vector that records the row permutation. |
A | Input: Matrix for which the LU decomposition is performed |
Definition at line 56 of file lin_alg.cc.
|
friend |
Definition at line 1652 of file matpackI.cc.
|
friend |
Definition at line 1683 of file matpackI.cc.
|
friend |
Definition at line 1720 of file matpackI.cc.
|
friend |
Definition at line 1712 of file matpackI.cc.
|
friend |
Definition at line 1029 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 1242 of file matpackI.cc.
|
friend |
Matrix - SparseMatrix multiplication.
Calculates the matrix product:
A = B*C, where C is sparse.
Output comes first!
Dimensions of A, B, and C must match. No memory reallocation takes place, only the data is copied.
A | Output: Result matrix (full). |
B | First matrix to multiply (sparse). |
C | Second matrix to multiply (full). |
Definition at line 539 of file matpackII.cc.
|
friend |
SparseMatrix - Matrix multiplication.
Calculates the matrix product:
A = B*C, where B is sparse.
Output comes first!
Dimensions of A, B, and C must match. No memory reallocation takes place, only the data is copied.
A | Output: Result matrix (full). |
B | First matrix to multiply (sparse). |
C | Second matrix to multiply (full). |
Definition at line 490 of file matpackII.cc.
|
friend |
Matrix-Vector Multiplication.
Computes the Matrix-Vector product y = M * x, for a m times n matrix M, a length-m vector y and a length-n vector x.
The product is computed using the dgemv_ routine from the BLAS library if the matrix is contiguous in memory. If this is not the case, the mult_general method is used to compute the product.
No memory is allocated for the computation and the matrix and vector views may not overlap.
[out] | y | The length-m VectorView where the result is stored. |
[in] | M | Reference to the m-times-n ConstMatrixView holding the matrix M. |
[in] | x | Reference to the length-n ConstVectorView holding the vector x. |
Definition at line 1123 of file matpackI.cc.
|
friend |
General matrix multiplication.
This is the fallback matrix multiplication which works for all ConstMatrixView objects.
[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 1346 of file matpackI.cc.
|
friend |
y = M*x. Note that the order is different from MTL, output comes first! Dimensions of y, M, and x must match. No memory reallocation takes place, only the data is copied. Using this function on overlapping Matrix and VectorViews belonging to the same Matrix will lead to unpredictable results.
The implementation here is different from the other multiplication routines. It does not use iterators but a more drastic approach to gain maximum performance.
Definition at line 1181 of file matpackI.cc.
Definition at line 90 of file poly_roots.cc.
|
friend |
Const version of transpose.
Definition at line 1444 of file matpackI.cc.
|
protected |
The column range of mdata that is actually used.
Definition at line 1079 of file matpackI.h.
Referenced by MatrixView::begin(), begin(), diagonal(), diagonalize(), MatrixView::end(), end(), MatrixView::get_c_array(), lubacksub(), MapToEigen(), MapToEigen4x4(), mult(), ncols(), ConstIterator3D::operator!=(), Iterator3D::operator!=(), MatrixView::operator=(), swap(), and transpose().
|
protected |
Pointer to the plain C array that holds the data.
Definition at line 1081 of file matpackI.h.
Referenced by MatrixView::begin(), begin(), diagonal(), diagonalize(), MatrixView::end(), end(), MatrixView::get_c_array(), Matrix::get_raw_data(), inv(), lubacksub(), ludcmp(), MapToEigen(), MapToEigen4x4(), Matrix::Matrix(), mult(), ConstIterator3D::operator!=(), Iterator3D::operator!=(), Iterator3D::operator++(), ConstIterator3D::operator++(), Matrix::operator=(), swap(), transpose(), and Matrix::~Matrix().
|
protected |
The row range of mdata that is actually used.
Definition at line 1077 of file matpackI.h.
Referenced by MatrixView::begin(), begin(), diagonal(), MatrixView::end(), end(), MatrixView::get_c_array(), MapToEigen(), MapToEigen4x4(), mult(), nrows(), ConstIterator3D::operator!=(), Iterator3D::operator!=(), MatrixView::operator=(), swap(), and transpose().