remora::matrix< T, L, cpu_tag > Class Template Reference

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

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

+ Inheritance diagram for remora::matrix< T, L, cpu_tag >:

Public Types

typedef array_type::const_reference const_reference
 
typedef array_type::reference reference
 
typedef elementwise< dense_tag > evaluation_category
 
typedef L orientation
 
typedef iterators::dense_storage_iterator< value_type > row_iterator
 
typedef iterators::dense_storage_iterator< value_type > column_iterator
 
typedef iterators::dense_storage_iterator< value_type const > const_row_iterator
 
typedef iterators::dense_storage_iterator< value_type const > const_column_iterator
 
typedef 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 (std::initializer_list< std::initializer_list< T > > list)
 Constructor from a nested initializer list. More...
 
 matrix (size_type size1, size_type size2)
 Dense matrix constructor with defined size. More...
 
 matrix (size_type size1, size_type size2, value_type const &init)
 Dense matrix constructor with defined size a initial value for all the matrix elements. More...
 
 matrix (matrix const &m)=default
 Copy-constructor of a dense matrix. More...
 
 matrix (matrix &&m)
 Move-constructor of a dense matrix. More...
 
template<class E >
 matrix (matrix_expression< E, cpu_tag > const &e)
 Constructor of a dense matrix from a matrix expression. More...
 
matrixoperator= (matrix const &m)=default
 Assigns m to this. More...
 
matrixoperator= (matrix &&m)
 Move-Assigns m to this. More...
 
template<class C >
matrixoperator= (matrix_container< C, cpu_tag > const &m)
 Assigns m to this. More...
 
template<class E >
matrixoperator= (matrix_expression< E, cpu_tag > const &e)
 Assigns e to this. More...
 
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...
 
storage_type raw_storage ()
 Returns the underlying storage structure for low level access. More...
 
const_storage_type raw_storage () const
 Returns the underlying storage structure for low level access. More...
 
device_traits< cpu_tag >::queue_type & queue ()
 
void resize (size_type size1, size_type size2)
 Resize a matrix to new dimensions. If resizing is performed, the data is not preserved. More...
 
void clear ()
 
const_reference operator() (size_type i, size_type j) const
 
reference operator() (size_type i, size_type j)
 
void set_element (size_type i, size_type j, value_type t)
 
void swap (matrix &m)
 
void swap_rows (size_type i, size_type j)
 
void swap_columns (size_type i, size_type j)
 
const_row_iterator row_begin (size_type i) const
 
const_row_iterator row_end (size_type i) const
 
row_iterator row_begin (size_type i)
 
