shark::blas::matrix< T, L > Class Template Reference

A dense matrix of values of type T. More...

#include <shark/LinAlg/BLAS/matrix.hpp>

+ Inheritance diagram for shark::blas::matrix< T, L >:

Public Types

typedef array_type::const_reference const_reference
 
typedef array_type::reference reference
 
typedef const T * const_pointer
 
typedef T * pointer
 
typedef index_type const * const_index_pointer
 
typedef index_type index_pointer
 
typedef dense_tag storage_category
 
typedef elementwise_tag evaluation_category
 
typedef L orientation
 
typedef dense_storage_iterator< value_type > row_iterator
 
typedef dense_storage_iterator< value_type > column_iterator
 
typedef dense_storage_iterator< value_type const > const_row_iterator
 
typedef dense_storage_iterator< value_type const > const_column_iterator
 
typedef blas::major_iterator< self_type >::type major_iterator
 

Public Member Functions

 matrix ()
 Default dense matrix constructor. Make a dense matrix of size (0,0) More...
 
 matrix (size_type size1, size_type size2)
 
 matrix (size_type size1, size_type size2, const value_type &init)
 
 matrix (size_type size1, size_type size2, const array_type &data)
 
 matrix (const matrix &m)
 
template<class E >
 matrix (matrix_expression< E > const &e)
 
size_type size1 () const
 Returns the number of rows of the matrix. More...
 
size_type size2 () const
 Returns the number of columns of the matrix. More...
 
difference_type stride1 () const
 Returns the stride in memory between two rows. More...
 
difference_type stride2 () const
 Returns the stride in memory between two columns. More...
 
const_pointer storage () const
 Returns the pointer to the beginning of the matrix storage. More...
 
pointer storage ()
 Returns the pointer to the beginning of the matrix storage. More...
 
void resize (size_type size1, size_type size2)
 
void clear ()
 
const_reference operator() (index_type i, index_type j) const
 
reference operator() (index_type i, index_type j)
 
void set_element (size_type i, size_type j, value_type t)
 
matrixoperator= (matrix m)
 
template<class C >
matrixoperator= (matrix_container< C > const &m)
 
template<class E >
matrixoperator= (matrix_expression< E > const &e)
 
void swap (matrix &m)
 
const_row_iterator row_begin (index_type i) const
 
const_row_iterator row_end (index_type i) const
 
row_iterator row_begin (index_type i)
 
row_iterator row_end (index_type i)
 
const_row_iterator column_begin (std::size_t j) const
 
const_column_iterator column_end (std::size_t j) const
 
column_iterator column_begin (std::size_t j)
 
column_iterator column_end (std::size_t j)
 
major_iterator set_element (major_iterator pos, index_type index, value_type value)
 
major_iterator clear_element (major_iterator elem)
 
major_iterator clear_range (major_iterator start, major_iterator end)
 
void reserve (size_type non_zeros)
 
void reserve_row (std::size_t, std::size_t)
 
void reserve_column (std::size_t, std::size_t)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int)
 
- Public Member Functions inherited from shark::blas::matrix_container< matrix< T, L > >
const container_type & operator() () const
 
container_type & operator() ()
 
- Public Member Functions inherited from shark::blas::matrix_expression< E >
const expression_type & operator() () const
 
expression_type & operator() ()
 

Friends

void swap (matrix &m1, matrix &m2)
 
void swap_rows (matrix &a, index_type i, matrix &b, index_type j)
 
void swap_rows (matrix &a, index_type i, index_type j)
 
void swap_columns (matrix &a, index_type i, matrix &b, index_type j)
 
void swap_columns (matrix &a, index_type i, index_type j)
 

Detailed Description

template<class T, class L = row_major>
class shark::blas::matrix< T, L >

A dense matrix of values of type T.

For a \((m \times n)\)-dimensional matrix and \( 0 \leq i < m, 0 \leq j < n\), every element \( m_{i,j} \) is mapped to the \((i.n + j)\)-th element of the container for row major orientation or the \( (i + j.m) \)-th element of the container for column major orientation. In a dense matrix all elements are represented in memory in a contiguous chunk of memory by definition.

