1 #ifndef VIENNACL_DETAIL_MATRIX_DEF_HPP_
2 #define VIENNACL_DETAIL_MATRIX_DEF_HPP_
34 template<
typename NumericT>
50 const_reference
operator()(size_type i, size_type j)
const
68 template<
typename NumericT>
80 template<
typename NumericT>
92 template<
typename NumericT>
102 template<
class NumericT,
typename SizeT,
typename DistanceT>
117 explicit matrix_base(): size1_(0), size2_(0), start1_(0), start2_(0), stride1_(1), stride2_(1), internal_size1_(0), internal_size2_(0), row_major_fixed_(false), row_major_(true) {}
120 explicit matrix_base(
bool is_row_major) : size1_(0), size2_(0), start1_(0), start2_(0), stride1_(1), stride2_(1), internal_size1_(0), internal_size2_(0), row_major_fixed_(true), row_major_(is_row_major) {}
133 size_type mat_size1, size_type mat_start1, size_type mat_stride1, size_type mat_internal_size1,
134 size_type mat_size2, size_type mat_start2, size_type mat_stride2, size_type mat_internal_size2,
135 bool is_row_major): size1_(mat_size1), size2_(mat_size2),
136 start1_(mat_start1), start2_(mat_start2),
137 stride1_(mat_stride1), stride2_(mat_stride2),
138 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2),
139 row_major_fixed_(true), row_major_(is_row_major),
143 template<
typename LHS,
typename RHS,
typename OP>
148 size_type mat_size1, size_type mat_start1, size_type mat_stride1, size_type mat_internal_size1,
149 size_type mat_size2, size_type mat_start2, size_type mat_stride2, size_type mat_internal_size2,
152 #ifdef VIENNACL_WITH_OPENCL
155 size_type mat_size1, size_type mat_start1, size_type mat_stride1, size_type mat_internal_size1,
156 size_type mat_size2, size_type mat_start2, size_type mat_stride2, size_type mat_internal_size2,
164 template<
typename OtherNumericT>
167 self_type &
operator=(
const self_type & other);
168 template<
typename OtherNumericT>
173 template<
typename LHS,
typename RHS,
typename OP>
177 template<
typename LHS,
typename RHS,
typename OP>
179 template<
typename LHS,
typename RHS,
typename OP>
224 size_type
size1()
const {
return size1_;}
226 size_type
size2()
const {
return size2_; }
228 size_type
start1()
const {
return start1_;}
230 size_type
start2()
const {
return start2_; }
234 size_type
stride2()
const {
return stride2_; }
244 handle_type &
handle() {
return elements_; }
246 const handle_type &
handle()
const {
return elements_; }
253 void resize(size_type rows, size_type columns,
bool preserve =
true);
261 size_type internal_size1_;
262 size_type internal_size2_;
263 bool row_major_fixed_;
265 handle_type elements_;
const handle_type & handle() const
Returns the OpenCL handle, const-version.
viennacl::backend::mem_handle handle_type
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
size_type internal_size() const
Returns the total amount of allocated memory in multiples of sizeof(NumericT)
self_type & operator=(const self_type &other)
Helper class for checking whether a matrix has a row-major layout.
const_reference operator()(size_type i, size_type j) const
matrix_expression< const self_type, const NumericT, op_mult > operator-() const
Sign flip for the matrix. Emulated to be equivalent to -1.0 * matrix.
scalar_matrix(size_type s1, size_type s2, const_reference val, viennacl::context ctx=viennacl::context())
A proxy class for entries in a vector.
viennacl::context context() const
DistanceT difference_type
Expression template class for representing a tree of expressions which ultimately result in a matrix...
size_type stride2() const
Returns the number of columns.
This file provides the forward declarations for the main types used within ViennaCL.
entry_proxy< NumericT > operator()(size_type row_index, size_type col_index)
Read-write access to a single element of the matrix/matrix_range/matrix_slice.
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
viennacl::scalar< int > s2
viennacl::scalar< float > s1
viennacl::memory_types memory_domain() const
NumericT const & const_reference
NumericT const & const_reference
zero_matrix(size_type s1, size_type s2, viennacl::context ctx=viennacl::context())
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
matrix_base(bool is_row_major)
The layout constructor. Does not allocate any memory.
void switch_memory_context(viennacl::context new_ctx)
Base class for representing matrices where the individual entries are not all stored explicitly...
NumericT const & const_reference
matrix_base()
The default constructor. Does not allocate any memory.
matrix_iterator< col_iteration, self_type > iterator2
void clear()
Resets all entries to zero.
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
size_type stride1() const
Returns the number of rows.
NumericT const & const_reference
size_type size2() const
Returns the number of columns.
handle_type & handle()
Returns the OpenCL handle, non-const-version.
Represents a vector consisting of zeros only. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only.
size_type size1() const
Returns the number of rows.
void set_handle(viennacl::backend::mem_handle const &h)
scalar< NumericT > value_type
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
matrix_iterator< row_iteration, self_type > iterator1
size_type start2() const
Returns the number of columns.
identity_matrix(size_type s, viennacl::context ctx=viennacl::context())
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
self_type & operator*=(char val)
Scales the matrix by a char (8-bit integer)
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
self_type & operator+=(const matrix_expression< const LHS, const RHS, OP > &proxy)
self_type & operator/=(char val)
Scales the matrix by a char (8-bit integer)
void resize(size_type rows, size_type columns, bool preserve=true)
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
matrix_base(viennacl::backend::mem_handle &h, size_type mat_size1, size_type mat_start1, size_type mat_stride1, size_type mat_internal_size1, size_type mat_size2, size_type mat_start2, size_type mat_stride2, size_type mat_internal_size2, bool is_row_major)
Constructor for creating a matrix_range or matrix_stride from some other matrix/matrix_range/matrix_s...
implicit_matrix_base(size_type size1, size_type size2, NumericT value, bool diag, viennacl::context ctx)
size_type start1() const
Returns the number of rows.
self_type & operator-=(const matrix_expression< const LHS, const RHS, OP > &proxy)
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...