fmatvec  2.0.0
Fast Matrix/Vector Library
Public Types | Public Member Functions | List of all members
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT > Class Template Reference

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

#include <fixed_general_matrix.h>

Public Types

typedef AT value_type
 

Public Member Functions

 Matrix (Noinit)
 
 Matrix (Init ini=INIT, const AT &a=AT())
 
 Matrix (Eye ini, const AT &a=1)
 
 Matrix (int m, int n, Noinit)
 
 Matrix (int m, int n, Init ini=INIT, const AT &a=AT())
 
 Matrix (int m, int n, Eye ini, const AT &a=1)
 
 Matrix (const Matrix< General, Fixed< M >, Fixed< N >, AT > &A)=default
 Copy Constructor. More...
 
template<class Row , class Col >
 Matrix (const Matrix< General, Row, Col, AT > &A)
 Copy Constructor. More...
 
template<class Type , class Row , class Col >
 Matrix (const Matrix< Type, Row, Col, AT > &A)
 Copy Constructor. More...
 
 Matrix (const std::string &strs)
 String Constructor. More...
 
 Matrix (const char *strs)
 
Matrix< General, Fixed< M >, Fixed< N >, AT > & operator= (const Matrix< General, Fixed< M >, Fixed< N >, AT > &A)=default
 Assignment operator. More...
 
template<class Type , class Row , class Col >
Matrix< General, Fixed< M >, Fixed< N >, AT > & operator= (const Matrix< Type, Row, Col, AT > &A)
 Assignment operator. More...
 
template<class Type , class Row , class Col >
Matrix< General, Fixed< M >, Fixed< N >, AT > & operator<<= (const Matrix< Type, Row, Col, AT > &A)
 Matrix assignment. More...
 
template<class AT2 >
 operator Matrix< General, Fixed< M >, Fixed< N >, AT2 > () const
 
AT & operator() (int i, int j)
 Element operator. More...
 
const AT & operator() (int i, int j) const
 Element operator. More...
 
AT & e (int i, int j)
 
const AT & e (int i, int j) const
 Element operator. More...
 
AT * operator() ()
 Pointer operator. More...
 
const AT * operator() () const
 Pointer operator. More...
 
int rows () const
 Number of rows. More...
 
int cols () const
 Number of columns. More...
 
int ldim () const
 Leading dimension. More...
 
void resize (int m, int n)
 
const CBLAS_TRANSPOSE blasTrans () const
 Transposed status. More...
 
const CBLAS_ORDER blasOrder () const
 Storage convention. More...
 
const Matrix< General, Var, Var, AT > operator() (const Range< Var, Var > &I, const Range< Var, Var > &J) const
 Submatrix operator. More...
 
template<int M1, int M2, int N1, int N2>
const Matrix< General, Fixed< M2-M1+1 >, Fixed< N2-N1+1 >, AT > operator() (const Range< Fixed< M1 >, Fixed< M2 >> &I, const Range< Fixed< N1 >, Fixed< N2 >> &J) const
 
template<int M1, int M2>
const Matrix< General, Fixed< M2-M1+1 >, Var, AT > operator() (const Range< Fixed< M1 >, Fixed< M2 >> &I, const Range< Var, Var > &J) const
 
template<int N1, int N2>
const Matrix< General, Var, Fixed< N2-N1+1 >, AT > operator() (const Range< Var, Var > &I, const Range< Fixed< N1 >, Fixed< N2 >> &J) const
 
const RowVector< Fixed< N >, AT > row (int i) const
 
const Vector< Fixed< M >, AT > col (int j) const
 
Matrix< General, Fixed< M >, Fixed< N >, AT > & init (const AT &val=AT())
 Initialization. More...
 
Matrix< General, Fixed< M >, Fixed< N >, AT > & init (Init, const AT &a=AT())
 
Matrix< General, Fixed< M >, Fixed< N >, AT > & init (Eye, const AT &val=1)
 
