linbox
Data Structures | Public Types | Public Member Functions | Data Fields
BlasMatrix< _Field, _Storage > Class Template Reference

Dense matrix representation. More...

#include <matrix-domain.h>

+ Inheritance diagram for BlasMatrix< _Field, _Storage >:
+ Collaboration diagram for BlasMatrix< _Field, _Storage >:

Data Structures

class  IndexedIterator
 Indexed Iterator. More...
 
struct  rebind
 Rebind operator. More...
 

Public Types

typedef Field::Element Element
 Element type.
 
typedef _Storage Rep
 Actually a std::vector<Element> (or alike: cstor(n), cstor(n, val), operator[], resize(n).)
 
typedef Rep::pointer pointer
 pointer type to elements
 
typedef const pointer const_pointer
 const pointer type
 
typedef BlasMatrix< Field, RepSelf_t
 Self typeype.
 
typedef const BlasMatrix< Field, RepconstSelf_t
 Self typeype.
 
typedef BlasSubmatrix< Self_tsubMatrixType
 Submatrix type.
 
typedef BlasSubmatrix< constSelf_tconstSubMatrixType
 Submatrix type.
 
typedef Self_t matrixType
 matrix type
 
typedef constSelf_t constMatrixType
 matrix type
 
typedef Self_t blasType
 blas matrix type
 

Public Member Functions

 BlasMatrix (const _Field &F)
 Allocates a new $ 0 \times 0$ matrix (shaped and ready).
 
void init (const _Field &F, const size_t &r=0, const size_t &c=0)
 Allocates a new bare $ 0 \times 0$ matrix (unshaped, unready). More...
 
 BlasMatrix (MatrixStream< _Field > &ms)
 Constructor from a matrix stream. More...
 
template<class Matrix >
 BlasMatrix (const Matrix &A)
 Generic copy constructor from either a blackbox or a matrix container. More...
 
template<class Matrix >
 BlasMatrix (const Matrix &A, const size_t &i0, const size_t &j0, const size_t &m, const size_t &n)
 Generic copy constructor from either a blackbox or a matrix container (allow submatrix). More...
 
template<class _Matrix >
 BlasMatrix (const _Matrix &A, const _Field &F)
 Constructor. More...
 
 BlasMatrix (const Self_t &A)
 Copy Constructor of a matrix (copying data). More...
 
 BlasMatrix (const _Field &F, const std::vector< Element > &v, const size_t &m, const size_t &n)
 Create a BlasMatrix from a vector of elements. More...
 
 BlasMatrix (const _Field &F, const Element *v, const size_t &m, const size_t &n)
 Create a BlasMatrix from an array of elements. More...
 
template<class StreamVector >
 BlasMatrix (const Field &F, VectorStream< StreamVector > &stream)
 Constructor using a finite vector stream (stream of the rows). More...
 
 ~BlasMatrix ()
 Destructor.
 
Self_toperator= (const Self_t &A)
 operator = (copying data)
 
template<class Matrix >
BlasMatrixcopy (const Matrix &B)
 Make this a (deep)copy of B. More...
 
size_t rowdim () const
 Get the number of rows in the matrix. More...
 
size_t coldim () const
 Get the number of columns in the matrix. More...
 
size_t getStride () const
  Get the stride of the matrix.
 
size_t & getWriteStride ()
 Get a reference to the stride of the matrix. More...
 
void resize (const size_t &m, const size_t &n, const Element &val=Element())
 Resize the matrix to the given dimensions. More...
 
pointer getPointer ()
  .
 
pointergetWritePointer ()
  .
 
const ElementsetEntry (size_t i, size_t j, const Element &a_ij)
 Set the entry at the (i, j) position to a_ij. More...
 
ElementrefEntry (size_t i, size_t j)
 Get a writeable reference to the entry in the (i, j) position. More...
 
const ElementgetEntry (size_t i, size_t j) const
 Get a read-only reference to the entry in the (i, j) position. More...
 
ElementgetEntry (Element &x, size_t i, size_t j) const
 Copy the (i, j) entry into x, and return a reference to x. More...
 
Self_t transpose (Self_t &tM) const
 Creates a transposed matrix of *this. More...
 
template<bool _IP>
void transpose ()
 Transpose (inplace). More...
 
void reverseRows ()
 Reverse the rows of a matrix. More...
 
void reverseCols ()
 Reverse the columns of a matrix. More...
 
void reverse ()
 Reverse the rows/columns of a matrix. More...
 
std::istream & read (std::istream &file)
 Read the matrix from an input stream. More...
 
std::ostream & write (std::ostream &os) const
 Write the matrix in MatrixMarket format.
 
std::ostream & write (std::ostream &os, Tag::FileFormat f) const
 Write the matrix to an output stream. More...
 
std::ostream & write (std::ostream &os, bool mapleFormat) const
 
template<class Vector >
VectorcolumnDensity (Vector &v) const
 Compute column density. More...
 
