ViennaCL - The Vienna Computing Library  1.5.0
Public Types | Public Member Functions
vector< SCALARTYPE, ALIGNMENT > Class Template Reference

A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::vector. More...

#include <vector.hpp>

Inheritance diagram for vector< SCALARTYPE, ALIGNMENT >:
vector_base< SCALARTYPE >

Public Types

typedef base_type::size_type size_type
typedef base_type::difference_type difference_type

Public Member Functions

 vector ()
 Default constructor in order to be compatible with various containers.
 vector (size_type vec_size)
 An explicit constructor for the vector, allocating the given amount of memory (plus a padding specified by 'ALIGNMENT')
 vector (size_type vec_size, viennacl::context ctx)
 vector (SCALARTYPE *ptr_to_mem, viennacl::memory_types mem_type, size_type vec_size, size_type start=0, difference_type stride=1)
template<typename LHS , typename RHS , typename OP >
 vector (vector_expression< const LHS, const RHS, OP > const &proxy)
 vector (const base_type &v)
 vector (const self_type &v)
 vector (unit_vector< SCALARTYPE > const &v)
 Creates the vector from the supplied unit vector.
 vector (zero_vector< SCALARTYPE > const &v)
 Creates the vector from the supplied zero vector.
 vector (scalar_vector< SCALARTYPE > const &v)
 Creates the vector from the supplied scalar vector.
template<typename T >
self_typeoperator= (T const &other)
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.
self_typefast_swap (self_type &other)
 Swaps the handles of two vectors by swapping the OpenCL handles only, no data copy.
void switch_memory_context (viennacl::context new_ctx)

Detailed Description

template<class SCALARTYPE, unsigned int ALIGNMENT>
class viennacl::vector< SCALARTYPE, ALIGNMENT >

A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::vector.

This is the basic vector type of ViennaCL. It is similar to std::vector and boost::numeric::ublas::vector and supports various linear algebra operations. By default, the internal length of the vector is padded to a multiple of 'ALIGNMENT' in order to speed up several GPU viennacl::ocl::kernels.

Template Parameters:
SCALARTYPEThe floating point type, either 'float' or 'double'
ALIGNMENTThe 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

Reimplemented from vector_base< SCALARTYPE >.

Reimplemented from vector_base< SCALARTYPE >.


Constructor & Destructor Documentation

vector ( ) [inline, explicit]

Default constructor in order to be compatible with various containers.

vector ( size_type  vec_size) [inline, explicit]

An explicit constructor for the vector, allocating the given amount of memory (plus a padding specified by 'ALIGNMENT')

Parameters:
vec_sizeThe length (i.e. size) of the vector.
vector ( size_type  vec_size,
viennacl::context  ctx 
) [inline, explicit]
vector ( SCALARTYPE *  ptr_to_mem,
viennacl::memory_types  mem_type,
size_type  vec_size,
size_type  start = 0,
difference_type  stride = 1 
) [inline, explicit]
vector ( vector_expression< const LHS, const RHS, OP > const &  proxy) [inline]
vector ( const base_type v) [inline]
vector ( const self_type v) [inline]
vector ( unit_vector< SCALARTYPE > const &  v) [inline]

Creates the vector from the supplied unit vector.

vector ( zero_vector< SCALARTYPE > const &  v) [inline]

Creates the vector from the supplied zero vector.

vector ( scalar_vector< SCALARTYPE > const &  v) [inline]

Creates the vector from the supplied scalar vector.


Member Function Documentation

self_type& fast_swap ( self_type other) [inline]

Swaps the handles of two vectors by swapping the OpenCL handles only, no data copy.

self_type& operator= ( T const &  other) [inline]
void resize ( size_type  new_size,
bool  preserve = true 
) [inline]

Resizes the allocated memory for the vector. Pads the memory to be a multiple of 'ALIGNMENT'.

Parameters:
new_sizeThe new size of the vector
preserveIf true, old entries of the vector are preserved, otherwise eventually discarded.

Reimplemented from vector_base< SCALARTYPE >.

void resize ( size_type  new_size,
viennacl::context  ctx,
bool  preserve = true 
) [inline]

Resizes the allocated memory for the vector. Convenience function for setting an OpenCL context in case reallocation is needed.

Parameters:
new_sizeThe new size of the vector
ctxThe context within which the new memory should be allocated
preserveIf true, old entries of the vector are preserved, otherwise eventually discarded.

Reimplemented from vector_base< SCALARTYPE >.

void switch_memory_context ( viennacl::context  new_ctx) [inline]

Reimplemented from vector_base< SCALARTYPE >.


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