Matrix< General, Fixed< M >, Fixed< N >, AT > & init (Noinit, const AT &a=AT())
 
 operator std::vector< std::vector< AT >> () const
 Cast to std::vector<std::vector<AT>>. More...
 
 Matrix (const 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 FMATVEC_ASSERT checks for constant length of each row. More...
 
const Matrix< General, Fixed< N >, Fixed< M >, AT > T () const
 Cast to AT. More...
 
template<class Row >
void set (int j, const Vector< Row, AT > &x)
 set Column j of matrix to given Vector
 
template<class Col >
void set (int i, const RowVector< Col, AT > &x)
 set Row i of matrix to given RowVector
 
template<class Type , class Row , class Col >
void set (const Range< Var, Var > &I, const Range< Var, Var > &J, const Matrix< Type, Row, Col, AT > &A)
 set the submatrix - specified by the Range operators - to the values of A More...
 
template<class Row >
void add (int j, const Vector< Row, AT > &x)
 add to Column j of the matrix the given Vector
 
template<class Col >
void add (int i, const RowVector< Col, AT > &x)
 add to Row i of the matrix the given RowVector
 
template<class Type , class Row , class Col >
void add (const Range< Var, Var > &I, const Range< Var, Var > &J, const Matrix< Type, Row, Col, AT > &A)
 

Detailed Description

template<int M, int N, class AT>
class fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >

This is a matrix class for general matrices.

Template class Matrix with shape type General, Fixed 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

◆ Matrix() [1/5]

template<int M, int N, class AT >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::Matrix ( const Matrix< General, Fixed< M >, Fixed< N >, AT > &  A)
default

Copy Constructor.

Constructs a copy of the matrix A.

Parameters
AThe matrix that will be copied.

◆ Matrix() [2/5]

template<int M, int N, class AT >
template<class Row , class Col >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::Matrix ( const Matrix< General, Row, Col, AT > &  A)
inline

Copy Constructor.

Constructs a copy of the matrix A.

Parameters
AThe matrix that will be copied.

◆ Matrix() [3/5]

template<int M, int N, class AT >
template<class Type , class Row , class Col >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::Matrix ( const Matrix< Type, Row, Col, AT > &  A)
inlineexplicit

Copy Constructor.

Constructs a copy of the matrix A.

Parameters
AThe matrix that will be copied.

◆ Matrix() [4/5]

template<int M, int N, class AT >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::Matrix ( const std::string &  strs)

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

Matrix<General, Fixed,double> A("[3,2;1,2]");

constructs the matrix

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

Parameters
strThe string the matrix will be initialized with.

◆ Matrix() [5/5]

template<int M, int N, class AT >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::Matrix ( const std::vector< std::vector< AT >> &  m)
inlineexplicit

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

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

Member Function Documentation

◆ blasOrder()

template<int M, int N, class AT >
const CBLAS_ORDER fmatvec::Matrix< General, Fixed< M >, Fixed< N >, 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
CblasRowMajor.

◆ blasTrans()

template<int M, int N, class AT >
const CBLAS_TRANSPOSE fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::blasTrans ( ) const
inline

Transposed status.

Returns the blas-conform transposed status.

Returns
CblasTrans if the matrix is in transposed form, CblasNoTrans otherwise.

◆ cols()

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

Number of columns.

Returns
The number of columns of the matrix.

◆ e()

template<int M, int N, class AT >
const AT& fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::e ( int  i,
int  j 
) const
inline

Element operator.

See e(int,int)

◆ init()

template<int M, int N, class AT >
Matrix< General, Fixed< M >, Fixed< N >, AT > & fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::init ( const AT &  val = AT())
inline

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.

◆ ldim()

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

Leading dimension.

Returns
The leading dimension of the matrix

◆ operator std::vector< std::vector< AT >>()

template<int M, int N, class AT >
fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator std::vector< std::vector< AT >> ( ) const
inlineexplicit

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

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

◆ operator()() [1/5]

template<int M, int N, class AT >
AT& fmatvec::Matrix< General, Fixed< M >, Fixed< N >, 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 in debug mode.
See also
operator()(int,int) const

◆ operator()() [2/5]

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

Element operator.

See operator()(int,int)

◆ operator()() [3/5]

template<int M, int N, class AT >
AT* fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator() ( )
inline

Pointer operator.

Returns the pointer to the first element.

Returns
The pointer to the first element.

◆ operator()() [4/5]

template<int M, int N, class AT >
const AT* fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator() ( ) const
inline

Pointer operator.

See operator()()

◆ operator()() [5/5]

template<int M, int N, class AT >
const Matrix< General, Var, Var, AT > fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator() ( const Range< Var, Var > &  I,
const Range< Var, Var > &  J 
) const
inline

Submatrix operator.

See operator()(const Range<Var,Var>&, const Range<Var,Var>&)

◆ operator<<=()

template<int M, int N, class AT >
template<class Type , class Row , class Col >
Matrix<General,Fixed<M>,Fixed<N>,AT>& fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator<<= ( const Matrix< Type, Row, Col, AT > &  A)
inline

Matrix assignment.

Copies the matrix given by A.

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

◆ operator=() [1/2]

template<int M, int N, class AT >
Matrix<General,Fixed<M>,Fixed<N>,AT>& fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator= ( const Matrix< General, Fixed< M >, Fixed< N >, AT > &  A)
inlinedefault

Assignment operator.

Copies the matrix given by A.

Parameters
AThe matrix to be assigned.
Returns
A reference to the calling matrix.

◆ operator=() [2/2]

template<int M, int N, class AT >
template<class Type , class Row , class Col >
Matrix<General,Fixed<M>,Fixed<N>,AT>& fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::operator= ( const Matrix< Type, Row, Col, AT > &  A)
inline

Assignment operator.

Copies the matrix given by A.

Parameters
AThe matrix to be assigned.
Returns
A reference to the calling matrix.

◆ resize()

template<int M, int N, class AT >
void fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::resize ( int  m,
int  n 
)
inline

Resize a fixed matrix. Do nothing for the fixed dimension and throw on any other dimension.

◆ rows()

template<int M, int N, class AT >
int fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::rows ( ) const
inline

Number of rows.

Returns
The number of rows of the matrix.

◆ set()

template<int M, int N, class AT >
template<class Type , class Row , class Col >
void fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::set ( const Range< Var, Var > &  I,
const Range< Var, Var > &  J,
const Matrix< Type, Row, Col, AT > &  A 
)
inline

set the submatrix - specified by the Range operators - to the values of A

Parameters
IRange of starting and ending row
JRange of starting and ending column
AMatrix with the values the submatrix should take

◆ T()

template<int M, int N, class AT >
const Matrix< General, Fixed< N >, Fixed< M >, AT > fmatvec::Matrix< General, Fixed< M >, Fixed< N >, AT >::T ( ) const
inline

Cast to AT.

Returns
The AT representation of the matrix

AT Constructor. Constructs and initializes a matrix with a AT object.

Parameters
vThe AT the matrix will be initialized with.

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