ViennaCL - The Vienna Computing Library
1.5.2
|
A dense matrix class. More...
#include <matrix.hpp>
Public Types | |
typedef matrix_iterator < row_iteration, self_type > | iterator1 |
typedef matrix_iterator < col_iteration, self_type > | iterator2 |
typedef scalar< SCALARTYPE > | value_type |
typedef SCALARTYPE | cpu_value_type |
typedef SizeType | size_type |
typedef DistanceType | difference_type |
typedef viennacl::backend::mem_handle | handle_type |
typedef F | orientation_functor |
typedef F::orientation_category | orientation_category |
Public Member Functions | |
matrix_base () | |
The default constructor. Does not allocate any memory. | |
matrix_base (size_type rows, size_type columns, viennacl::context ctx=viennacl::context()) | |
Creates the matrix with the given dimensions. | |
matrix_base (viennacl::backend::mem_handle &h, size_type mat_size1, size_type mat_start1, difference_type mat_stride1, size_type mat_internal_size1, size_type mat_size2, size_type mat_start2, difference_type mat_stride2, size_type mat_internal_size2) | |
Constructor for creating a matrix_range or matrix_stride from some other matrix/matrix_range/matrix_stride. | |
template<typename LHS , typename RHS , typename OP > | |
matrix_base (matrix_expression< const LHS, const RHS, OP > const &proxy) | |
matrix_base (SCALARTYPE *ptr_to_mem, viennacl::memory_types mem_type, size_type mat_size1, size_type mat_start1, difference_type mat_stride1, size_type mat_internal_size1, size_type mat_size2, size_type mat_start2, difference_type mat_stride2, size_type mat_internal_size2) | |
self_type & | operator= (const self_type &other) |
template<typename LHS , typename RHS , typename OP > | |
self_type & | operator= (const matrix_expression< const LHS, const RHS, OP > &proxy) |
Creates the matrix from the supplied random matrix. | |
self_type & | operator= (const matrix_expression< const self_type, const self_type, op_trans > &proxy) |
template<typename LHS , typename RHS , typename OP > | |
self_type & | operator+= (const matrix_expression< const LHS, const RHS, OP > &proxy) |
template<typename LHS , typename RHS , typename OP > | |
self_type & | operator-= (const matrix_expression< const LHS, const RHS, OP > &proxy) |
self_type & | operator= (identity_matrix< SCALARTYPE > const &m) |
Assigns the supplied identity matrix to the matrix. | |
self_type & | operator= (zero_matrix< SCALARTYPE > const &m) |
Assigns the supplied zero matrix to the matrix. | |
self_type & | operator= (scalar_matrix< SCALARTYPE > const &m) |
Assigns the supplied scalar vector to the matrix. | |
entry_proxy< SCALARTYPE > | operator() (size_type row_index, size_type col_index) |
Read-write access to a single element of the matrix/matrix_range/matrix_slice. | |
const_entry_proxy< SCALARTYPE > | operator() (size_type row_index, size_type col_index) const |
Read access to a single element of the matrix/matrix_range/matrix_slice. | |
self_type & | operator+= (const self_type &other) |
self_type & | operator-= (const self_type &other) |
self_type & | operator*= (SCALARTYPE val) |
Scales a matrix by a CPU scalar value. | |
self_type & | operator/= (SCALARTYPE val) |
Scales this matrix by a CPU scalar value. | |
matrix_expression< const self_type, const SCALARTYPE, op_mult > | operator- () const |
Sign flip for the matrix. Emulated to be equivalent to -1.0 * matrix. | |
size_type | size1 () const |
Returns the number of rows. | |
size_type | size2 () const |
Returns the number of columns. | |
size_type | start1 () const |
Returns the number of rows. | |
size_type | start2 () const |
Returns the number of columns. | |
size_type | stride1 () const |
Returns the number of rows. | |
size_type | stride2 () const |
Returns the number of columns. | |
void | clear () |
Resets all entries to zero. | |
size_type | internal_size1 () const |
Returns the internal number of rows. Usually required for launching OpenCL kernels only. | |
size_type | internal_size2 () const |
Returns the internal number of columns. Usually required for launching OpenCL kernels only. | |
size_type | internal_size () const |
Returns the total amount of allocated memory in multiples of sizeof(SCALARTYPE) | |
handle_type & | handle () |
Returns the OpenCL handle, non-const-version. | |
const handle_type & | handle () const |
Returns the OpenCL handle, const-version. | |
viennacl::memory_types | memory_domain () const |
Static Public Attributes | |
static const size_type | alignment = 128 |
Protected Member Functions | |
void | set_handle (viennacl::backend::mem_handle const &h) |
void | switch_memory_context (viennacl::context new_ctx) |
void | resize (size_type rows, size_type columns, bool preserve=true) |
Resizes the matrix. Existing entries can be preserved, but. |
A dense matrix class.
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. |
typedef SCALARTYPE cpu_value_type |
Reimplemented in matrix_slice< MatrixType >, and matrix_range< MatrixType >.
typedef DistanceType difference_type |
Reimplemented in matrix_slice< MatrixType >, and matrix_range< MatrixType >.
typedef matrix_iterator<row_iteration, self_type > iterator1 |
typedef matrix_iterator<col_iteration, self_type > iterator2 |
typedef F::orientation_category orientation_category |
Reimplemented in matrix_slice< MatrixType >, and matrix_range< MatrixType >.
typedef F orientation_functor |
typedef SizeType size_type |
Reimplemented in matrix< SCALARTYPE, F, ALIGNMENT >, matrix_slice< MatrixType >, and matrix_range< MatrixType >.
typedef scalar<SCALARTYPE> value_type |
Reimplemented in matrix_slice< MatrixType >, and matrix_range< MatrixType >.
matrix_base | ( | ) | [inline, explicit] |
The default constructor. Does not allocate any memory.
matrix_base | ( | size_type | rows, |
size_type | columns, | ||
viennacl::context | ctx = viennacl::context() |
||
) | [inline, explicit] |
Creates the matrix with the given dimensions.
rows | Number of rows |
columns | Number of columns |
ctx | Optional context in which the matrix is created (one out of multiple OpenCL contexts, CUDA, host) |
matrix_base | ( | viennacl::backend::mem_handle & | h, |
size_type | mat_size1, | ||
size_type | mat_start1, | ||
difference_type | mat_stride1, | ||
size_type | mat_internal_size1, | ||
size_type | mat_size2, | ||
size_type | mat_start2, | ||
difference_type | mat_stride2, | ||
size_type | mat_internal_size2 | ||
) | [inline, explicit] |
Constructor for creating a matrix_range or matrix_stride from some other matrix/matrix_range/matrix_stride.
matrix_base | ( | matrix_expression< const LHS, const RHS, OP > const & | proxy | ) | [inline, explicit] |
matrix_base | ( | SCALARTYPE * | ptr_to_mem, |
viennacl::memory_types | mem_type, | ||
size_type | mat_size1, | ||
size_type | mat_start1, | ||
difference_type | mat_stride1, | ||
size_type | mat_internal_size1, | ||
size_type | mat_size2, | ||
size_type | mat_start2, | ||
difference_type | mat_stride2, | ||
size_type | mat_internal_size2 | ||
) | [inline, explicit] |
void clear | ( | ) | [inline] |
Resets all entries to zero.
handle_type& handle | ( | ) | [inline] |
Returns the OpenCL handle, non-const-version.
const handle_type& handle | ( | ) | const [inline] |
Returns the OpenCL handle, const-version.
size_type internal_size | ( | ) | const [inline] |
Returns the total amount of allocated memory in multiples of sizeof(SCALARTYPE)
size_type internal_size1 | ( | ) | const [inline] |
Returns the internal number of rows. Usually required for launching OpenCL kernels only.
size_type internal_size2 | ( | ) | const [inline] |
Returns the internal number of columns. Usually required for launching OpenCL kernels only.
viennacl::memory_types memory_domain | ( | ) | const [inline] |
entry_proxy<SCALARTYPE> operator() | ( | size_type | row_index, |
size_type | col_index | ||
) | [inline] |
Read-write access to a single element of the matrix/matrix_range/matrix_slice.
const_entry_proxy<SCALARTYPE> operator() | ( | size_type | row_index, |
size_type | col_index | ||
) | const [inline] |
Read access to a single element of the matrix/matrix_range/matrix_slice.
self_type& operator*= | ( | SCALARTYPE | val | ) | [inline] |
Scales a matrix by a CPU scalar value.
self_type& operator+= | ( | const matrix_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
matrix_expression<const self_type, const SCALARTYPE, op_mult> operator- | ( | ) | const [inline] |
Sign flip for the matrix. Emulated to be equivalent to -1.0 * matrix.
self_type& operator-= | ( | const matrix_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
self_type& operator/= | ( | SCALARTYPE | val | ) | [inline] |
Scales this matrix by a CPU scalar value.
self_type& operator= | ( | const matrix_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
Creates the matrix from the supplied random matrix.
Implementation of the operation m1 = m2 @ alpha, where @ denotes either multiplication or division, and alpha is either a CPU or a GPU scalar
proxy | An expression template proxy class. |
self_type& operator= | ( | const matrix_expression< const self_type, const self_type, op_trans > & | proxy | ) | [inline] |
self_type& operator= | ( | identity_matrix< SCALARTYPE > const & | m | ) | [inline] |
Assigns the supplied identity matrix to the matrix.
self_type& operator= | ( | zero_matrix< SCALARTYPE > const & | m | ) | [inline] |
Assigns the supplied zero matrix to the matrix.
self_type& operator= | ( | scalar_matrix< SCALARTYPE > const & | m | ) | [inline] |
Assigns the supplied scalar vector to the matrix.
Resizes the matrix. Existing entries can be preserved, but.
rows | New number of rows |
columns | New number of columns |
preserve | If true, existing values are preserved. |
Reimplemented in matrix< SCALARTYPE, F, ALIGNMENT >.
void set_handle | ( | viennacl::backend::mem_handle const & | h | ) | [inline, protected] |
void switch_memory_context | ( | viennacl::context | new_ctx | ) | [inline, protected] |