Public Types | Public Member Functions | Friends

matrix< SCALARTYPE, F, ALIGNMENT > Class Template Reference

A dense matrix class. More...

#include <matrix.hpp>

Public Types

typedef matrix_iterator
< row_iteration, matrix
< SCALARTYPE, F, ALIGNMENT > > 
iterator1
typedef matrix_iterator
< col_iteration, matrix
< SCALARTYPE, F, ALIGNMENT > > 
iterator2
typedef scalar< typename
viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT
< SCALARTYPE >::ResultType > 
value_type
typedef vcl_size_t size_type

Public Member Functions

 matrix ()
 The default constructor. Does not allocate any memory.
 matrix (size_type rows, size_type columns)
 Creates the matrix with the given dimensions.
 matrix (cl_mem mem, size_type rows, size_type columns)
template<typename LHS , typename RHS , typename OP >
 matrix (matrix_expression< LHS, RHS, OP > const &proxy)
 matrix (const matrix< SCALARTYPE, F, ALIGNMENT > &mat)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator= (const matrix< SCALARTYPE, F, ALIGNMENT > &mat)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator= (const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_trans > &proxy)
void resize (size_type rows, size_type columns, bool preserve=true)
 Resizes the matrix. Existing entries can be preserved, but.
entry_proxy< SCALARTYPE > operator() (size_type row_index, size_type col_index)
 Read-write access to a single element of the vector.
scalar< SCALARTYPE > operator() (size_type row_index, size_type col_index) const
 Read access to a single element of the vector.
matrix_expression< const
matrix< SCALARTYPE, F,
ALIGNMENT >, const matrix
< SCALARTYPE, F, ALIGNMENT >
, op_add > 
operator+ (const matrix< SCALARTYPE, F, ALIGNMENT > &other)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator+= (const matrix< SCALARTYPE, F, ALIGNMENT > &other)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator+= (const matrix_range< matrix< SCALARTYPE, F, ALIGNMENT > > &other)
matrix_expression< const
matrix< SCALARTYPE, F,
ALIGNMENT >, const matrix
< SCALARTYPE, F, ALIGNMENT >
, op_sub > 
operator- (const matrix< SCALARTYPE, F, ALIGNMENT > &other)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator-= (const matrix< SCALARTYPE, F, ALIGNMENT > &other)
template<unsigned int A1, unsigned int A2>
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator+= (const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod > &proxy)
template<unsigned int A1, unsigned int A2>
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator-= (const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod > &proxy)
template<unsigned int A1, unsigned int A2>
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator+= (const matrix_expression< const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod >, const SCALARTYPE, op_prod > &proxy)
template<unsigned int A1, unsigned int A2>
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator-= (const matrix_expression< const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod >, const SCALARTYPE, op_prod > &proxy)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator*= (SCALARTYPE val)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator*= (scalar< SCALARTYPE > const &val)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator/= (SCALARTYPE val)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator/= (scalar< SCALARTYPE > const &val)
template<typename MatrixType1 , typename MatrixType2 >
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator= (const matrix_expression< MatrixType1, MatrixType2, op_prod > &proxy)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator= (const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_add > &proxy)
matrix< SCALARTYPE, F,
ALIGNMENT > & 
operator= (const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_sub > &proxy)
const size_typesize1 () const
 Returns the number of rows.
const size_typesize2 () const
 Returns the number of columns.
void clear ()
 Resets all entries to zero.
const size_type internal_size1 () const
 Returns the internal number of rows. Usually required for launching OpenCL kernels only.
const size_type internal_size2 () const
 Returns the internal number of columns. Usually required for launching OpenCL kernels only.
const size_type internal_size () const
 Returns the total amount of allocated memory in multiples of sizeof(SCALARTYPE).
const viennacl::ocl::handle
< cl_mem > & 
handle () const
 Returns the OpenCL handle.

Friends

template<typename CPU_MATRIX , typename SCALARTYPE2 , typename F2 , unsigned int ALIGNMENT2>
void copy (const CPU_MATRIX &cpu_matrix, matrix< SCALARTYPE2, F2, ALIGNMENT2 > &gpu_matrix)
template<typename SCALARTYPE2 , typename A1 , typename A2 , typename F2 , unsigned int ALIGNMENT2>
void copy (const std::vector< std::vector< SCALARTYPE2, A1 >, A2 > &cpu_matrix, matrix< SCALARTYPE2, F2, ALIGNMENT2 > &gpu_matrix)
template<typename SCALARTYPE2 , typename F2 , unsigned int ALIGNMENT2>
void fast_copy (SCALARTYPE2 *cpu_matrix_begin, SCALARTYPE2 *cpu_matrix_end, matrix< SCALARTYPE2, F2, ALIGNMENT2 > &gpu_matrix)

Detailed Description

template<class SCALARTYPE, typename F, unsigned int ALIGNMENT>
class viennacl::matrix< SCALARTYPE, F, ALIGNMENT >

A dense matrix class.

