ARTS
2.4.0(git:4fb77825)
|
Implementation of sparse matrices. More...
#include "matpackII.h"
#include <Eigen/Core>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
Go to the source code of this file.
Functions | |
std::ostream & | operator<< (std::ostream &os, const Sparse &M) |
Output operator for Sparse. More... | |
void | abs (Sparse &A, const Sparse &B) |
Absolute value of sparse matrix elements. More... | |
void | mult (VectorView y, const Sparse &M, ConstVectorView x) |
Sparse matrix - Vector multiplication. More... | |
void | transpose_mult (VectorView y, const Sparse &M, ConstVectorView x) |
Sparse matrix - Vector multiplication. More... | |
void | mult (MatrixView A, const Sparse &B, const ConstMatrixView &C) |
SparseMatrix - Matrix multiplication. More... | |
void | mult (MatrixView A, const ConstMatrixView &B, const Sparse &C) |
Matrix - SparseMatrix multiplication. More... | |
void | transpose (Sparse &A, const Sparse &B) |
Transpose of sparse matrix. More... | |
void | mult (Sparse &A, const Sparse &B, const Sparse &C) |
Sparse - Sparse multiplication. More... | |
void | add (Sparse &A, const Sparse &B, const Sparse &C) |
Sparse - Sparse addition. More... | |
void | id_mat (Sparse &A) |
Sparse identity matrix. More... | |
void | sub (Sparse &A, const Sparse &B, const Sparse &C) |
Sparse - Sparse subtraction. More... | |
Implementation of sparse matrices.
Notes:
There are two different ways to index: S.rw(3,4) = 1; // Read and write cout << S.ro(3,4); // Read only
This distinction is necessary, because rw() creates elements if they don't already exist.
The normal index operator "()" correspondes to ro, so "S(3,4)" is the same as S.ro(3,4).
Definition in file matpackII.cc.
Absolute value of sparse matrix elements.
Computes the absolute values of the elements in sparse matrix B.
The output matrix A must have been initialized with the correct size.
A | Output: Absolute value matrix. |
B | Original matrix. |
Definition at line 394 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), and Sparse::nrows().
Calculates A = B+C, where result A is sparse, and B and C are also sparse.
Output comes first!
Dimensions of B, and C must match. A will be resized.
A | Output: Result matrix. |
B | First summand matrix. |
C | Second summand matrix. |
Definition at line 630 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), Sparse::nrows(), and Sparse::resize().
Referenced by test49(), and test_sparse_arithmetic().
void id_mat | ( | Sparse & | A | ) |
Sparse identity matrix.
Set the given Sparse matrix object to the identity matrix. The matrix must be square.
A | The matrix to be set to the identity matrix. |
Definition at line 647 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), and Sparse::nrows().
void mult | ( | MatrixView | A, |
const ConstMatrixView & | B, | ||
const Sparse & | C | ||
) |
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.
References ConstMatrixView::ncols(), Sparse::ncols(), ConstMatrixView::nrows(), and Sparse::nrows().
void mult | ( | MatrixView | A, |
const Sparse & | B, | ||
const ConstMatrixView & | C | ||
) |
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.
References data, Range::get_start(), Range::get_stride(), Sparse::matrix, ConstMatrixView::mcr, ConstMatrixView::mdata, ConstMatrixView::mrr, ConstMatrixView::ncols(), Sparse::ncols(), ConstMatrixView::nrows(), and Sparse::nrows().
Sparse - Sparse multiplication.
Calculates A = B*C, where result A is sparse, and B and C are also 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. |
B | First product matrix. |
C | Second product matrix. |
Definition at line 606 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), and Sparse::nrows().
void mult | ( | VectorView | y, |
const Sparse & | M, | ||
ConstVectorView | x | ||
) |
Sparse matrix - Vector multiplication.
This calculates the product
y = M*x, where M is sparse.
Output comes first!
Dimensions of y, M, and x must match. No memory reallocation takes place, only the data is copied.
y | Output: The multiplication result. |
M | Matrix for multiplication (sparse). |
x | Vector for multiplication. |
Definition at line 417 of file matpackII.cc.
References data, M, ARTS::Var::x(), and ARTS::Var::y().
std::ostream& operator<< | ( | std::ostream & | os, |
const Sparse & | M | ||
) |
Output operator for Sparse.
os | Output stream. |
v | Sparse matrix to print. |
Definition at line 375 of file matpackII.cc.
References M.
Calculates A = B-C, where result A is sparse, and B and C are also sparse.
Output comes first!
Dimensions of B, and C must match. A will be resized.
A | Output: Result matrix. |
B | First subtrahend matrix. |
C | Second subtrahend matrix. |
Definition at line 667 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), Sparse::nrows(), and Sparse::resize().
Referenced by sensor_responseBackendFrequencySwitching(), test49(), and test_sparse_arithmetic().
Transpose of sparse matrix.
Computes the transpose of the sparse matrix B.
The output matrix A must have been initialized with the correct size.
A | Output: Transposed matrix. |
B | Original matrix. |
Definition at line 582 of file matpackII.cc.
References Sparse::matrix, Sparse::ncols(), and Sparse::nrows().
void transpose_mult | ( | VectorView | y, |
const Sparse & | M, | ||
ConstVectorView | x | ||
) |
Sparse matrix - Vector multiplication.
This calculates the product
y = M*x, where M is sparse.
Output comes first!
Dimensions of y, M, and x must match. No memory reallocation takes place, only the data is copied.
y | Output: The multiplication result. |
M | Matrix for multiplication (sparse). |
x | Vector for multiplication. |
Definition at line 452 of file matpackII.cc.
References data, M, ARTS::Var::x(), and ARTS::Var::y().
Referenced by mult().