Go to the documentation of this file.
98 return matrix.coeffRef((
int)r, (
int)c);
112 return matrix.coeff((
int)r, (
int)c);
164 for (
Index i = 0; i < n; ++i) {
176 for (
int i = 0; i < m; i++) {
177 diag[i] =
matrix.coeff(i, i);
196 for (
int i = 0; i < m; i++) {
197 Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(matrix, i);
199 A(it.row(), it.col()) = it.value();
280 row_indices.resize(
nnz());
281 column_indices.resize(
nnz());
284 for (
int i = 0; i < m; i++) {
285 Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(
matrix, i);
287 values[j] = it.value();
288 row_indices[j] = it.row();
289 column_indices[j] = it.col();
297 Eigen::SparseMatrix<Numeric, Eigen::RowMajor> block_copy(
298 matrix.block((
int)offset, 0, (
int)nrows_block, (
int)
ncols()));
320 for (
int i = 0; i <
ncols(); i++) {
321 if (v[i] != 0)
matrix.coeffRef((
int)r, i) = v[i];
341 typedef Eigen::Triplet<Numeric> T;
342 std::vector<T> tripletList(nelems);
344 for (
Index i = 0; i < nelems; i++) {
345 tripletList[i] = T((
int)rowind[i], (
int)colind[i],
data[i]);
348 matrix.setFromTriplets(tripletList.begin(), tripletList.end());
365 matrix.resize((
int)r, (
int)c);
419 assert(
y.nelem() ==
M.nrows());
420 assert(
M.ncols() ==
x.nelem());
423 typedef Eigen::Matrix<Numeric, Eigen::Dynamic, 1, Eigen::ColMajor>
425 typedef Eigen::Stride<1, Eigen::Dynamic> Stride;
426 typedef Eigen::Map<EigenColumnVector, 0, Stride> ColumnMap;
429 data =
x.mdata +
x.mrange.get_start();
430 ColumnMap x_map(
data,
x.nelem(), Stride(1,
x.mrange.get_stride()));
431 data =
y.mdata +
y.mrange.get_start();
432 ColumnMap y_map(
data,
y.nelem(), Stride(1,
y.mrange.get_stride()));
434 y_map =
M.matrix * x_map;
454 assert(
y.nelem() ==
M.ncols());
455 assert(
M.nrows() ==
x.nelem());
458 typedef Eigen::Matrix<Numeric, 1, Eigen::Dynamic, Eigen::RowMajor>
460 typedef Eigen::Stride<1, Eigen::Dynamic> Stride;
461 typedef Eigen::Map<EigenColumnVector, 0, Stride> ColumnMap;
464 data =
x.mdata +
x.mrange.get_start();
465 ColumnMap x_map(
data,
x.nelem(), Stride(1,
x.mrange.get_stride()));
466 data =
y.mdata +
y.mrange.get_start();
467 ColumnMap y_map(
data,
y.nelem(), Stride(1,
y.mrange.get_stride()));
469 y_map = x_map *
M.matrix;
498 Matrix<Numeric, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
500 typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Stride;
501 typedef Eigen::Map<EigenMatrix, 0, Stride> MatrixMap;
503 Index row_stride, column_stride;
509 Stride c_stride(row_stride, column_stride);
515 Stride a_stride(row_stride, column_stride);
547 Matrix<Numeric, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
549 typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Stride;
550 typedef Eigen::Map<EigenMatrix, 0, Stride> MatrixMap;
558 Stride b_stride(row_stride, column_stride);
564 Stride a_stride(row_stride, column_stride);
Sparse & operator-=(const Sparse &x)
Subtract sparse matrix.
Index ncols() const
Returns the number of columns.
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Numeric * mdata
Pointer to the plain C array that holds the data.
Vector y(Workspace &ws) noexcept
void resize(Index n)
Resize function.
void id_mat(Sparse &A)
Sparse identity matrix.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Sparse()
Default constructor.
Index nrows() const
Returns the number of rows.
Numeric ro(Index r, Index c) const
Read only index operator.
void mult(VectorView y, const Sparse &M, ConstVectorView x)
Sparse matrix - Vector multiplication.
void list_elements(Vector &values, ArrayOfIndex &row_indices, ArrayOfIndex &column_indices) const
List elements in matrix.
Range mcr
The column range of mdata that is actually used.
void insert_row(Index r, Vector v)
Insert row function.
Range mrr
The row range of mdata that is actually used.
constexpr Index get_start() const
Returns the start index of the range.
void insert_elements(Index nnz, const ArrayOfIndex &rowind, const ArrayOfIndex &colind, ConstVectorView data)
Insert vector of elements with given row and column indices.
bool empty() const
Returns true if variable size is zero.
Index nnz() const
Returns the number of nonzero elements.
Index ncols() const
Returns the number of columns.
Sparse & operator*=(Numeric x)
Scale matrix.
void transpose(Sparse &A, const Sparse &B)
Transpose of sparse matrix.
Numeric operator()(Index r, Index c) const
Plain index operator.
void sub(Sparse &A, const Sparse &B, const Sparse &C)
Sparse - Sparse subtraction.
Index nelem() const
Returns the number of elements.
NUMERIC Numeric
The type to use for all floating point numbers.
A constant view of a Matrix.
Vector diagonal() const
Diagonal elements as vector.
Index nrows(Workspace &ws) noexcept
void resize(Index r, Index c)
Resize function.
constexpr Index get_stride() const
Returns the stride of the range.
Sparse & operator/=(Numeric x)
Scale matrix by reciprocal.
void split(Index offset, Index nrows)
Reduce matrix to the row range [offset, offset + nrows].
void transpose_mult(VectorView y, const Sparse &M, ConstVectorView x)
Sparse matrix - Vector multiplication.
Index nrows() const
Returns the number of rows.
void abs(Sparse &A, const Sparse &B)
Absolute value of sparse matrix elements.
Numeric & rw(Index r, Index c)
Read and write index operator.
Eigen::SparseMatrix< Numeric, Eigen::RowMajor > matrix
The actual matrix.
Header file for sparse matrices.
Sparse & operator+=(const Sparse &x)
Add sparse matrix.
Vector x(Workspace &ws) noexcept
INDEX Index
The type to use for all integer numbers and indices.
Index ncols(Workspace &ws) noexcept
A constant view of a Vector.
std::ostream & operator<<(std::ostream &os, const Sparse &M)
Output operator for Sparse.
void add(Sparse &A, const Sparse &B, const Sparse &C)
Sparse - Sparse addition.