template<>
void random (const size_t &b)
 
 BlasMatrix (const _Field &F, const size_t &m, const size_t &n)
 Allocates a new $ m \times n$ zero matrix (shaped and ready). More...
 
Raw Indexed iterator

Like the raw iterator, the indexed iterator is a method for accessing all entries in the matrix in some unspecified order.

At each position of the the indexed iterator, it also provides the row and column indices of the currently referenced entry. This is provided through it's rowIndex() and colIndex() functions.

IndexedIterator IndexedBegin ()
 
IndexedIterator IndexedEnd ()
 
ConstIndexedIterator IndexedBegin () const
 
ConstIndexedIterator IndexedEnd () const
 
Row operator[] (size_t i)
 Retrieve a reference to a row. More...
 
ConstRow operator[] (size_t i) const
 Retrieve a reference to a row. More...
 

Data Fields

pointer _ptr
 
MatrixDomain< Field > _MD
 
VectorDomain< Field > _VD
 

Column of rows iterator

The column of rows iterator traverses the rows of the matrix in ascending order.

Dereferencing the iterator yields a row vector in dense format

typedef Subvector< typename Rep::iterator, typename Rep::const_iterator > Row
 
typedef Subvector< typename Rep::const_iterator > ConstRow
 
RowIterator rowBegin ()
 
RowIterator rowEnd ()
 
ConstRowIterator rowBegin () const
 
ConstRowIterator rowEnd () const
 

Row of columns iterator

The row of columns iterator traverses the columns of the matrix in ascending order.

Dereferencing the iterator yields a column vector in dense format

typedef Subvector< Subiterator< typename Rep::iterator > > Col
 
typedef Subvector< Subiterator< typename Rep::const_iterator > > ConstCol
 
typedef Col Column
 
typedef ConstCol ConstColumn
 
ColIterator colBegin ()
 
ColIterator colEnd ()
 
ConstColIterator colBegin () const
 
ConstColIterator colEnd () const
 

Iterator

The iterator is a method for accessing all entries in the matrix in some unspecified order.

This can be used, e.g. to reduce all matrix entries modulo a prime before passing the matrix into an algorithm.

typedef Rep::iterator Iterator
 
typedef Rep::const_iterator ConstIterator
 
Iterator Begin ()
 
Iterator End ()
 
ConstIterator Begin () const
 
ConstIterator End () const
 

Detailed Description

template<class _Field, class _Storage>
class LinBox::BlasMatrix< _Field, _Storage >

Dense matrix representation.

A BlasMatrix is a matrix of _Field::Element, with the structure of BLAS matrices. It is basically a vector of _Field::Element. In the Mother model, a BlasMatrix is allocated by the user.

Bug:
why not BlasMatrixDomain ?
Bug:
necessitates the inclusion of those things after of before. We should not include directly this but just the matrices and they automatically need their domain (for now)
Examples:
examples/omp_block_rank.C, and examples/samplebb.C.

Constructor & Destructor Documentation

◆ BlasMatrix() [1/9]

BlasMatrix ( const _Field &  F,
const size_t &  m,
const size_t &  n 
)

Allocates a new $ m \times n$ zero matrix (shaped and ready).

Parameters
F
mrows
ncols

◆ BlasMatrix() [2/9]

BlasMatrix ( MatrixStream< _Field > &  ms)

Constructor from a matrix stream.

Parameters
msmatrix stream.

◆ BlasMatrix() [3/9]

BlasMatrix ( const Matrix &  A)

Generic copy constructor from either a blackbox or a matrix container.

Parameters
Amatrix to be copied

◆ BlasMatrix() [4/9]

BlasMatrix ( const Matrix &  A,
const size_t &  i0,
const size_t &  j0,
const size_t &  m,
const size_t &  n 
)

Generic copy constructor from either a blackbox or a matrix container (allow submatrix).

Parameters
Amatrix to be copied
i0
j0
mrows
ncolumns

◆ BlasMatrix() [5/9]

BlasMatrix ( const _Matrix &  A,
const _Field &  F 
)

Constructor.

Parameters
Amatrix to be copied
FField

◆ BlasMatrix() [6/9]

BlasMatrix ( const Self_t A)

Copy Constructor of a matrix (copying data).

Parameters
Amatrix to be copied.

◆ BlasMatrix() [7/9]

BlasMatrix ( const _Field &  F,
const std::vector< Element > &  v,
const size_t &  m,
const size_t &  n 
)

Create a BlasMatrix from a vector of elements.

Parameters
F
v
m
n

◆ BlasMatrix() [8/9]

BlasMatrix ( const _Field &  F,
const Element v,
const size_t &  m,
const size_t &  n 
)

Create a BlasMatrix from an array of elements.

Parameters
F
v
m
n

◆ BlasMatrix() [9/9]

BlasMatrix ( const Field &  F,
VectorStream< StreamVector > &  stream 
)

Constructor using a finite vector stream (stream of the rows).

