linbox
|
Class of matrix arithmetic functions. More...
#include <matrix-domain.h>
Public Types | |
typedef Vector< Field >::Dense | Rep_ |
Public Member Functions | |
MatrixDomain (const Field &F) | |
Constructor. More... | |
MatrixDomain & | operator= (const MatrixDomain &MD) |
Copy operator. | |
template<class Matrix_ > | |
std::ostream & | write (std::ostream &os, const Matrix_ &A) const |
Print matrix. More... | |
template<class Matrix_ > | |
std::istream & | read (std::istream &is, Matrix_ &A) const |
Read matrix. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | copy (Matrix1 &B, const Matrix2 &A) const |
Matrix copy B <- A. More... | |
Matrix & | copy (Matrix &B, const Matrix &A) const |
B <– A. They must already have the same shape. | |
Matrix & | swap (Matrix &B, Matrix &A) const |
Matrix swap B <–> A. More... | |
template<class Matrix1 , class Matrix2 > | |
bool | areEqual (const Matrix1 &A, const Matrix2 &B) const |
Matrix equality. More... | |
template<class Matrix_ > | |
bool | isZero (const Matrix_ &A) const |
Matrix equality with zero. More... | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | add (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const |
Matrix-matrix addition C <- A + B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | addin (Matrix1 &A, const Matrix2 &B) const |
Matrix-matrix in-place addition A <- A + B. More... | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | sub (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const |
Matrix-matrix subtraction C <- A - B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | subin (Matrix1 &A, const Matrix2 &B) const |
Matrix-matrix in-place subtraction A <- A - B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | neg (Matrix1 &B, const Matrix2 &A) const |
Matrix negate B <- -A. More... | |
template<class Matrix_ > | |
Matrix_ & | negin (Matrix_ &A) const |
Matrix in-place negate A <- -A. More... | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | mul (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const |
Matrix-matrix multiply C <- A * B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix2 & | leftMulin (const Matrix1 &A, Matrix2 &B) const |
Matrix-matrix in-place multiply on the left B <- A * B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | rightMulin (Matrix1 &A, const Matrix2 &B) const |
Matrix-matrix in-place multiply on the right A <- A * B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | mulin (Matrix1 &A, const Matrix2 &B) const |
Matrix-matrix in-place multiply A <- A * B. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | mul (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a) const |
Matrix-scalar multiply C <- B * a. More... | |
template<class Matrix_ > | |
Matrix_ & | mulin (Matrix_ &B, const typename Field::Element &a) const |
Matrix-scalar in-place multiply B <- B * a. More... | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | axpyin (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const |
Matrix-matrix in-place axpy Y <- Y + A*X. More... | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | axmyin (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const |
Y <- AX-Y. | |
template<class Matrix1 , class Matrix2 , class Matrix3 > | |
Matrix1 & | muladd (Matrix1 &D, const typename Field::Element &beta, const Matrix1 &C, const typename Field::Element &alpha, const Matrix2 &A, const Matrix3 &B) const |
General matrix multiply . More... | |
const Field & | field () const |
Retrieve the underlying field. More... | |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | pow_apply (Matrix1 &M1, const Matrix2 &M2, unsigned long int k) const |
template<class Matrix1 , class Matrix2 > | |
Matrix1 & | pow_horn (Matrix1 &M1, const Matrix2 &M2, unsigned long int k) const |
Matrix-vector arithmetic operations | |
These operations take a matrix satisfying the DenseMatrix archetype and LinBox vectors as inputs. They involve matrix-vector product and matrix-vector AXPY | |
template<class Vector1 , class Matrix_ , class Vector2 > | |
Vector1 & | vectorMul (Vector1 &w, const Matrix_ &A, const Vector2 &v) const |
Matrix-vector multiply w <- A * v. More... | |
template<class Vector1 , class Matrix_ , class Vector2 > | |
Vector1 & | vectorAxpyin (Vector1 &y, const Matrix_ &A, const Vector2 &x) const |
Matrix-vector in-place axpy . More... | |
Matrix-black box arithmetic operations | |
These operations mimic the matrix-matrix arithmetic operations above, but one of the parameters is a BlackboxArchetype. | |
template<class Matrix1 , class Blackbox , class Matrix2 > | |
Matrix1 & | blackboxMulLeft (Matrix1 &C, const Blackbox &A, const Matrix2 &B) const |
Matrix-black box left-multiply C <- A * B. More... | |
template<class Matrix1 , class Matrix2 , class Blackbox > | |
Matrix1 & | blackboxMulRight (Matrix1 &C, const Matrix2 &A, const Blackbox &B) const |
Matrix-black box right-multiply C <- A * B. More... | |
Matrix permutations | |
These operations permute the rows or columns of a matrix based on the given permutation. They are intended for use with Gauss-Jordan elimination | |
typedef std::pair< unsigned int, unsigned int > | Transposition |
Transposition. | |
typedef std::vector< Transposition > | Permutation |
Permutation. More... | |
template<class Matrix_ , class Iterator > | |
Matrix_ & | permuteRows (Matrix_ &A, Iterator P_start, Iterator P_end) const |
Permute the rows of the given matrix. More... | |
template<class Matrix_ , class Iterator > | |
Matrix_ & | permuteColumns (Matrix_ &A, Iterator P_start, Iterator P_end) const |
Permute the columns of the given matrix. More... | |
Class of matrix arithmetic functions.
This class encapuslated matrix-matrix and matrix-vector operations, roughly equivalent to BLAS levels 2 and 3. The arithmetic methods are parameterized by matrix type so that they may be used the same way with sparse matrices, dense matrices, and dense submatrices. Except where otherwise noted, they require the matrix inputs to meet the BlasMatrix archetype.
These methods are specialized so that they can run efficiently with different matrix representations. If a matrix has an efficient row iterator, but not an efficient column iterator, a specialization that makes use of the former will be selected. This allows a great deal of flexibility when dealing with sparse matrix arithmetic.
For all of the arithmetic operations that output matrices, it is assumed that the output matrix has an efficient row iterator. In typical use, the output matrix will be a BlasMatrix or a BlasSubmatrix, which has efficient row and column iterators. In particular, one should not perform these arithmetic operations outputting to a SparseMatrixBase.
There are other restrictions. See the method-specific documentation for more details.
typedef std::vector<Transposition> Permutation |
Permutation.
A permutation is represented as a vector of pairs, each pair representing a transposition.
|
inline |
Constructor.
F | field for MatrixDomain operations. |
|
inline |
Retrieve the underlying field.
Return a reference to the field that this matrix domain object uses
|
inline |
Print matrix.
os | Output stream to which matrix is written. |
A | Matrix. |
|
inline |
Read matrix.
is | Input stream from which matrix is read. |
A | Matrix. |
|
inline |
Matrix copy B <- A.
Copy the contents of the matrix B to the matrix A
Both matrices must support the same iterators, row or column.
B | Matrix B |
A | Matrix A |
Matrix swap B <–> A.
They must already have the same shape.
|
inline |
Matrix equality.
Test whether the matrices A and B are equal
A | Input vector |
B | Input vector |
|
inline |
Matrix equality with zero.
A | Input matrix |
|
inline |
Matrix-matrix addition C <- A + B.
Each of A, B, and C must support the same iterator, either row or column
C | Output matrix C |
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix in-place addition A <- A + B.
Each of A and B must support the same iterator, either row or column
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix subtraction C <- A - B.
Each of A, B, and C must support the same iterator, either row or column
C | Output matrix C |
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix in-place subtraction A <- A - B.
Each of A and B must support the same iterator, either row or column
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix negate B <- -A.
Each of A and B must support the same iterator, either row or column
B | Output matrix B |
A | Input matrix A |
|
inline |
Matrix in-place negate A <- -A.
A | Input matrix A; result is stored here |
|
inline |
Matrix-matrix multiply C <- A * B.
C must support both row and column iterators, and the vector representations must be dense. Examples of supported matrices are BlasMatrix and BlasSubmatrix.
Either A or B, or both, may have limited iterators. However, either A must support row iterators or B must support column iterators. If both A and B lack support for an iterator (either row or column), then C must support the same type of iterator as A and B.
C | Output matrix C |
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix in-place multiply on the left B <- A * B.
B should support both row and column iterators, and must be dense. A must support row iterators.
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix in-place multiply on the right A <- A * B.
A should support both row and column iterators, and must be dense. B must support column iterators.
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-matrix in-place multiply A <- A * B.
This is an alias for rightMulin
A | Input matrix A |
B | Input matrix B |
|
inline |
Matrix-scalar multiply C <- B * a.
Multiply B by the scalar element a and store the result in C. B and C must support the same iterators.
C | Output matrix C |
B | Input matrix B |
a | Input scalar a |
|
inline |
Matrix-scalar in-place multiply B <- B * a.
Multiply B by the scalar element a in-place.
B | Input matrix B |
a | Input scalar a |
|
inline |
Matrix-matrix in-place axpy Y <- Y + A*X.
This function combines mul and add, eliminating the need for an additional temporary in expressions of the form $Y = Y + AX$. Only one row of additional storage is required. Y may have either efficient row iterators or efficient column iterators, and the same restrictions on A and X apply as in mul.
Note that no out-of-place axpy is provided, since it gives no benefit. One may just as easily multiply into the result and call addin.
Y | Input matrix Y; result is stored here |
A | Input matrix A |
X | Input matrix X |
|
inline |
General matrix multiply .
Matrix1& pow_apply | ( | Matrix1 & | M1, |
const Matrix2 & | M2, | ||
unsigned long int | k | ||
) | const |
Matrix1& pow_horn | ( | Matrix1 & | M1, |
const Matrix2 & | M2, | ||
unsigned long int | k | ||
) | const |
|
inline |
Matrix-vector multiply w <- A * v.
The vectors v and w must be of the same representation (dense, sparse sequence, sparse associative, or sparse parallel), but they may be of different types. The matrix A may have any representation.
w | Output vector w |
A | Input matrix A |
v | Input vector v |
|
inline |
Matrix-vector in-place axpy .
This function eliminates the requirement for temporary storage when one is computing an expression of the form given above.
The vectors y and x must be of the same representation (dense, sparse sequence, sparse associative, or sparse parallel), but they may be of different types. The matrix A may have any representation.
Note that out-of-place axpy is not provided since it provides no benefit – one can use mul and then addin to exactly the same effect, with no additional storage or performance cost.
y | Input vector y; result is stored here |
A | Input matrix A |
x | Input vector x |
|
inline |
Matrix-black box left-multiply C <- A * B.
Both C and B must support column iterators
C | Output matrix |
A | Black box for A |
B | Matrix B |
|
inline |
Matrix-black box right-multiply C <- A * B.
Both C and A must support row iterators
C | Output matrix |
A | Matrix A |
B | Black box for B |
|
inline |
Permute the rows of the given matrix.
A | Output matrix |
P_start | Start of permutation |
P_end | End of permutation |
|
inline |
Permute the columns of the given matrix.
A | Output matrix |
P_start | Start of permutation |
P_end | End of permutation |