Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MatrixDomain Class Template Reference

#include <matrix-domain.h>

Inheritance diagram for MatrixDomain:

MVProductDomain List of all members.

Detailed Description

template<class Field>
class LinBox::MatrixDomain< Field >

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 DenseMatrix 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 DenseMatrixBase or a DenseSubmatrix, 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.


Public Types

typedef std::pair< unsigned
int, unsigned int > 
Transposition
typedef std::vector< TranspositionPermutation

Public Methods

 MatrixDomain (const Field &F)
const Fieldfield () const
template<class Matrix> std::ostream & write (std::ostream &os, const Matrix &A) const
template<class Matrix> std::istream & read (std::istream &is, Matrix &A) const
template<class Matrix1, class Matrix2> Matrix1 & copy (Matrix1 &B, const Matrix2 &A) const
template<class Matrix1, class Matrix2> bool areEqual (const Matrix1 &A, const Matrix2 &B) const
template<class Matrix> bool isZero (const Matrix &A) const
template<class Matrix1, class Matrix2, class Matrix3> Matrix1 & add (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
template<class Matrix1, class Matrix2> Matrix1 & addin (Matrix1 &A, const Matrix2 &B) const
template<class Matrix1, class Matrix2, class Matrix3> Matrix1 & sub (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
template<class Matrix1, class Matrix2> Matrix1 & subin (Matrix1 &A, const Matrix2 &B) const
template<class Matrix1, class Matrix2> Matrix1 & neg (Matrix1 &B, const Matrix2 &A) const
template<class Matrix> Matrix & negin (Matrix &A) const
template<class Matrix1, class Matrix2, class Matrix3> Matrix1 & mul (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
template<class Matrix1, class Matrix2> Matrix2 & leftMulin (const Matrix1 &A, Matrix2 &B) const
template<class Matrix1, class Matrix2> Matrix1 & rightMulin (Matrix1 &A, const Matrix2 &B) const
template<class Matrix1, class Matrix2> Matrix1 & mulin (Matrix1 &A, const Matrix2 &B) const
template<class Matrix1, class Matrix2> Matrix1 & mul (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a) const
template<class Matrix> Matrix & mulin (Matrix &B, const typename Field::Element &a) const
template<class Matrix1, class Matrix2, class Matrix3> Matrix1 & axpyin (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const
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
template<class Vector1, class Matrix, class Vector2> Vector1 & vectorMul (Vector1 &w, const Matrix &A, const Vector2 &v) const
template<class Vector1, class Matrix, class Vector2> Vector1 & vectorAxpyin (Vector1 &y, const Matrix &A, const Vector2 &x) const
template<class Matrix1, class Blackbox, class Matrix2> Matrix1 & blackboxMulLeft (Matrix1 &C, const Blackbox &A, const Matrix2 &B) const
template<class Matrix1, class Matrix2, class Blackbox> Matrix1 & blackboxMulRight (Matrix1 &C, const Matrix2 &A, const Blackbox &B) const
template<class Matrix, class Iterator> Matrix & permuteRows (Matrix &A, Iterator P_start, Iterator P_end) const
template<class Matrix, class Iterator> Matrix & permuteColumns (Matrix &A, Iterator P_start, Iterator P_end) const


Member Typedef Documentation

typedef std::vector<Transposition> Permutation
 

typedef std::pair<unsigned int, unsigned int> Transposition
 

Permutation

A permutation is represented as a vector of pairs, each pair representing a transposition.


Constructor & Destructor Documentation

MatrixDomain const Field   F [inline]
 


Member Function Documentation

Matrix1 & add Matrix1 &    M1,
const Matrix2 &    M2,
const Matrix3 &    M3
const [inline]
 

Matrix-matrix addition C <- A + B

Each of A, B, and C must support the same iterator, either row or column

Parameters:
C  Output matrix C
A  Input matrix A
B  Input matrix B
Returns:
Reference to C

Matrix1 & addin Matrix1 &    M1,
const Matrix2 &    M2
const [inline]
 

Matrix-matrix in-place addition A <- A + B

Each of A and B must support the same iterator, either row or column

Parameters:
A  Input matrix A
B  Input matrix B
Returns:
Reference to A

bool areEqual const Matrix1 &    M1,
const Matrix2 &    M2
const [inline]
 

Matrix equality Test whether the matrices A and B are equal

Parameters:
A  Input vector
B  Input vector
Returns:
true if and only if the matrices A and B are equal

Matrix1& axpyin Matrix1 &    Y,
const Matrix2 &    A,
const Matrix3 &    X
const [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.

Parameters:
Y  Input matrix Y; result is stored here
A  Input matrix A
X  Input matrix X

Matrix1 & blackboxMulLeft Matrix1 &    C,
const Blackbox   A,
const Matrix2 &    B
const [inline]
 

Matrix-black box left-multiply C <- A * B

Both C and B must support column iterators

Parameters:
C  Output matrix
A  Black box for A
B  Matrix B

Matrix1 & blackboxMulRight Matrix1 &    C,
const Matrix2 &    A,
const Blackbox   B
const [inline]
 

Matrix-black box right-multiply C <- A * B

Both C and A must support row iterators

Parameters:
C  Output matrix
A  Matrix A
B  Black box for B

Matrix1& copy Matrix1 &    B,
const Matrix2 &    A
const [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.

Parameters:
B  Matrix B
A  Matrix A
Returns:
Reference to B

const Field& field   const [inline]
 

Retrieve the underlying field Return a reference to the field that this matrix domain object uses

Returns:
reference to field

bool isZero const Matrix &    A const [inline]
 

Matrix equality with zero

Parameters:
A  Input matrix
Returns:
true if and only if the matrix A is zero

Matrix2 & leftMulin const Matrix1 &    A,
Matrix2 &    B
const [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.

Parameters:
A  Input matrix A
B  Input matrix B
Returns:
Reference to B

Matrix1& mul Matrix1 &    C,
const Matrix2 &    B,
const typename Field::Element   a
const [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.

Parameters:
C  Output matrix C
B  Input matrix B
a  Input scalar a
Returns:
Reference to C

Matrix1 & mul Matrix1 &    M1,
const Matrix2 &    M2,
const Matrix3 &    M3
const [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 DenseMatrixBase and DenseSubmatrix.

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.

Parameters:
C  Output matrix C
A  Input matrix A
B  Input matrix B
Returns:
Reference to C

Matrix& mulin Matrix &    B,
const typename Field::Element   a
const [inline]
 

Matrix-scalar in-place multiply B <- B * a

Multiply B by the scalar element a in-place.

Parameters:
B  Input matrix B
a  Input scalar a
Returns:
Reference to B

Matrix1& mulin Matrix1 &    A,
const Matrix2 &    B
const [inline]
 

Matrix-matrix in-place multiply A <- A * B

This is an alias for rightMulin

Parameters:
A  Input matrix A
B  Input matrix B
Returns:
Reference to A

Matrix1& neg Matrix1 &    B,
const Matrix2 &    A
const [inline]
 

Matrix negate B <- -A

Each of A and B must support the same iterator, either row or column

Parameters:
B  Output matrix B
A  Input matrix A
Returns:
reference to B

Matrix& negin Matrix &    A const [inline]
 

Matrix in-place negate A <- -A

Parameters:
A  Input matrix A; result is stored here

Matrix& permuteColumns Matrix &    A,
Iterator    P_start,
Iterator    P_end
const [inline]
 

Permute the columns of the given matrix

Parameters:
A  Output matrix
P_start  Start of permutation
P_end  End of permutation
Returns:
Reference to A

Matrix& permuteRows Matrix &    A,
Iterator    P_start,
Iterator    P_end
const [inline]
 

Permute the rows of the given matrix

Parameters:
A  Output matrix
P_start  Start of permutation
P_end  End of permutation
Returns:
Reference to A

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
 

std::istream& read std::istream &    is,
Matrix &    A
const [inline]
 

Read matrix

Parameters:
is  Input stream from which matrix is read.
A  Matrix.
Returns:
reference to is.

Matrix1 & rightMulin Matrix1 &    A,
const Matrix2 &    B
const [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.

Parameters:
A  Input matrix A
B  Input matrix B
Returns:
Reference to A

Matrix1 & sub Matrix1 &    M1,
const Matrix2 &    M2,
const Matrix3 &    M3
const [inline]
 

Matrix-matrix subtraction C <- A - B

Each of A, B, and C must support the same iterator, either row or column

Parameters:
C  Output matrix C
A  Input matrix A
B  Input matrix B
Returns:
Reference to C

Matrix1 & subin Matrix1 &    M1,
const Matrix2 &    M2
const [inline]
 

Matrix-matrix in-place subtraction A <- A - B

Each of A and B must support the same iterator, either row or column

Parameters:
A  Input matrix A
B  Input matrix B
Returns:
Reference to A

Vector1& vectorAxpyin Vector1 &    y,
const Matrix &    A,
const Vector2 &    x
const [inline]
 

Matrix-vector in-place axpy y <- y + A*x

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.

Parameters:
y  Input vector y; result is stored here
A  Input matrix A
x  Input vector x

Vector1& vectorMul Vector1 &    w,
const Matrix &    A,
const Vector2 &    v
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.

Parameters:
w  Output vector w
A  Input matrix A
v  Input vector v
Returns:
Reference to w

std::ostream& write std::ostream &    os,
const Matrix &    A
const [inline]
 

Print matrix.

Parameters:
os  Output stream to which matrix is written.
A  Matrix.
Returns:
reference to os.


Generated on Mon Jun 20 09:16:54 2005 for linbox by doxygen1.2.18