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

A dense matrix of values of type T stored on the gpu. More...

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

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

Public Types

typedef value_type const_reference
 
typedef value_type reference
 
typedef elementwise< dense_tag > evaluation_category
 
typedef L orientation
 
typedef boost::compute::strided_iterator< typename boost::compute::vector< T >::iterator > row_iterator
 
typedef boost::compute::strided_iterator< typename boost::compute::vector< T >::iterator > column_iterator
 
typedef boost::compute::strided_iterator< typename boost::compute::vector< T >::const_iterator > const_row_iterator
 
typedef boost::compute::strided_iterator< typename boost::compute::vector< T >::const_iterator > const_column_iterator
 

Public Member Functions

 matrix (boost::compute::command_queue &queue=boost::compute::system::default_queue())
 Constructor of a matrix with a default queue. More...
 
 matrix (size_type size1, size_type size2, boost::compute::command_queue &queue=boost::compute::system::default_queue())
 Constructor of a matrix with a predefined size By default, its elements are uninitialized. More...
 
 matrix (size_type size1, size_type size2, value_type const &init, boost::compute::command_queue &queue=boost::compute::system::default_queue())
 Constructor of a matrix with a predefined size initialized to a value. More...
 
 matrix (matrix &&m)
 Move-constructor of a matrix. More...
 
 matrix (matrix const &m)
 Copy-constructor of a matrix. More...
 
template<class E >
 matrix (matrix_expression< E, gpu_tag > const &e)
 Copy-constructor of a matrix from a matrix_expression. More...
 
matrixoperator= (matrix const &m)
 Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix) Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix). This method does not create any temporary. More...
 
matrixoperator= (matrix &&m)
 Move-Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix) More...
 
template<class C >
matrixoperator= (matrix_container< C, gpu_tag > const &m)
 Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix) Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix). This method does not create any temporary. More...
 
template<class E >
matrixoperator= (matrix_expression< E, gpu_tag > const &e)
 Assign the result of a matrix_expression to the matrix. 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...
 
boost::compute::command_queue & queue () const
 
const_storage_type raw_storage () const
 Returns the underlying storage structure for low level access. More...
 
storage_type raw_storage ()
 Returns the underlying storage structure for low level access. More...
 
template<class IndexExpr1 , class IndexExpr2 >
detail::induced_matrix_element< IndexExpr1, IndexExpr2, T > operator() (IndexExpr1 const &i, IndexExpr2 const &j) const
 
void resize (size_type size1, size_type size2)
 Resize the matrix. More...
 
void resize (size_type size1, size_type size2, value_type init)
 Resize the matrix. More...
 
void clear ()
 
const_row_iterator row_begin (size_type i) const
 
const_row_iterator row_end (size_type i) const
 
const_row_iterator column_begin (size_type j) const
 
const_column_iterator column_end (size_type j) const
 
row_iterator row_begin (size_type i)
 
row_iterator row_end (size_type i)
 
row_iterator column_begin (size_type j)
 
column_iterator column_end (size_type j)
 
- Public Member Functions inherited from remora::matrix_container< matrix< T, L, gpu_tag >, gpu_tag >
const container_type & operator() () const
 
container_type & operator() ()
 
- Public Member Functions inherited from remora::matrix_expression< matrix< T, L, gpu_tag >, gpu_tag >
const expression_type & operator() () const
 
expression_type & operator() ()
 

Friends

void swap (matrix &m1, matrix &m2)
 Swap the content of two matrixs. More...
 

Detailed Description

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

A dense matrix of values of type T stored on the gpu.

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

Member Typedef Documentation

◆ column_iterator

template<class T , class L >
typedef boost::compute::strided_iterator<typename boost::compute::vector<T>::iterator > remora::matrix< T, L, gpu_tag >::column_iterator

Definition at line 271 of file matrix.hpp.

◆ const_column_iterator

template<class T , class L >
typedef boost::compute::strided_iterator<typename boost::compute::vector<T>::const_iterator > remora::matrix< T, L, gpu_tag >::const_column_iterator

Definition at line 273 of file matrix.hpp.

◆ const_reference

template<class T , class L >
typedef value_type remora::matrix< T, L, gpu_tag >::const_reference

Definition at line 89 of file matrix.hpp.

◆ const_row_iterator

template<class T , class L >
typedef boost::compute::strided_iterator<typename boost::compute::vector<T>::const_iterator > remora::matrix< T, L, gpu_tag >::const_row_iterator

Definition at line 272 of file matrix.hpp.

◆ evaluation_category

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

Definition at line 97 of file matrix.hpp.

◆ orientation

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

Definition at line 98 of file matrix.hpp.

◆ reference

template<class T , class L >
typedef value_type remora::matrix< T, L, gpu_tag >::reference

Definition at line 90 of file matrix.hpp.

◆ row_iterator

template<class T , class L >
typedef boost::compute::strided_iterator<typename boost::compute::vector<T>::iterator > remora::matrix< T, L, gpu_tag >::row_iterator

Definition at line 270 of file matrix.hpp.

Constructor & Destructor Documentation

◆ matrix() [1/6]

template<class T , class L >
remora::matrix< T, L, gpu_tag >::matrix ( boost::compute::command_queue &  queue = boost::compute::system::default_queue())
inline

Constructor of a matrix with a default queue.

note that for all operations for which matrix is on the left hand side, the kernels are enqueued on the supplied queue in case of a multi-queue setup.

Definition at line 106 of file matrix.hpp.

◆ matrix() [2/6]

