|
ViennaCL - The Vienna Computing Library
1.5.1
|
Common base class for dense vectors, vector ranges, and vector slices. More...
#include <vector.hpp>
Public Types | |
| typedef scalar< SCALARTYPE > | value_type |
| typedef SCALARTYPE | cpu_value_type |
| typedef viennacl::backend::mem_handle | handle_type |
| typedef SizeType | size_type |
| typedef DistanceType | difference_type |
| typedef const_vector_iterator < SCALARTYPE, 1 > | const_iterator |
| typedef vector_iterator < SCALARTYPE, 1 > | iterator |
Public Member Functions | |
| vector_base () | |
| Default constructor in order to be compatible with various containers. | |
| vector_base (viennacl::backend::mem_handle &h, size_type vec_size, size_type vec_start, difference_type vec_stride) | |
| An explicit constructor for wrapping an existing vector into a vector_range or vector_slice. | |
| vector_base (size_type vec_size, viennacl::context ctx=viennacl::context()) | |
| Creates a vector and allocates the necessary memory. | |
| vector_base (SCALARTYPE *ptr_to_mem, viennacl::memory_types mem_type, size_type vec_size, vcl_size_t start=0, difference_type stride=1) | |
| template<typename LHS , typename RHS , typename OP > | |
| vector_base (vector_expression< const LHS, const RHS, OP > const &proxy) | |
| Creates the vector from the supplied random vector. | |
| 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. | |
| template<typename LHS , typename RHS , typename OP > | |
| self_type & | operator= (const vector_expression< const LHS, const RHS, OP > &proxy) |
| Implementation of the operation v1 = v2 @ alpha, where @ denotes either multiplication or division, and alpha is either a CPU or a GPU scalar. | |
| template<typename T > | |
| self_type & | operator= (const vector_base< T > &v1) |
| self_type & | operator= (unit_vector< SCALARTYPE > const &v) |
| Creates the vector from the supplied unit vector. | |
| self_type & | operator= (zero_vector< SCALARTYPE > const &v) |
| Creates the vector from the supplied zero vector. | |
| self_type & | operator= (scalar_vector< SCALARTYPE > const &v) |
| Creates the vector from the supplied scalar vector. | |
| template<typename F > | |
| self_type & | operator= (const viennacl::vector_expression< const matrix_base< SCALARTYPE, F >, const vector_base< SCALARTYPE >, viennacl::op_prod > &proxy) |
| Operator overload for v1 = A * v2, where v1, v2 are vectors and A is a dense matrix. | |
| template<typename F > | |
| self_type & | operator= (const vector_expression< const matrix_expression< const matrix_base< SCALARTYPE, F >, const matrix_base< SCALARTYPE, F >, op_trans >, const vector_base< SCALARTYPE >, op_prod > &proxy) |
| Operator overload for v1 = trans(A) * v2, where v1, v2 are vectors and A is a dense matrix. | |
| entry_proxy< SCALARTYPE > | operator() (size_type index) |
| Read-write access to a single element of the vector. | |
| entry_proxy< SCALARTYPE > | operator[] (size_type index) |
| Read-write access to a single element of the vector. | |
| const_entry_proxy< SCALARTYPE > | operator() (size_type index) const |
| Read access to a single element of the vector. | |
| const_entry_proxy< SCALARTYPE > | operator[] (size_type index) const |
| Read access to a single element of the vector. | |
| self_type & | operator+= (const self_type &vec) |
| self_type & | operator-= (const self_type &vec) |
| template<typename LHS , typename RHS , typename OP > | |
| self_type & | operator+= (const vector_expression< const LHS, const RHS, OP > &proxy) |
| template<typename LHS , typename RHS , typename OP > | |
| self_type & | operator-= (const vector_expression< const LHS, const RHS, OP > &proxy) |
| self_type & | operator*= (SCALARTYPE val) |
| Scales a vector (or proxy) by a CPU scalar value. | |
| self_type & | operator/= (SCALARTYPE val) |
| Scales this vector by a CPU scalar value. | |
| vector_expression< const self_type, const SCALARTYPE, op_mult > | operator* (SCALARTYPE value) const |
| Scales the vector by a CPU scalar 'alpha' and returns an expression template. | |
| vector_expression< const self_type, const SCALARTYPE, op_div > | operator/ (SCALARTYPE value) const |
| Scales the vector by a CPU scalar 'alpha' and returns an expression template. | |
| vector_expression< const self_type, const SCALARTYPE, op_mult > | operator- () const |
| Sign flip for the vector. Emulated to be equivalent to -1.0 * vector. | |
| iterator | begin () |
| Returns an iterator pointing to the beginning of the vector (STL like) | |
| iterator | end () |
| Returns an iterator pointing to the end of the vector (STL like) | |
| const_iterator | begin () const |
| Returns a const-iterator pointing to the beginning of the vector (STL like) | |
| const_iterator | end () const |
| Returns a const-iterator pointing to the end of the vector (STL like) | |
| self_type & | swap (self_type &other) |
| Swaps the entries of the two vectors. | |
| size_type | size () const |
| Returns the length of the vector (cf. std::vector) | |
| size_type | internal_size () const |
| Returns the internal length of the vector, which is given by size() plus the extra memory due to padding the memory with zeros up to a multiple of 'ALIGNMENT'. | |
| size_type | start () const |
| Returns the offset within the buffer. | |
| size_type | stride () const |
| Returns the stride within the buffer (in multiples of sizeof(SCALARTYPE)) | |
| bool | empty () const |
| Returns true is the size is zero. | |
| const handle_type & | handle () const |
| Returns the memory handle. | |
| handle_type & | handle () |
| Returns the memory handle. | |
| void | clear () |
| Resets all entries to zero. Does not change the size of the vector. | |
| 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) |
| self_type & | fast_swap (self_type &other) |
| Swaps the handles of two vectors by swapping the OpenCL handles only, no data copy. | |
| void | pad () |
| Pads vectors with alignment > 1 with trailing zeros if the internal size is larger than the visible size. | |
| void | switch_memory_context (viennacl::context new_ctx) |
| void | resize (size_type new_size, bool preserve=true) |
| Resizes the allocated memory for the vector. Pads the memory to be a multiple of 'ALIGNMENT'. | |
| void | resize (size_type new_size, viennacl::context ctx, bool preserve=true) |
| Resizes the allocated memory for the vector. Convenience function for setting an OpenCL context in case reallocation is needed. | |
Common base class for dense vectors, vector ranges, and vector slices.
| SCALARTYPE | The floating point type, either 'float' or 'double' |
| typedef const_vector_iterator<SCALARTYPE, 1> const_iterator |
Reimplemented in vector_slice< VectorType >, and vector_range< VectorType >.
| typedef SCALARTYPE cpu_value_type |
Reimplemented in vector_slice< VectorType >, and vector_range< VectorType >.
| typedef DistanceType difference_type |
Reimplemented in vector< SCALARTYPE, ALIGNMENT >, vector< ScalarType >, vector_slice< VectorType >, and vector_range< VectorType >.
| typedef vector_iterator<SCALARTYPE, 1> iterator |
Reimplemented in vector_slice< VectorType >, and vector_range< VectorType >.
| typedef SizeType size_type |
Reimplemented in vector< SCALARTYPE, ALIGNMENT >, vector< ScalarType >, vector_slice< VectorType >, and vector_range< VectorType >.
| typedef scalar<SCALARTYPE> value_type |
Reimplemented in vector_slice< VectorType >, and vector_range< VectorType >.
| vector_base | ( | ) | [inline, explicit] |
Default constructor in order to be compatible with various containers.
| vector_base | ( | viennacl::backend::mem_handle & | h, |
| size_type | vec_size, | ||
| size_type | vec_start, | ||
| difference_type | vec_stride | ||
| ) | [inline, explicit] |
An explicit constructor for wrapping an existing vector into a vector_range or vector_slice.
| h | The existing memory handle from a vector/vector_range/vector_slice |
| vec_size | The length (i.e. size) of the buffer |
| vec_start | The offset from the beginning of the buffer identified by 'h' |
| vec_stride | Increment between two elements in the original buffer (in multiples of SCALARTYPE) |
| vector_base | ( | size_type | vec_size, |
| viennacl::context | ctx = viennacl::context() |
||
| ) | [inline, explicit] |
Creates a vector and allocates the necessary memory.
| vector_base | ( | SCALARTYPE * | ptr_to_mem, |
| viennacl::memory_types | mem_type, | ||
| size_type | vec_size, | ||
| vcl_size_t | start = 0, |
||
| difference_type | stride = 1 |
||
| ) | [inline, explicit] |
| vector_base | ( | vector_expression< const LHS, const RHS, OP > const & | proxy | ) | [inline, explicit] |
Creates the vector from the supplied random vector.
| const_iterator begin | ( | ) | const [inline] |
Returns a const-iterator pointing to the beginning of the vector (STL like)
| void clear | ( | ) | [inline] |
Resets all entries to zero. Does not change the size of the vector.
| bool empty | ( | ) | const [inline] |
Returns true is the size is zero.
| const_iterator end | ( | ) | const [inline] |
Returns a const-iterator pointing to the end of the vector (STL like)
Swaps the handles of two vectors by swapping the OpenCL handles only, no data copy.
Reimplemented in vector< ScalarType >.
| const handle_type& handle | ( | ) | const [inline] |
Returns the memory handle.
| handle_type& handle | ( | ) | [inline] |
Returns the memory handle.
| size_type internal_size | ( | ) | const [inline] |
Returns the internal length of the vector, which is given by size() plus the extra memory due to padding the memory with zeros up to a multiple of 'ALIGNMENT'.
| viennacl::memory_types memory_domain | ( | ) | const [inline] |
| entry_proxy<SCALARTYPE> operator() | ( | size_type | index | ) | [inline] |
Read-write access to a single element of the vector.
| const_entry_proxy<SCALARTYPE> operator() | ( | size_type | index | ) | const [inline] |
Read access to a single element of the vector.
| vector_expression< const self_type, const SCALARTYPE, op_mult> operator* | ( | SCALARTYPE | value | ) | const [inline] |
Scales the vector by a CPU scalar 'alpha' and returns an expression template.
| self_type& operator*= | ( | SCALARTYPE | val | ) | [inline] |
Scales a vector (or proxy) by a CPU scalar value.
| self_type& operator+= | ( | const vector_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
| vector_expression<const self_type, const SCALARTYPE, op_mult> operator- | ( | ) | const [inline] |
Sign flip for the vector. Emulated to be equivalent to -1.0 * vector.
| self_type& operator-= | ( | const vector_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
| vector_expression< const self_type, const SCALARTYPE, op_div> operator/ | ( | SCALARTYPE | value | ) | const [inline] |
Scales the vector by a CPU scalar 'alpha' and returns an expression template.
| self_type& operator/= | ( | SCALARTYPE | val | ) | [inline] |
Scales this vector by a CPU scalar value.
Assignment operator. Other vector needs to be of the same size, or this vector is not yet initialized.
| self_type& operator= | ( | const vector_expression< const LHS, const RHS, OP > & | proxy | ) | [inline] |
Implementation of the operation v1 = v2 @ 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 vector_base< T > & | v1 | ) | [inline] |
| self_type& operator= | ( | unit_vector< SCALARTYPE > const & | v | ) | [inline] |
Creates the vector from the supplied unit vector.
| self_type& operator= | ( | zero_vector< SCALARTYPE > const & | v | ) | [inline] |
Creates the vector from the supplied zero vector.
| self_type& operator= | ( | scalar_vector< SCALARTYPE > const & | v | ) | [inline] |
Creates the vector from the supplied scalar vector.
| self_type& operator= | ( | const viennacl::vector_expression< const matrix_base< SCALARTYPE, F >, const vector_base< SCALARTYPE >, viennacl::op_prod > & | proxy | ) | [inline] |
Operator overload for v1 = A * v2, where v1, v2 are vectors and A is a dense matrix.
| proxy | An expression template proxy class |
| self_type& operator= | ( | const vector_expression< const matrix_expression< const matrix_base< SCALARTYPE, F >, const matrix_base< SCALARTYPE, F >, op_trans >, const vector_base< SCALARTYPE >, op_prod > & | proxy | ) | [inline] |
Operator overload for v1 = trans(A) * v2, where v1, v2 are vectors and A is a dense matrix.
| proxy | An expression template proxy class |
| entry_proxy<SCALARTYPE> operator[] | ( | size_type | index | ) | [inline] |
Read-write access to a single element of the vector.
| const_entry_proxy<SCALARTYPE> operator[] | ( | size_type | index | ) | const [inline] |
Read access to a single element of the vector.
| void pad | ( | ) | [inline, protected] |
Pads vectors with alignment > 1 with trailing zeros if the internal size is larger than the visible size.
Resizes the allocated memory for the vector. Pads the memory to be a multiple of 'ALIGNMENT'.
| new_size | The new size of the vector |
| preserve | If true, old entries of the vector are preserved, otherwise eventually discarded. |
Reimplemented in vector< SCALARTYPE, ALIGNMENT >, and vector< ScalarType >.
| void resize | ( | size_type | new_size, |
| viennacl::context | ctx, | ||
| bool | preserve = true |
||
| ) | [inline, protected] |
Resizes the allocated memory for the vector. Convenience function for setting an OpenCL context in case reallocation is needed.
| new_size | The new size of the vector |
| ctx | The context within which the new memory should be allocated |
| preserve | If true, old entries of the vector are preserved, otherwise eventually discarded. |
Reimplemented in vector< SCALARTYPE, ALIGNMENT >, and vector< ScalarType >.
| void set_handle | ( | viennacl::backend::mem_handle const & | h | ) | [inline, protected] |
Returns the stride within the buffer (in multiples of sizeof(SCALARTYPE))
| void switch_memory_context | ( | viennacl::context | new_ctx | ) | [inline, protected] |
Reimplemented in vector< SCALARTYPE, ALIGNMENT >, and vector< ScalarType >.
Reimplemented in vector_slice< VectorType >, and vector_range< VectorType >.
1.7.6.1