Orientation can also be specified, otherwise a row_major is used.

Template Parameters
Tthe type of object stored in the matrix (like double, float, complex, etc...)
Lthe storage organization. It can be either row_major or column_major. Default is row_major

Definition at line 56 of file matrix.hpp.

Member Typedef Documentation

§ column_iterator

template<class T, class L = row_major>
typedef dense_storage_iterator<value_type> shark::blas::matrix< T, L >::column_iterator

Definition at line 251 of file matrix.hpp.

§ const_column_iterator

template<class T, class L = row_major>
typedef dense_storage_iterator<value_type const> shark::blas::matrix< T, L >::const_column_iterator

Definition at line 253 of file matrix.hpp.

§ const_index_pointer

template<class T, class L = row_major>
typedef index_type const* shark::blas::matrix< T, L >::const_index_pointer

Definition at line 70 of file matrix.hpp.

§ const_pointer

template<class T, class L = row_major>
typedef const T* shark::blas::matrix< T, L >::const_pointer

Definition at line 66 of file matrix.hpp.

§ const_reference

template<class T, class L = row_major>
typedef array_type::const_reference shark::blas::matrix< T, L >::const_reference

Definition at line 64 of file matrix.hpp.

§ const_row_iterator

template<class T, class L = row_major>
typedef dense_storage_iterator<value_type const> shark::blas::matrix< T, L >::const_row_iterator

Definition at line 252 of file matrix.hpp.

§ evaluation_category

template<class T, class L = row_major>
typedef elementwise_tag shark::blas::matrix< T, L >::evaluation_category

Definition at line 76 of file matrix.hpp.

§ index_pointer

template<class T, class L = row_major>
typedef index_type shark::blas::matrix< T, L >::index_pointer

Definition at line 71 of file matrix.hpp.

§ major_iterator

template<class T, class L = row_major>
typedef blas::major_iterator<self_type>::type shark::blas::matrix< T, L >::major_iterator

Definition at line 281 of file matrix.hpp.

§ orientation

template<class T, class L = row_major>
typedef L shark::blas::matrix< T, L >::orientation

Definition at line 77 of file matrix.hpp.

§ pointer

template<class T, class L = row_major>
typedef T* shark::blas::matrix< T, L >::pointer

Definition at line 67 of file matrix.hpp.

§ reference

template<class T, class L = row_major>
typedef array_type::reference shark::blas::matrix< T, L >::reference

Definition at line 65 of file matrix.hpp.

§ row_iterator

template<class T, class L = row_major>
typedef dense_storage_iterator<value_type> shark::blas::matrix< T, L >::row_iterator

Definition at line 250 of file matrix.hpp.

§ storage_category

template<class T, class L = row_major>
typedef dense_tag shark::blas::matrix< T, L >::storage_category

Definition at line 75 of file matrix.hpp.

Constructor & Destructor Documentation

§ matrix() [1/6]

template<class T, class L = row_major>
shark::blas::matrix< T, L >::matrix ( )
inline

Default dense matrix constructor. Make a dense matrix of size (0,0)

Definition at line 82 of file matrix.hpp.

Referenced by shark::PrecomputedMatrix< Matrix >::PrecomputedMatrix().

§ matrix() [2/6]

template<class T, class L = row_major>
shark::blas::matrix< T, L >::matrix ( size_type  size1,
size_type  size2 
)
inline

Dense matrix constructor with defined size

Parameters
size1number of rows
size2number of columns

Definition at line 88 of file matrix.hpp.

§ matrix() [3/6]

template<class T, class L = row_major>
shark::blas::matrix< T, L >::matrix ( size_type  size1,
size_type  size2,
const value_type &  init 
)
inline

Dense matrix constructor with defined size a initial value for all the matrix elements

Parameters
size1number of rows
size2number of columns
initinitial value assigned to all elements

Definition at line 96 of file matrix.hpp.

§ matrix() [4/6]

template<class T, class L = row_major>
shark::blas::matrix< T, L >::matrix ( size_type  size1,
size_type  size2,
const array_type &  data 
)
inline

Dense matrix constructor with defined size and an initial data array

Parameters
size1number of rows
size2number of columns
dataarray to copy into the matrix. Must have the same dimension as the matrix

Definition at line 104 of file matrix.hpp.

§ matrix() [5/6]

template<class T, class L = row_major>
shark::blas::matrix< T, L >::matrix ( const matrix< T, L > &  m)
inline

Copy-constructor of a dense matrix

Parameters
mis a dense matrix

Definition at line 110 of file matrix.hpp.

§ matrix() [6/6]

template<class T, class L = row_major>
template<class E >
shark::blas::matrix< T, L >::matrix ( matrix_expression< E > const &  e)
inline

Copy-constructor of a dense matrix from a matrix expression

Parameters
eis a matrix expression

Definition at line 117 of file matrix.hpp.

Member Function Documentation

§ clear()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::clear ( )
inline

Definition at line 175 of file matrix.hpp.

§ clear_element()

template<class T, class L = row_major>
major_iterator shark::blas::matrix< T, L >::clear_element ( major_iterator  elem)
inline

Definition at line 290 of file matrix.hpp.

§ clear_range()

template<class T, class L = row_major>
major_iterator shark::blas::matrix< T, L >::clear_range ( major_iterator  start,
major_iterator  end 
)
inline

Definition at line 295 of file matrix.hpp.

§ column_begin() [1/2]

template<class T, class L = row_major>
const_row_iterator shark::blas::matrix< T, L >::column_begin ( std::size_t  j) const
inline

Definition at line 268 of file matrix.hpp.

§ column_begin() [2/2]

template<class T, class L = row_major>
column_iterator shark::blas::matrix< T, L >::column_begin ( std::size_t  j)
inline

Definition at line 274 of file matrix.hpp.

§ column_end() [1/2]

template<class T, class L = row_major>
const_column_iterator shark::blas::matrix< T, L >::column_end ( std::size_t  j) const
inline

Definition at line 271 of file matrix.hpp.

§ column_end() [2/2]

template<class T, class L = row_major>
column_iterator shark::blas::matrix< T, L >::column_end ( std::size_t  j)
inline

Definition at line 277 of file matrix.hpp.

§ operator()() [1/2]

template<class T, class L = row_major>
const_reference shark::blas::matrix< T, L >::operator() ( index_type  i,
index_type  j 
) const
inline

Definition at line 180 of file matrix.hpp.

§ operator()() [2/2]

template<class T, class L = row_major>
reference shark::blas::matrix< T, L >::operator() ( index_type  i,
index_type  j 
)
inline

Definition at line 183 of file matrix.hpp.

§ operator=() [1/3]

template<class T, class L = row_major>
matrix& shark::blas::matrix< T, L >::operator= ( matrix< T, L >  m)
inline
Note
"pass by value" the key idea to enable move semantics

Definition at line 193 of file matrix.hpp.

§ operator=() [2/3]

template<class T, class L = row_major>
template<class C >
matrix& shark::blas::matrix< T, L >::operator= ( matrix_container< C > const &  m)
inline

Definition at line 198 of file matrix.hpp.

§ operator=() [3/3]

template<class T, class L = row_major>
template<class E >
matrix& shark::blas::matrix< T, L >::operator= ( matrix_expression< E > const &  e)
inline

Definition at line 204 of file matrix.hpp.

§ reserve()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::reserve ( size_type  non_zeros)
inline

Definition at line 300 of file matrix.hpp.

§ reserve_column()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::reserve_column ( std::size_t  ,
std::size_t   
)
inline

Definition at line 302 of file matrix.hpp.

§ reserve_row()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::reserve_row ( std::size_t  ,
std::size_t   
)
inline

Definition at line 301 of file matrix.hpp.

§ resize()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::resize ( size_type  size1,
size_type  size2 
)
inline

Resize a matrix to new dimensions. If resizing is performed, the data is not preserved.

Parameters
size1the new number of rows
size2the new number of colums

Definition at line 169 of file matrix.hpp.

Referenced by shark::blas::matrix< double, blas::column_major >::operator=(), and shark::PartlyPrecomputedMatrix< Matrix >::PartlyPrecomputedMatrix().

§ row_begin() [1/2]

template<class T, class L = row_major>
const_row_iterator shark::blas::matrix< T, L >::row_begin ( index_type  i) const
inline

Definition at line 255 of file matrix.hpp.

§ row_begin() [2/2]

template<class T, class L = row_major>
row_iterator shark::blas::matrix< T, L >::row_begin ( index_type  i)
inline

Definition at line 261 of file matrix.hpp.

§ row_end() [1/2]

template<class T, class L = row_major>
const_row_iterator shark::blas::matrix< T, L >::row_end ( index_type  i) const
inline

Definition at line 258 of file matrix.hpp.

§ row_end() [2/2]

template<class T, class L = row_major>
row_iterator shark::blas::matrix< T, L >::row_end ( index_type  i)
inline

Definition at line 264 of file matrix.hpp.

§ serialize()

template<class T, class L = row_major>
template<class Archive >
void shark::blas::matrix< T, L >::serialize ( Archive &  ar,
const unsigned  int 
)
inline

Definition at line 306 of file matrix.hpp.

§ set_element() [1/2]

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::set_element ( size_type  i,
size_type  j,
value_type  t 
)
inline

Definition at line 187 of file matrix.hpp.

§ set_element() [2/2]

template<class T, class L = row_major>
major_iterator shark::blas::matrix< T, L >::set_element ( major_iterator  pos,
index_type  index,
value_type  value 
)
inline

Definition at line 284 of file matrix.hpp.

§ size1()

§ size2()

§ storage() [1/2]

template<class T, class L = row_major>
const_pointer shark::blas::matrix< T, L >::storage ( ) const
inline

Returns the pointer to the beginning of the matrix storage.

Grants low-level access to the matrix internals. Element order depends on whether the matrix is row_major or column_major. to access element (i,j) use storage()[i*stride1()+j*stride2()].

Definition at line 148 of file matrix.hpp.

§ storage() [2/2]

template<class T, class L = row_major>
pointer shark::blas::matrix< T, L >::storage ( )
inline

Returns the pointer to the beginning of the matrix storage.

Grants low-level access to the matrix internals. Element order depends on whether the matrix is row_major or column_major. to access element (i,j) use storage()[i*stride1()+j*stride2()].

Definition at line 156 of file matrix.hpp.

§ stride1()

template<class T, class L = row_major>
difference_type shark::blas::matrix< T, L >::stride1 ( ) const
inline

§ stride2()

template<class T, class L = row_major>
difference_type shark::blas::matrix< T, L >::stride2 ( ) const
inline

§ swap()

template<class T, class L = row_major>
void shark::blas::matrix< T, L >::swap ( matrix< T, L > &  m)
inline

Friends And Related Function Documentation

§ swap

template<class T, class L = row_major>
void swap ( matrix< T, L > &  m1,
matrix< T, L > &  m2 
)
friend

Definition at line 216 of file matrix.hpp.

§ swap_columns [1/2]

template<class T, class L = row_major>
void swap_columns ( matrix< T, L > &  a,
index_type  i,
matrix< T, L > &  b,
index_type  j 
)
friend

Definition at line 235 of file matrix.hpp.

§ swap_columns [2/2]

template<class T, class L = row_major>
void swap_columns ( matrix< T, L > &  a,
index_type  i,
index_type  j 
)
friend

Definition at line 244 of file matrix.hpp.

§ swap_rows [1/2]

template<class T, class L = row_major>
void swap_rows ( matrix< T, L > &  a,
index_type  i,
matrix< T, L > &  b,
index_type  j 
)
friend

Definition at line 220 of file matrix.hpp.

§ swap_rows [2/2]

template<class T, class L = row_major>
void swap_rows ( matrix< T, L > &  a,
index_type  i,
index_type  j 
)
friend

Definition at line 229 of file matrix.hpp.


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