94 return matrix.coeffRef((
int)r, (
int)
c);
108 return matrix.coeff((
int)r, (
int)
c);
133 return matrix.coeff((
int)r, (
int)
c);
160 for (
Index i = 0; i < n; ++i) {
172 for (
int i = 0; i < m; i++) {
173 diag[i] =
matrix.coeff(i, i);
192 for (
int i = 0; i < m; i++) {
193 Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(matrix, i);
195 A(it.row(), it.col()) = it.value();
276 row_indices.resize(
nnz());
277 column_indices.resize(
nnz());
280 for (
int i = 0; i < m; i++) {
281 Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(
matrix, i);
283 values[j] = it.value();
284 row_indices[j] = it.row();
285 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());
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;
434 y_map =
M.matrix * x_map;
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;
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);
510 MatrixMap C_map(data, C.
nrows(), C.
ncols(), c_stride);
515 Stride a_stride(row_stride, column_stride);
516 MatrixMap A_map(data, A.
nrows(), A.
ncols(), a_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;
552 Index row_stride, column_stride;
558 Stride b_stride(row_stride, column_stride);
559 MatrixMap B_map(data, B.
nrows(), B.
ncols(), b_stride);
564 Stride a_stride(row_stride, column_stride);
565 MatrixMap A_map(data, A.
nrows(), A.
ncols(), a_stride);
A constant view of a Matrix.
Range mrr
The row range of mdata that is actually used.
Index nrows() const noexcept
Index ncols() const noexcept
Numeric * mdata
Pointer to the plain C array that holds the data.
Range mcr
The column range of mdata that is actually used.
A constant view of a Vector.
Numeric * mdata
Pointer to the plain C array that holds the data.
Range mrange
The range of mdata that is actually used.
Index nelem() const noexcept
Returns the number of elements.
constexpr Index get_start() const noexcept
Returns the start index of the range.
constexpr Index get_stride() const noexcept
Returns the stride of the range.
void resize(Index n)
Resize function.
#define ARTS_ASSERT(condition,...)
void id_mat(Sparse &A)
Sparse identity matrix.
std::ostream & operator<<(std::ostream &os, const Sparse &M)
Output operator for Sparse.
void transpose(Sparse &A, const Sparse &B)
Transpose of sparse matrix.
void abs(Sparse &A, const Sparse &B)
Absolute value of sparse matrix elements.
void transpose_mult(VectorView y, const Sparse &M, ConstVectorView x)
Sparse matrix - Vector multiplication.
void sub(Sparse &A, const Sparse &B, const Sparse &C)
Sparse - Sparse subtraction.
void mult(VectorView y, const Sparse &M, ConstVectorView x)
Sparse matrix - Vector multiplication.
void add(Sparse &A, const Sparse &B, const Sparse &C)
Sparse - Sparse addition.
Header file for sparse matrices.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
Numeric operator()(Index r, Index c) const
Plain index operator.
Eigen::SparseMatrix< Numeric, Eigen::RowMajor > matrix
The actual matrix.
Index nnz() const
Returns the number of nonzero elements.
int * get_row_start_pointer()
Sparse()
Default constructor.
void split(Index offset, Index nrows)
Reduce matrix to the row range [offset, offset + nrows].
Numeric * get_element_pointer()
Numeric & rw(Index r, Index c)
Read and write index operator.
void resize(Index r, Index c)
Resize function.
void list_elements(Vector &values, ArrayOfIndex &row_indices, ArrayOfIndex &column_indices) const
List elements in matrix.
void insert_row(Index r, Vector v)
Insert row function.
int * get_column_index_pointer()
Index nrows() const
Returns the number of rows.
Vector diagonal() const
Diagonal elements as vector.
Numeric ro(Index r, Index c) const
Read only index operator.
Sparse & operator/=(Numeric x)
Scale matrix by reciprocal.
Index ncols() const
Returns the number of columns.
bool empty() const
Returns true if variable size is zero.
Sparse & operator*=(Numeric x)
Scale matrix.
Sparse & operator-=(const Sparse &x)
Subtract sparse matrix.
Sparse & operator+=(const Sparse &x)
Add sparse matrix.
void insert_elements(Index nnz, const ArrayOfIndex &rowind, const ArrayOfIndex &colind, ConstVectorView data)
Insert vector of elements with given row and column indices.