row_iterator row_end (size_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, size_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 remora::matrix_container< matrix< T, L, cpu_tag >, cpu_tag >
const container_type & operator() () const
 
container_type & operator() ()
 
- Public Member Functions inherited from remora::matrix_expression< matrix< T, L, cpu_tag >, cpu_tag >
const expression_type & operator() () const
 
expression_type & operator() ()
 

Friends

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

Detailed Description

template<class T, class L>
class remora::matrix< T, L, cpu_tag >

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 53 of file matrix.hpp.

Member Typedef Documentation

◆ column_iterator

template<class T , class L >
typedef iterators::dense_storage_iterator<value_type> remora::matrix< T, L, cpu_tag >::column_iterator

Definition at line 274 of file matrix.hpp.

◆ const_column_iterator

template<class T , class L >
typedef iterators::dense_storage_iterator<value_type const> remora::matrix< T, L, cpu_tag >::const_column_iterator

Definition at line 276 of file matrix.hpp.

◆ const_reference

template<class T , class L >
typedef array_type::const_reference remora::matrix< T, L, cpu_tag >::const_reference

Definition at line 58 of file matrix.hpp.

◆ const_row_iterator

template<class T , class L >
typedef iterators::dense_storage_iterator<value_type const> remora::matrix< T, L, cpu_tag >::const_row_iterator

Definition at line 275 of file matrix.hpp.

◆ evaluation_category

template<class T , class L >
typedef elementwise<dense_tag> remora::matrix< T, L, cpu_tag >::evaluation_category

Definition at line 66 of file matrix.hpp.

◆ major_iterator

template<class T , class L >
typedef major_iterator<self_type>::type remora::matrix< T, L, cpu_tag >::major_iterator

Definition at line 304 of file matrix.hpp.

◆ orientation

template<class T , class L >
typedef L remora::matrix< T, L, cpu_tag >::orientation

Definition at line 67 of file matrix.hpp.

◆ reference

template<class T , class L >
typedef array_type::reference remora::matrix< T, L, cpu_tag >::reference

Definition at line 59 of file matrix.hpp.

◆ row_iterator

template<class T , class L >
typedef iterators::dense_storage_iterator<value_type> remora::matrix< T, L, cpu_tag >::row_iterator

Definition at line 273 of file matrix.hpp.

Constructor & Destructor Documentation

◆ matrix() [1/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( )
inline

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

Definition at line 72 of file matrix.hpp.

◆ matrix() [2/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( std::initializer_list< std::initializer_list< T > >  list)
inline

Constructor from a nested initializer list.

Constructs a matrix like this: m = {{1,2},{3,4}}.

Parameters
listThe nested initializer list storing the values of the matrix.

Definition at line 78 of file matrix.hpp.

◆ matrix() [3/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( size_type  size1,
size_type  size2 
)
inline

Dense matrix constructor with defined size.

Parameters
size1number of rows
size2number of columns

Definition at line 92 of file matrix.hpp.

◆ matrix() [4/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( size_type  size1,
size_type  size2,
value_type const &  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 101 of file matrix.hpp.

◆ matrix() [5/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( matrix< T, L, cpu_tag > const &  m)
default

Copy-constructor of a dense matrix.

Parameters
mis a dense matrix

◆ matrix() [6/7]

template<class T , class L >
remora::matrix< T, L, cpu_tag >::matrix ( matrix< T, L, cpu_tag > &&  m)
inline

Move-constructor of a dense matrix.

Parameters
mis a dense matrix

Definition at line 113 of file matrix.hpp.

◆ matrix() [7/7]

template<class T , class L >
template<class E >
remora::matrix< T, L, cpu_tag >::matrix ( matrix_expression< E, cpu_tag > const &  e)
inline

Constructor of a dense matrix from a matrix expression.

Constructs the matrix by evaluating the expression and assigning the results to the newly constructed matrix using a call to assign.

Parameters
eis a matrix expression

Definition at line 122 of file matrix.hpp.

References remora::assign().

Member Function Documentation

◆ clear()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::clear ( )
inline

Definition at line 207 of file matrix.hpp.

◆ clear_element()

template<class T , class L >
major_iterator remora::matrix< T, L, cpu_tag >::clear_element ( major_iterator  elem)
inline

Definition at line 313 of file matrix.hpp.

◆ clear_range()

template<class T , class L >
major_iterator remora::matrix< T, L, cpu_tag >::clear_range ( major_iterator  start,
major_iterator  end 
)
inline

Definition at line 318 of file matrix.hpp.

◆ column_begin() [1/2]

template<class T , class L >
const_row_iterator remora::matrix< T, L, cpu_tag >::column_begin ( std::size_t  j) const
inline

Definition at line 291 of file matrix.hpp.

◆ column_begin() [2/2]

template<class T , class L >
column_iterator remora::matrix< T, L, cpu_tag >::column_begin ( std::size_t  j)
inline

Definition at line 297 of file matrix.hpp.

◆ column_end() [1/2]

template<class T , class L >
const_column_iterator remora::matrix< T, L, cpu_tag >::column_end ( std::size_t  j) const
inline

Definition at line 294 of file matrix.hpp.

◆ column_end() [2/2]

template<class T , class L >
column_iterator remora::matrix< T, L, cpu_tag >::column_end ( std::size_t  j)
inline

Definition at line 300 of file matrix.hpp.

◆ operator()() [1/2]

template<class T , class L >
const_reference remora::matrix< T, L, cpu_tag >::operator() ( size_type  i,
size_type  j 
) const
inline

Definition at line 212 of file matrix.hpp.

◆ operator()() [2/2]

template<class T , class L >
reference remora::matrix< T, L, cpu_tag >::operator() ( size_type  i,
size_type  j 
)
inline

Definition at line 217 of file matrix.hpp.

◆ operator=() [1/4]

template<class T , class L >
matrix& remora::matrix< T, L, cpu_tag >::operator= ( matrix< T, L, cpu_tag > const &  m)
default

Assigns m to this.

◆ operator=() [2/4]

template<class T , class L >
matrix& remora::matrix< T, L, cpu_tag >::operator= ( matrix< T, L, cpu_tag > &&  m)
inline

Move-Assigns m to this.

Definition at line 136 of file matrix.hpp.

◆ operator=() [3/4]

template<class T , class L >
template<class C >
matrix& remora::matrix< T, L, cpu_tag >::operator= ( matrix_container< C, cpu_tag > const &  m)
inline

Assigns m to this.

evaluates the expression and assign the results to this using a call to assign. As containers are assumed to not overlap, no temporary is created

Parameters
mis a matrix expression

Definition at line 152 of file matrix.hpp.

References remora::assign().

◆ operator=() [4/4]

template<class T , class L >
template<class E >
matrix& remora::matrix< T, L, cpu_tag >::operator= ( matrix_expression< E, cpu_tag > const &  e)
inline

Assigns e to this.

evaluates the expression and assign the results to this using a call to assign. A temporary is created to prevent aliasing.

Parameters
eis a matrix expression

Definition at line 165 of file matrix.hpp.

References shark::swap().

◆ queue()

template<class T , class L >
device_traits<cpu_tag>::queue_type& remora::matrix< T, L, cpu_tag >::queue ( )
inline

Definition at line 189 of file matrix.hpp.

◆ raw_storage() [1/2]

template<class T , class L >
storage_type remora::matrix< T, L, cpu_tag >::raw_storage ( )
inline

Returns the underlying storage structure for low level access.

Definition at line 181 of file matrix.hpp.

◆ raw_storage() [2/2]

template<class T , class L >
const_storage_type remora::matrix< T, L, cpu_tag >::raw_storage ( ) const
inline

Returns the underlying storage structure for low level access.

Definition at line 186 of file matrix.hpp.

◆ reserve()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::reserve ( size_type  non_zeros)
inline

Definition at line 323 of file matrix.hpp.

◆ reserve_column()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::reserve_column ( std::size_t  ,
std::size_t   
)
inline

Definition at line 325 of file matrix.hpp.

◆ reserve_row()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::reserve_row ( std::size_t  ,
std::size_t   
)
inline

Definition at line 324 of file matrix.hpp.

◆ resize()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::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 201 of file matrix.hpp.

◆ row_begin() [1/2]

template<class T , class L >
const_row_iterator remora::matrix< T, L, cpu_tag >::row_begin ( size_type  i) const
inline

Definition at line 278 of file matrix.hpp.

◆ row_begin() [2/2]

template<class T , class L >
row_iterator remora::matrix< T, L, cpu_tag >::row_begin ( size_type  i)
inline

Definition at line 284 of file matrix.hpp.

◆ row_end() [1/2]

template<class T , class L >
const_row_iterator remora::matrix< T, L, cpu_tag >::row_end ( size_type  i) const
inline

Definition at line 281 of file matrix.hpp.

◆ row_end() [2/2]

template<class T , class L >
row_iterator remora::matrix< T, L, cpu_tag >::row_end ( size_type  i)
inline

Definition at line 287 of file matrix.hpp.

◆ serialize()

template<class T , class L >
template<class Archive >
void remora::matrix< T, L, cpu_tag >::serialize ( Archive &  ar,
const unsigned  int 
)
inline

Definition at line 329 of file matrix.hpp.

◆ set_element() [1/2]

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::set_element ( size_type  i,
size_type  j,
value_type  t 
)
inline

Definition at line 223 of file matrix.hpp.

◆ set_element() [2/2]

template<class T , class L >
major_iterator remora::matrix< T, L, cpu_tag >::set_element ( major_iterator  pos,
size_type  index,
value_type  value 
)
inline

Definition at line 307 of file matrix.hpp.

◆ size1()

template<class T , class L >
size_type remora::matrix< T, L, cpu_tag >::size1 ( ) const
inline

Returns the number of rows of the matrix.

Definition at line 172 of file matrix.hpp.

◆ size2()

template<class T , class L >
size_type remora::matrix< T, L, cpu_tag >::size2 ( ) const
inline

Returns the number of columns of the matrix.

Definition at line 176 of file matrix.hpp.

◆ swap()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::swap ( matrix< T, L, cpu_tag > &  m)
inline

Definition at line 230 of file matrix.hpp.

References shark::swap().

◆ swap_columns()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::swap_columns ( size_type  i,
size_type  j 
)
inline

Definition at line 265 of file matrix.hpp.

References shark::swap().

◆ swap_rows()

template<class T , class L >
void remora::matrix< T, L, cpu_tag >::swap_rows ( size_type  i,
size_type  j 
)
inline

Definition at line 248 of file matrix.hpp.

References shark::swap().

Friends And Related Function Documentation

◆ swap

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

Definition at line 235 of file matrix.hpp.

◆ swap_columns

template<class T , class L >
void swap_columns ( matrix< T, L, cpu_tag > &  a,
size_type  i,
matrix< T, L, cpu_tag > &  b,
size_type  j 
)
friend

Definition at line 256 of file matrix.hpp.

◆ swap_rows

template<class T , class L >
void swap_rows ( matrix< T, L, cpu_tag > &  a,
size_type  i,
matrix< T, L, cpu_tag > &  b,
size_type  j 
)
friend

Definition at line 239 of file matrix.hpp.


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