Parameters
FThe field of entries; passed so that arithmetic may be done on elements
streamA vector stream to use as a source of vectors for this matrix

Member Function Documentation

◆ init()

void init ( const _Field &  F,
const size_t &  r = 0,
const size_t &  c = 0 
)

Allocates a new bare $ 0 \times 0$ matrix (unshaped, unready).

(Re)allocates a new $ m \times n$ zero matrix (shaped and ready).

◆ copy()

BlasMatrix& copy ( const Matrix &  B)
inline

Make this a (deep)copy of B.

Assumes same shape. make sure we actually copy

◆ rowdim()

size_t rowdim ( ) const

Get the number of rows in the matrix.

Returns
Number of rows in matrix

◆ coldim()

size_t coldim ( ) const

Get the number of columns in the matrix.

Returns
Number of columns in matrix

◆ getWriteStride()

size_t & getWriteStride ( )

Get a reference to the stride of the matrix.

Modify stride this way.

◆ resize()

void resize ( const size_t &  m,
const size_t &  n,
const Element val = Element() 
)

Resize the matrix to the given dimensions.

The state of the matrix's entries after a call to this method is undefined

Parameters
mNumber of rows
nNumber of columns
val

◆ setEntry()

const _Field::Element & setEntry ( size_t  i,
size_t  j,
const Element a_ij 
)

Set the entry at the (i, j) position to a_ij.

Parameters
iRow number, 0...rowdim () - 1
jColumn number 0...coldim () - 1
a_ijElement to set

◆ refEntry()

_Field::Element & refEntry ( size_t  i,
size_t  j 
)

Get a writeable reference to the entry in the (i, j) position.

Parameters
iRow index of entry
jColumn index of entry
Returns
Reference to matrix entry

◆ getEntry() [1/2]

const _Field::Element & getEntry ( size_t  i,
size_t  j 
) const

Get a read-only reference to the entry in the (i, j) position.

Parameters
iRow index
jColumn index
Returns
Const reference to matrix entry

◆ getEntry() [2/2]

_Field::Element & getEntry ( Element x,
size_t  i,
size_t  j 
) const

Copy the (i, j) entry into x, and return a reference to x.

This form is more in the Linbox style and is provided for interface compatibility with other parts of the library

Parameters
xElement in which to store result
iRow index
jColumn index
Returns
Reference to x

◆ transpose() [1/2]

Self_t transpose ( Self_t tM) const

Creates a transposed matrix of *this.

Parameters
[in]tM
Returns
the transposed matrix of this.

◆ transpose() [2/2]

void transpose ( )

Transpose (inplace).

If rows and columns agree, we can transpose inplace.

◆ reverseRows()

void reverseRows ( )

Reverse the rows of a matrix.

This is done inplace. Let J=antiDiag(1) (or the matrix of the reverse permutation or the matrix (i,j) = (i+j+1==m)). Then, we compute A <- J.A;

◆ reverseCols()

void reverseCols ( )

Reverse the columns of a matrix.

This is done inplace. This is A <- J.A

◆ reverse()

void reverse ( )

Reverse the rows/columns of a matrix.

This is done inplace. This is A <- J.A.J

◆ read()

std::istream & read ( std::istream &  file)

Read the matrix from an input stream.

The stream is in SMS, DENSE, or MatrixMarket format and is autodetected.

Parameters
fileInput stream from which to read

◆ write() [1/2]

std::ostream& write ( std::ostream &  os,
Tag::FileFormat  f 
) const
inline

Write the matrix to an output stream.

Parameters
osOutput stream to which to write
fwrite in some format (Tag::FileFormat::Format). Default is Maple's.

◆ write() [2/2]

std::ostream& write ( std::ostream &  os,
bool  mapleFormat 
) const
inline
Deprecated:
Only for compatiblity.

◆ operator[]() [1/2]

BlasMatrix< _Field, _Rep >::Row operator[] ( size_t  i)

Retrieve a reference to a row.

Since rows may also be indexed, this allows A[i][j] notation to be used.

Parameters
iRow index
Bug:
Rows and Cols should be BlasVectors

◆ operator[]() [2/2]

BlasMatrix< _Field, _Rep >::ConstRow operator[] ( size_t  i) const

Retrieve a reference to a row.

Since rows may also be indexed, this allows A[i][j] notation to be used.

Parameters
iRow index
Bug:
Rows and Cols should be BlasVectors

◆ columnDensity()

Vector & columnDensity ( Vector v) const

Compute column density.

Parameters
v

◆ random()

void random< size_t > ( const size_t &  b)
Bug:
does not work for submatrices.
Todo:
b should be the random generator

Field Documentation

◆ _ptr

pointer _ptr
Bug:
why public ?

◆ _MD

MatrixDomain<Field> _MD
Bug:
why public ?

◆ _VD

VectorDomain<Field> _VD
Bug:
why public ?

The documentation for this class was generated from the following files: