Public Member Functions
fmatvec::Matrix< General, AT > Class Template Reference

This is a matrix class for general matrices. More...

#include <general_matrix.h>

Inheritance diagram for fmatvec::Matrix< General, AT >:
fmatvec::RowVector< AT > fmatvec::SquareMatrix< AT > fmatvec::Vector< AT >

List of all members.

Public Member Functions

 Matrix ()
 Standard constructor.
 Matrix (int m_, int n_)
 Regular Constructor.
 Matrix (int m_, int n_, Initialization ini, const AT &a=0)
 Regular Constructor.
 Matrix (const Matrix< General, AT > &A)
 Copy Constructor.
 Matrix (int m_, int n_, AT *ele_)
 Regular Constructor.
 Matrix (const char *str)
 String Constructor.
 ~Matrix ()
 Destructor.
Matrix< General, AT > & resize (int m_, int n_)
 Matrix resizing.
Matrix< General, AT > & resize (int m_, int n_, Initialization ini, const AT &a=0)
 Matrix resizing.
Matrix< General, AT > & operator= (const Matrix< General, AT > &A)
 Assignment operator.
template<class T >
Matrix< General, AT > & operator<< (const Matrix< T, AT > &A)
 Copy operator.
Matrix< General, AT > & operator>> (const Matrix< General, AT > &A)
 Reference operator.
AT & operator() (int i, int j)
 Element operator.
const AT & operator() (int i, int j) const
 Element operator.
AT * operator() ()
 Pointer operator.
const AT * operator() () const
 Pointer operator.
int rows () const
 Number of rows.
int cols () const
 Number of columns.
int ldim () const
 Leading dimension.
bool transposed () const
 Transposed status.
const CBLAS_TRANSPOSE blasTrans () const
 Transposed status.
const CBLAS_ORDER blasOrder () const
 Storage convention.
Matrix< General, AT > operator() (int i1, int j1, int i2, int j2)
 Submatrix operator.
const Matrix< General, AT > operator() (int i1, int j1, int i2, int j2) const
 Submatrix operator.
Matrix< General, AT > operator() (const Index &I, const Index &J)
 Submatrix operator.
const Matrix< General, AT > operator() (const Index &I, const Index &J) const
 Submatrix operator.
SquareMatrix< AT > operator() (const Index &I)
 Submatrix operator.
const SquareMatrix< AT > operator() (const Index &I) const
 Submatrix operator.
Vector< AT > col (int i)
 Column operator.
const Vector< AT > col (int i) const
 Column operator.
RowVector< AT > row (int i)
 Row operator.
const RowVector< AT > row (int i) const
 Row operator.
Matrix< General, AT > & resize ()
 Matrix unsizing.
Matrix< General, AT > copy () const
 Matrix duplicating.
Matrix< General, AT > & init (const AT &a)
 Initialization.
 operator std::vector< std::vector< AT > > ()
 Cast to std::vector<std::vector<AT> >.
 Matrix (std::vector< std::vector< AT > > m)
 std::vector<std::vector<AT> > Constructor. Constructs and initializes a matrix with a std::vector<std::vector<AT> > object. An assert checks for constant length of each row.
Matrix< General, AT > T ()
const Matrix< General, AT > T () const
template<class Type >
Matrix< General, AT > & operator<< (const Matrix< Type, AT > &A)

Detailed Description

template<class AT>
class fmatvec::Matrix< General, AT >

This is a matrix class for general matrices.

Template class Matrix with shape type General and atomic type AT. The storage form is dense. The template parameter AT defines the atomic type of the matrix. Valid types are int, float, double, complex<float> and complex<double>


Constructor & Destructor Documentation

template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( )
inline

Standard constructor.

Constructs a matrix with no size.

template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( int  m_,
int  n_ 
)
inline

Regular Constructor.

Constructs a matrix of size m x n.

Parameters:
m_The number of rows.
n_The number of columns.
Remarks:
The matrix will be initialised to zero by default. This default behavior can be changed by defining FMATVEC_NO_INITIALIZATION.
template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( int  m_,
int  n_,
Initialization  ini,
const AT &  a = 0 
)
inline

Regular Constructor.

Constructs a matrix of size m x n. The matrix will be initialized to the value given by a (default 0), if ini is set to INIT. If init is set to NONINIT, the matrix will not be initialized.

Parameters:
m_The number of rows.
n_The number of columns.
iniINIT means initialization, NONINIT means no initialization.
aThe value, the matrix will be initialized with (default 0)
template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( const Matrix< General, AT > &  A)
inline

Copy Constructor.

Constructs a reference to the matrix A.

Attention:
The physical memory of the matrix A will not be copied, only referenced.
Parameters:
AThe matrix that will be referenced.
template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( int  m_,
int  n_,
AT *  ele_ 
)
inline

Regular Constructor.

Constructs a matrix of size m x n with the pyhsical memory given by ele_.

Parameters:
m_The number of rows.
n_The number of columns.
ele_The physical memory the matrix will point to.
template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( const char *  str)

String Constructor.

    Constructs and initializes a matrix with a string in a matlab-like
    notation. The rows are seperated by semicolons, the columns by commas.
    For example
    @code 
    Matrix<General,double> A("[3,2;1,2]");
    \endcode 
    constructs the matrix

\[ A=\begin{pmatrix}3 & 2\\ 1 & 2\end{pmatrix} \]

Parameters:
strThe string the matrix will be initialized with.
template<class AT >
fmatvec::Matrix< General, AT >::Matrix ( std::vector< std::vector< AT > >  m)

std::vector<std::vector<AT> > Constructor. Constructs and initializes a matrix with a std::vector<std::vector<AT> > object. An assert checks for constant length of each row.

Parameters:
mThe std::vector<std::vector<AT> > the matrix will be initialized with.

References fmatvec::Matrix< ST, AT >::cols(), and fmatvec::Matrix< ST, AT >::rows().


Member Function Documentation

template<class AT >
const CBLAS_ORDER fmatvec::Matrix< General, AT >::blasOrder ( ) const
inline

Storage convention.

Returns the blas-conform storage convention. The elements are stored in columnmajor form, i.e. the elements are stored columnwise.

Returns:
CblasColMajor.
template<class AT >
const CBLAS_TRANSPOSE fmatvec::Matrix< General, AT >::blasTrans ( ) const
inline

Transposed status.

Returns the blas-conform transposed status.

Returns:
CblasTrans if the matrix is in transposed form, CblasNoTrans otherwise.
template<class AT >
Vector< AT > fmatvec::Matrix< General, AT >::col ( int  i)

Column operator.

Returns a vector containing the i-th column of the calling matrix.

Attention:
The vector and the calling matrix will share the same physical memory.
Parameters:
iThe column, that will be returned.
Returns:
A vector containing the i-th column of the calling matrix.
template<class AT >
const Vector< AT > fmatvec::Matrix< General, AT >::col ( int  i) const

Column operator.

see col(int)

template<class AT >
int fmatvec::Matrix< General, AT >::cols ( ) const
inline
template<class AT >
Matrix< General, AT > fmatvec::Matrix< General, AT >::copy ( ) const

Matrix duplicating.

The calling matrix returns a deep copy of itself.

Returns:
The duplicate.

Reimplemented in fmatvec::Vector< AT >, fmatvec::RowVector< AT >, and fmatvec::SquareMatrix< AT >.

Referenced by fmatvec::bubbleSort(), and fmatvec::quickSortMedian().

template<class AT >
Matrix< General, AT > & fmatvec::Matrix< General, AT >::init ( const AT &  a)

Initialization.

Initializes all elements of the calling matrix with the value given by a.

Parameters:
aValue all elements will be initialized with.
Returns:
A reference to the calling matrix.

Reimplemented in fmatvec::Vector< AT >, and fmatvec::RowVector< AT >.

References fmatvec::Matrix< ST, AT >::cols(), and fmatvec::Matrix< ST, AT >::rows().

template<class AT >
int fmatvec::Matrix< General, AT >::ldim ( ) const
inline

Leading dimension.

Returns:
The leading dimension of the matrix.
template<class AT >
fmatvec::Matrix< General, AT >::operator std::vector< std::vector< AT > > ( )

Cast to std::vector<std::vector<AT> >.

Returns:
The std::vector<std::vector<AT> > representation of the matrix

Reimplemented in fmatvec::SquareMatrix< AT >.

template<class AT >
AT& fmatvec::Matrix< General, AT >::operator() ( int  i,
int  j 
)
inline

Element operator.

Returns a reference to the element in the i-th row and the j-th column.

Parameters:
iThe i-th row of the matrix
jThe j-th column of the matrix
Returns:
A reference to the element A(i,j).
Remarks:
The bounds are checked by default. To change this behavior, define FMATVEC_NO_BOUNDS_CHECK.
See also:
operator()(int,int) const

Reimplemented in fmatvec::Vector< AT >, and fmatvec::RowVector< AT >.

template<class AT >
const AT& fmatvec::Matrix< General, AT >::operator() ( int  i,
int  j 
) const
inline

Element operator.

See operator()(int,int)

Reimplemented in fmatvec::Vector< AT >, and fmatvec::RowVector< AT >.

template<class AT >
AT* fmatvec::Matrix< General, AT >::operator() ( )
inline

Pointer operator.

Returns the pointer to the first element.

Returns:
The pointer to the first element.
template<class AT >
const AT* fmatvec::Matrix< General, AT >::operator() ( ) const
inline

Pointer operator.

See operator()()

template<class AT >
Matrix< General, AT > fmatvec::Matrix< General, AT >::operator() ( int  i1,
int  j1,
int  i2,
int  j2 
)

Submatrix operator.

Returns a submatrix of the calling matrix.

Attention:
The submatrix and the calling matrix will share the same physical memory.
Parameters:
i1The starting row.
j1The starting column.
i2The ending row.
j2The ending column.
Returns:
A submatrix of the calling matrix.

References fmatvec::Matrix< ST, AT >::operator()().

template<class AT >
const Matrix< General, AT > fmatvec::Matrix< General, AT >::operator() ( int  i1,
int  j1,
int  i2,
int  j2 
) const
template<class AT >
Matrix< General, AT > fmatvec::Matrix< General, AT >::operator() ( const Index &  I,
const Index &  J 
)

Submatrix operator.

    Returns a submatrix of the calling matrix. 
    For example
    @code 
    B = A(Index(1,2),Index(2,4));
    \endcode
    yields

\[ A=\begin{pmatrix} a_{00} & a_{01} & a_{02} & a_{03} & a_{04}\\ a_{10} & a_{11} & a_{12} & a_{13} & a_{14}\\ a_{20} & a_{21} & a_{22} & a_{23} & a_{24}\\ a_{30} & a_{31} & a_{32} & a_{33} & a_{34} \end{pmatrix}\quad \Rightarrow \quad B=\begin{pmatrix} a_{12} & a_{13} & a_{14}\\ a_{22} & a_{23} & a_{24} \end{pmatrix} \]

Attention:
The submatrix and the calling matrix will share the same physical memory.
Parameters:
IIndex containing the starting and the ending row.
JIndex containing the starting and the ending column.
Returns:
A submatrix of the calling matrix.

References fmatvec::Index::end(), and fmatvec::Index::start().

template<class AT >
const Matrix< General, AT > fmatvec::Matrix< General, AT >::operator() ( const Index &  I,
const Index &  J 
) const
template<class AT >
SquareMatrix< AT > fmatvec::Matrix< General, AT >::operator() ( const Index &  I)

Submatrix operator.

Returns a square submatrix of the calling matrix.

Attention:
The submatrix and the calling matrix will share the same physical memory.
Parameters:
IIndex containing the starting and the ending row.
Returns:
A submatrix of the calling matrix.

Reimplemented in fmatvec::Vector< AT >, and fmatvec::RowVector< AT >.

References fmatvec::Index::end(), and fmatvec::Index::start().

template<class AT >
const SquareMatrix< AT > fmatvec::Matrix< General, AT >::operator() ( const Index &  I) const
template<class AT >
template<class T >
Matrix<General, AT>& fmatvec::Matrix< General, AT >::operator<< ( const Matrix< T, AT > &  A)

Copy operator.

Copies the matrix given by A.

Parameters:
AThe matrix to be copied.
Returns:
A reference to the calling matrix.

Reimplemented in fmatvec::SquareMatrix< AT >.

template<class AT >
Matrix<General, AT>& fmatvec::Matrix< General, AT >::operator= ( const Matrix< General, AT > &  A)
inline

Assignment operator.

Copies the matrix given by A by calling operator<<().

Parameters:
AThe matrix to be assigned.
Returns:
A reference to the calling matrix.
Remarks:
To call operator>>() by default, define FMATVEC_NO_DEEP_ASSIGNMENT
See also:
operator<<(), operator>>()

References fmatvec::operator<<(), and fmatvec::operator>>().

template<class AT >
Matrix< General, AT > & fmatvec::Matrix< General, AT >::operator>> ( const Matrix< General, AT > &  A)

Reference operator.

References the matrix given by A.

Parameters:
AThe matrix to be referenced.
Returns:
A reference to the calling matrix.
template<class AT >
Matrix<General, AT>& fmatvec::Matrix< General, AT >::resize ( int  m_,
int  n_ 
)
inline

Matrix resizing.

Resizes the matrix to size m x n.

Parameters:
m_The number of rows.
n_The number of columns.
Returns:
A reference to the calling matrix.
Remarks:
The matrix will be initialised to zero by default. To change this behavior, define FMATVEC_NO_INITIALIZATION.

References resize().

Referenced by resize().

template<class AT >
Matrix<General, AT>& fmatvec::Matrix< General, AT >::resize ( int  m_,
int  n_,
Initialization  ini,
const AT &  a = 0 
)
inline

Matrix resizing.

Resizes the matrix to size m x n. The matrix will be initialized to the value given by a (default 0), if ini is set to INIT. If init is set to NONINIT, the matrix will not be initialized.

Parameters:
m_The number of rows.
n_The number of columns.
iniINIT means initialization, NONINIT means no initialization.
aThe value, the matrix will be initialized with (default 0)
Returns:
A reference to the calling matrix.

References resize().

template<class AT >
Matrix<General, AT>& fmatvec::Matrix< General, AT >::resize ( )
inline

Matrix unsizing.

Resizes the matrix to size zero.

Returns:
A reference to the calling matrix.

Referenced by fmatvec::SquareMatrix< AT >::resize(), fmatvec::RowVector< AT >::resize(), and fmatvec::Vector< AT >::resize().

template<class AT >
RowVector< AT > fmatvec::Matrix< General, AT >::row ( int  i)

Row operator.

Returns a RowVector containing the i-th row of the calling matrix.

Attention:
The rowvector and the calling matrix will share the same physical memory.
Parameters:
iThe row, that will be returned.
Returns:
A rowvector containing the i-th row of the calling matrix.

Referenced by fmatvec::bubbleSort(), and fmatvec::quicksortmedian_intern().

template<class AT >
const RowVector< AT > fmatvec::Matrix< General, AT >::row ( int  i) const

Row operator.

see row(int)

template<class AT >
int fmatvec::Matrix< General, AT >::rows ( ) const
inline
template<class AT >
bool fmatvec::Matrix< General, AT >::transposed ( ) const
inline

Transposed status.

Returns boolean transposed status.

Returns:
True, if the matrix is in transposed form, false otherwise.

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