1 #ifndef VIENNACL_DETAIL_VECTOR_DEF_HPP_
2 #define VIENNACL_DETAIL_VECTOR_DEF_HPP_
35 template<
typename NumericT>
75 template<
typename NumericT>
80 assert( (ind < s) &&
bool(
"Provided index out of range!") );
86 template<
typename NumericT>
92 template<
typename NumericT>
103 template<
class NumericT,
typename SizeT ,
typename DistanceT >
126 bool empty()
const {
return size_ == 0; }
152 #ifdef VIENNACL_WITH_OPENCL
164 template<
typename LHS,
typename RHS,
typename OP>
171 template<
typename OtherNumericT>
176 self_type &
operator=(
const self_type & vec);
180 template<
typename LHS,
typename RHS,
typename OP>
183 template<
typename OtherNumericT>
298 self_type &
swap(self_type & other);
308 self_type &
fast_swap(self_type & other);
DistanceT difference_type
cpu_value_type value() const
A STL-type const-iterator for vector elements. Elements can be accessed, but cannot be manipulated...
vector_base()
Default constructor in order to be compatible with various containers.
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
vector_expression< const self_type, const NumericT, op_mult > operator*(char value) const
Scales the vector by a char (8-bit integer) 'alpha' and returns an expression template.
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
unit_vector(vcl_size_t s, vcl_size_t ind, viennacl::context ctx=viennacl::context())
void switch_memory_context(viennacl::context new_ctx)
entry_proxy< NumericT > operator[](size_type index)
Read-write access to a single element of the vector.
self_type & swap(self_type &other)
Swaps the entries of the two vectors.
A proxy class for entries in a vector.
NumericT const & const_reference
Expression template class for representing a tree of expressions which ultimately result in a matrix...
void pad()
Pads vectors with alignment > 1 with trailing zeros if the internal size is larger than the visible s...
cpu_value_type operator[](vcl_size_t i) const
This file provides the forward declarations for the main types used within ViennaCL.
vector_expression< const self_type, const NumericT, op_div > operator/(char value) const
Scales the vector by a char (8-bit integer) 'alpha' and returns an expression template.
self_type & operator-=(const self_type &vec)
An expression template class that represents a binary operation that yields a vector.
zero_vector(vcl_size_t s, viennacl::context ctx=viennacl::context())
viennacl::backend::mem_handle handle_type
void resize(size_type new_size, bool preserve=true)
Resizes the allocated memory for the vector. Pads the memory to be a multiple of 'AlignmentV'.
self_type & operator+=(const self_type &vec)
vector_expression< const self_type, const NumericT, op_mult > operator-() const
Sign flip for the vector. Emulated to be equivalent to -1.0 * vector.
entry_proxy< NumericT > operator()(size_type index)
Read-write access to a single element of the vector.
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
viennacl::context context() const
size_type stride() const
Returns the stride within the buffer (in multiples of sizeof(NumericT))
viennacl::vector< float > v1
iterator begin()
Returns an iterator pointing to the beginning of the vector (STL like)
scalar_vector(vcl_size_t s, NumericT val, viennacl::context ctx=viennacl::context())
scalar< NumericT > value_type
A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!!
vector_iterator< NumericT, 1 > iterator
Common base class for dense vectors, vector ranges, and vector slices.
self_type & operator=(const self_type &vec)
Assignment operator. Other vector needs to be of the same size, or this vector is not yet initialized...
bool empty() const
Returns true is the size is zero.
implicit_vector_base(vcl_size_t s, NumericT v, viennacl::context ctx)
handle_type & handle()
Returns the memory handle.
cpu_value_type operator()(vcl_size_t i) const
A tag class representing matrix-vector products and element-wise multiplications. ...
void clear()
Resets all entries to zero. Does not change the size of the vector.
self_type & operator/=(char val)
Scales a vector (or proxy) by a char (8-bit integer)
Represents a vector consisting of 1 at a given index and zeros otherwise.
implicit_vector_base(vcl_size_t s, vcl_size_t i, NumericT v, viennacl::context ctx)
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
std::pair< bool, vcl_size_t > index_
const_vector_iterator< NumericT, 1 > const_iterator
size_type size() const
Returns the length of the vector (cf. std::vector)
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
A tag class representing transposed matrices.
Common base class for representing vectors where the entries are not all stored explicitly.
size_type internal_size() const
Returns the internal length of the vector, which is given by size() plus the extra memory due to padd...
iterator end()
Returns an iterator pointing to the end of the vector (STL like)
size_type start() const
Returns the offset within the buffer.
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
void set_handle(viennacl::backend::mem_handle const &h)
self_type & operator*=(char val)
Scales a vector (or proxy) by a char (8-bit integer)
viennacl::memory_types memory_domain() const
const handle_type & handle() const
Returns the memory handle.
self_type & fast_swap(self_type &other)
Swaps the handles of two vectors by swapping the OpenCL handles only, no data copy.
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...