template<class T , class L >
remora::matrix< T, L, gpu_tag >::matrix ( size_type  size1,
size_type  size2,
boost::compute::command_queue &  queue = boost::compute::system::default_queue() 
)
inlineexplicit

Constructor of a matrix with a predefined size By default, its elements are uninitialized.

Parameters
size1number of rows
size2number of columns
queuethe opencl queue to use by this matrix

Definition at line 115 of file matrix.hpp.

◆ matrix() [3/6]

template<class T , class L >
remora::matrix< T, L, gpu_tag >::matrix ( size_type  size1,
size_type  size2,
value_type const &  init,
boost::compute::command_queue &  queue = boost::compute::system::default_queue() 
)
inline

Constructor of a matrix with a predefined size initialized to a value.

Parameters
size1number of rows
size2number of columns
initvalue to assign to each element of the matrix
queuethe opencl queue to use by this matrix

Definition at line 126 of file matrix.hpp.

◆ matrix() [4/6]

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

Move-constructor of a matrix.

Parameters
mis the matrix to be moved

Definition at line 134 of file matrix.hpp.

◆ matrix() [5/6]

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

Copy-constructor of a matrix.

Parameters
mis the matrix to be duplicated

Definition at line 142 of file matrix.hpp.

◆ matrix() [6/6]

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

Copy-constructor of a matrix from a matrix_expression.

Parameters
ethe matrix_expression whose values will be duplicated into the matrix

Definition at line 151 of file matrix.hpp.

References remora::detail::assign().

Member Function Documentation

◆ clear()

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

Definition at line 265 of file matrix.hpp.

◆ column_begin() [1/2]

template<class T , class L >
const_row_iterator remora::matrix< T, L, gpu_tag >::column_begin ( size_type  j) const
inline

Definition at line 282 of file matrix.hpp.

◆ column_begin() [2/2]

template<class T , class L >
row_iterator remora::matrix< T, L, gpu_tag >::column_begin ( size_type  j)
inline

Definition at line 296 of file matrix.hpp.

◆ column_end() [1/2]

template<class T , class L >
const_column_iterator remora::matrix< T, L, gpu_tag >::column_end ( size_type  j) const
inline

Definition at line 285 of file matrix.hpp.

◆ column_end() [2/2]

template<class T , class L >
column_iterator remora::matrix< T, L, gpu_tag >::column_end ( size_type  j)
inline

Definition at line 299 of file matrix.hpp.

◆ operator()()

template<class T , class L >
template<class IndexExpr1 , class IndexExpr2 >
detail::induced_matrix_element<IndexExpr1,IndexExpr2,T> remora::matrix< T, L, gpu_tag >::operator() ( IndexExpr1 const &  i,
IndexExpr2 const &  j 
) const
inline

Definition at line 232 of file matrix.hpp.

◆ operator=() [1/4]

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

Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix) Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix). This method does not create any temporary.

Parameters
mis the source matrix container
Returns
a reference to a matrix (i.e. the destination matrix)

Definition at line 167 of file matrix.hpp.

References remora::detail::assign().

◆ operator=() [2/4]

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

Move-Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix)

Parameters
mis the source matrix container
Returns
a reference to a matrix (i.e. the destination matrix)

Definition at line 175 of file matrix.hpp.

◆ operator=() [3/4]

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

Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix) Assign a full matrix (RHS-matrix) to the current matrix (LHS-matrix). This method does not create any temporary.

Parameters
mis the source matrix container
Returns
a reference to a matrix (i.e. the destination matrix)

Definition at line 188 of file matrix.hpp.

References remora::detail::assign().

◆ operator=() [4/4]

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

Assign the result of a matrix_expression to the matrix.

Parameters
eis a const reference to the matrix_expression
Returns
a reference to the resulting matrix

Definition at line 198 of file matrix.hpp.

References shark::swap().

◆ queue()

template<class T , class L >
boost::compute::command_queue& remora::matrix< T, L, gpu_tag >::queue ( ) const
inline

Definition at line 217 of file matrix.hpp.

◆ raw_storage() [1/2]

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

Returns the underlying storage structure for low level access.

Definition at line 221 of file matrix.hpp.

◆ raw_storage() [2/2]

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

Returns the underlying storage structure for low level access.

Definition at line 226 of file matrix.hpp.

◆ resize() [1/2]

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

Resize the matrix.

This might erase all data stored in the matrix

Parameters
size1new number of rows
size2new number of columns

Definition at line 243 of file matrix.hpp.

◆ resize() [2/2]

template<class T , class L >
void remora::matrix< T, L, gpu_tag >::resize ( size_type  size1,
size_type  size2,
value_type  init 
)
inline

Resize the matrix.

This will erase all data stored in the matrix and reinitialize it with the supplied value of init

Parameters
size1new number of rows
size2new number of columns
initthe value of all elements

Definition at line 260 of file matrix.hpp.

◆ row_begin() [1/2]

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

Definition at line 275 of file matrix.hpp.

◆ row_begin() [2/2]

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

Definition at line 289 of file matrix.hpp.

◆ row_end() [1/2]

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

Definition at line 278 of file matrix.hpp.

◆ row_end() [2/2]

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

Definition at line 292 of file matrix.hpp.

◆ size1()

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

Returns the number of rows of the matrix.

Definition at line 209 of file matrix.hpp.

◆ size2()

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

Returns the number of columns of the matrix.

Definition at line 213 of file matrix.hpp.

Friends And Related Function Documentation

◆ swap

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

Swap the content of two matrixs.

Parameters
m1is the first matrix. It takes values from m2
m2is the second matrix It takes values from m1

Definition at line 307 of file matrix.hpp.


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