Template Parameters:
SCALARTYPE The underlying scalar type (either float or double)
F Storage layout: Either row_major or column_major (at present only row_major is supported)
ALIGNMENT The internal memory size is given by (size()/ALIGNMENT + 1) * ALIGNMENT. ALIGNMENT must be a power of two. Best values or usually 4, 8 or 16, higher values are usually a waste of memory.

Member Typedef Documentation

typedef matrix_iterator<row_iteration, matrix<SCALARTYPE, F, ALIGNMENT> > iterator1
typedef matrix_iterator<col_iteration, matrix<SCALARTYPE, F, ALIGNMENT> > iterator2
typedef scalar<typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT<SCALARTYPE>::ResultType> value_type

Constructor & Destructor Documentation

matrix (  )  [inline]

The default constructor. Does not allocate any memory.

matrix ( size_type  rows,
size_type  columns 
) [inline, explicit]

Creates the matrix with the given dimensions.

Parameters:
rows Number of rows
columns Number of columns
matrix ( cl_mem  mem,
size_type  rows,
size_type  columns 
) [inline, explicit]
matrix ( matrix_expression< LHS, RHS, OP > const &  proxy  )  [inline]
matrix ( const matrix< SCALARTYPE, F, ALIGNMENT > &  mat  )  [inline]

Member Function Documentation

void clear (  )  [inline]

Resets all entries to zero.

const viennacl::ocl::handle<cl_mem>& handle (  )  const [inline]

Returns the OpenCL handle.

const size_type internal_size (  )  const [inline]

Returns the total amount of allocated memory in multiples of sizeof(SCALARTYPE).

const size_type internal_size1 (  )  const [inline]

Returns the internal number of rows. Usually required for launching OpenCL kernels only.

const size_type internal_size2 (  )  const [inline]

Returns the internal number of columns. Usually required for launching OpenCL kernels only.

scalar<SCALARTYPE> operator() ( size_type  row_index,
size_type  col_index 
) const [inline]

Read access to a single element of the vector.

entry_proxy<SCALARTYPE> operator() ( size_type  row_index,
size_type  col_index 
) [inline]

Read-write access to a single element of the vector.

matrix<SCALARTYPE, F, ALIGNMENT>& operator*= ( scalar< SCALARTYPE > const &  val  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator*= ( SCALARTYPE  val  )  [inline]
matrix_expression< const matrix<SCALARTYPE, F, ALIGNMENT>, const matrix<SCALARTYPE, F, ALIGNMENT>, op_add > operator+ ( const matrix< SCALARTYPE, F, ALIGNMENT > &  other  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator+= ( const matrix_range< matrix< SCALARTYPE, F, ALIGNMENT > > &  other  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator+= ( const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator+= ( const matrix_expression< const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod >, const SCALARTYPE, op_prod > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator+= ( const matrix< SCALARTYPE, F, ALIGNMENT > &  other  )  [inline]
matrix_expression< const matrix<SCALARTYPE, F, ALIGNMENT>, const matrix<SCALARTYPE, F, ALIGNMENT>, op_sub > operator- ( const matrix< SCALARTYPE, F, ALIGNMENT > &  other  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator-= ( const matrix< SCALARTYPE, F, ALIGNMENT > &  other  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator-= ( const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator-= ( const matrix_expression< const matrix_expression< const vector< SCALARTYPE, A1 >, const vector< SCALARTYPE, A2 >, op_prod >, const SCALARTYPE, op_prod > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator/= ( SCALARTYPE  val  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator/= ( scalar< SCALARTYPE > const &  val  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator= ( const matrix< SCALARTYPE, F, ALIGNMENT > &  mat  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator= ( const matrix_expression< MatrixType1, MatrixType2, op_prod > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator= ( const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_trans > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator= ( const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_sub > &  proxy  )  [inline]
matrix<SCALARTYPE, F, ALIGNMENT>& operator= ( const matrix_expression< const matrix< SCALARTYPE, F, ALIGNMENT >, const matrix< SCALARTYPE, F, ALIGNMENT >, op_add > &  proxy  )  [inline]
void resize ( size_type  rows,
size_type  columns,
bool  preserve = true 
) [inline]

Resizes the matrix. Existing entries can be preserved, but.

Parameters:
rows New number of rows
columns New number of columns
preserve If true, existing values are preserved.
const size_type& size1 (  )  const [inline]

Returns the number of rows.

const size_type& size2 (  )  const [inline]

Returns the number of columns.


Friends And Related Function Documentation

void copy ( const CPU_MATRIX &  cpu_matrix,
matrix< SCALARTYPE2, F2, ALIGNMENT2 > &  gpu_matrix 
) [friend]
void copy ( const std::vector< std::vector< SCALARTYPE2, A1 >, A2 > &  cpu_matrix,
matrix< SCALARTYPE2, F2, ALIGNMENT2 > &  gpu_matrix 
) [friend]
void fast_copy ( SCALARTYPE2 *  cpu_matrix_begin,
SCALARTYPE2 *  cpu_matrix_end,
matrix< SCALARTYPE2, F2, ALIGNMENT2 > &  gpu_matrix 
) [friend]

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