ViennaCL - The Vienna Computing Library  1.5.2
Data Structures | Namespaces | Functions
viennacl/vector.hpp File Reference

The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations such as norms and inner products are located in linalg/vector_operations.hpp. More...

#include "viennacl/forwards.h"
#include "viennacl/backend/memory.hpp"
#include "viennacl/scalar.hpp"
#include "viennacl/tools/tools.hpp"
#include "viennacl/tools/entry_proxy.hpp"
#include "viennacl/linalg/detail/op_executor.hpp"
#include "viennacl/linalg/vector_operations.hpp"
#include "viennacl/meta/result_of.hpp"
#include "viennacl/context.hpp"
#include "viennacl/traits/handle.hpp"

Go to the source code of this file.

Data Structures

class  implicit_vector_base< SCALARTYPE >
 Common base class for representing vectors where the entries are not all stored explicitly. More...
class  unit_vector< SCALARTYPE >
 Represents a vector consisting of 1 at a given index and zeros otherwise. More...
class  zero_vector< SCALARTYPE >
 Represents a vector consisting of zeros only. More...
class  one_vector< SCALARTYPE >
 Represents a vector consisting of ones only. More...
class  scalar_vector< SCALARTYPE >
 Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only. More...
class  vector_expression< LHS, RHS, OP >
 An expression template class that represents a binary operation that yields a vector. More...
class  const_vector_iterator< SCALARTYPE, ALIGNMENT >
 A STL-type const-iterator for vector elements. Elements can be accessed, but cannot be manipulated. VERY SLOW!! More...
class  vector_iterator< SCALARTYPE, ALIGNMENT >
 A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!! More...
class  vector_base< SCALARTYPE, SizeType, DistanceType >
 Common base class for dense vectors, vector ranges, and vector slices. More...
class  vector< SCALARTYPE, ALIGNMENT >
 A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::vector. More...
class  vector_tuple< ScalarT >
 Tuple class holding pointers to multiple vectors. Mainly used as a temporary object returned from viennacl::tie(). More...

Namespaces

namespace  viennacl
 

Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.


Functions

template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1, vector_base< ScalarT > const &v2)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1, vector_base< ScalarT > const &v2, vector_base< ScalarT > const &v3)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2, vector_base< ScalarT > &v3)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1, vector_base< ScalarT > const &v2, vector_base< ScalarT > const &v3, vector_base< ScalarT > const &v4)
template<typename ScalarT >
vector_tuple< ScalarT > tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2, vector_base< ScalarT > &v3, vector_base< ScalarT > &v4)
template<typename SCALARTYPE , unsigned int ALIGNMENT, typename CPU_ITERATOR >
void fast_copy (const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
 STL-like transfer of a GPU vector to the CPU. The cpu type is assumed to reside in a linear piece of memory, such as e.g. for std::vector.
template<typename NumericT , typename CPUVECTOR >
void fast_copy (vector_base< NumericT > const &gpu_vec, CPUVECTOR &cpu_vec)
 Transfer from a gpu vector to a cpu vector. Convenience wrapper for viennacl::linalg::fast_copy(gpu_vec.begin(), gpu_vec.end(), cpu_vec.begin());.
template<typename SCALARTYPE , unsigned int ALIGNMENT, typename CPU_ITERATOR >
void async_copy (const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
 Asynchronous version of fast_copy(), copying data from device to host. The host iterator cpu_begin needs to reside in a linear piece of memory, such as e.g. for std::vector.
template<typename NumericT , typename CPUVECTOR >
void async_copy (vector_base< NumericT > const &gpu_vec, CPUVECTOR &cpu_vec)
 Transfer from a gpu vector to a cpu vector. Convenience wrapper for viennacl::linalg::fast_copy(gpu_vec.begin(), gpu_vec.end(), cpu_vec.begin());.
template<typename SCALARTYPE , unsigned int ALIGNMENT, typename CPU_ITERATOR >
void copy (const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
 STL-like transfer for the entries of a GPU vector to the CPU. The cpu type does not need to lie in a linear piece of memory.
template<typename SCALARTYPE , unsigned int ALIGNMENT, typename CPU_ITERATOR >
void copy (const vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
 STL-like transfer for the entries of a GPU vector to the CPU. The cpu type does not need to lie in a linear piece of memory.
template<typename NumericT , typename CPUVECTOR >
void copy (vector_base< NumericT > const &gpu_vec, CPUVECTOR &cpu_vec)
 Transfer from a gpu vector to a cpu vector. Convenience wrapper for viennacl::linalg::copy(gpu_vec.begin(), gpu_vec.end(), cpu_vec.begin());.
template<typename CPU_ITERATOR , typename SCALARTYPE , unsigned int ALIGNMENT>
void fast_copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< SCALARTYPE, ALIGNMENT > gpu_begin)
 STL-like transfer of a CPU vector to the GPU. The cpu type is assumed to reside in a linear piece of memory, such as e.g. for std::vector.
template<typename CPUVECTOR , typename NumericT >
void fast_copy (const CPUVECTOR &cpu_vec, vector_base< NumericT > &gpu_vec)
 Transfer from a cpu vector to a gpu vector. Convenience wrapper for viennacl::linalg::fast_copy(cpu_vec.begin(), cpu_vec.end(), gpu_vec.begin());.
template<typename CPU_ITERATOR , typename SCALARTYPE , unsigned int ALIGNMENT>
void async_copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< SCALARTYPE, ALIGNMENT > gpu_begin)
 Asynchronous version of fast_copy(), copying data from host to device. The host iterator cpu_begin needs to reside in a linear piece of memory, such as e.g. for std::vector.
template<typename CPUVECTOR , typename NumericT >
void async_copy (const CPUVECTOR &cpu_vec, vector_base< NumericT > &gpu_vec)
 Transfer from a cpu vector to a gpu vector. Convenience wrapper for viennacl::linalg::fast_copy(cpu_vec.begin(), cpu_vec.end(), gpu_vec.begin());.
template<typename SCALARTYPE , unsigned int ALIGNMENT, typename CPU_ITERATOR >
void copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< SCALARTYPE, ALIGNMENT > gpu_begin)
 STL-like transfer for the entries of a GPU vector to the CPU. The cpu type does not need to lie in a linear piece of memory.
template<typename CPUVECTOR , typename T >
void copy (const CPUVECTOR &cpu_vec, vector_base< T > &gpu_vec)
 Transfer from a cpu vector to a gpu vector. Convenience wrapper for viennacl::linalg::copy(cpu_vec.begin(), cpu_vec.end(), gpu_vec.begin());.
template<typename SCALARTYPE , unsigned int ALIGNMENT_SRC, unsigned int ALIGNMENT_DEST>
void copy (const_vector_iterator< SCALARTYPE, ALIGNMENT_SRC > const &gpu_src_begin, const_vector_iterator< SCALARTYPE, ALIGNMENT_SRC > const &gpu_src_end, vector_iterator< SCALARTYPE, ALIGNMENT_DEST > gpu_dest_begin)
 Copy (parts of a) GPU vector to another GPU vector.
template<typename SCALARTYPE , unsigned int ALIGNMENT_SRC, unsigned int ALIGNMENT_DEST>
void copy (vector_iterator< SCALARTYPE, ALIGNMENT_SRC > const &gpu_src_begin, vector_iterator< SCALARTYPE, ALIGNMENT_SRC > const &gpu_src_end, vector_iterator< SCALARTYPE, ALIGNMENT_DEST > gpu_dest_begin)
 Copy (parts of a) GPU vector to another GPU vector.
template<typename SCALARTYPE , unsigned int ALIGNMENT_SRC, unsigned int ALIGNMENT_DEST>
void copy (vector< SCALARTYPE, ALIGNMENT_SRC > const &gpu_src_vec, vector< SCALARTYPE, ALIGNMENT_DEST > &gpu_dest_vec)
 Transfer from a ViennaCL vector to another ViennaCL vector. Convenience wrapper for viennacl::linalg::copy(gpu_src_vec.begin(), gpu_src_vec.end(), gpu_dest_vec.begin());.
template<typename T >
std::ostream & operator<< (std::ostream &os, vector_base< T > const &val)
 Output stream. Output format is ublas compatible.
template<typename LHS , typename RHS , typename OP >
std::ostream & operator<< (std::ostream &os, vector_expression< LHS, RHS, OP > const &proxy)
template<typename T >
void swap (vector_base< T > &vec1, vector_base< T > &vec2)
 Swaps the contents of two vectors, data is copied.
template<typename SCALARTYPE , unsigned int ALIGNMENT>
vector< SCALARTYPE, ALIGNMENT > & fast_swap (vector< SCALARTYPE, ALIGNMENT > &v1, vector< SCALARTYPE, ALIGNMENT > &v2)
 Swaps the content of two vectors by swapping OpenCL handles only, NO data is copied.
template<typename T , typename S1 >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value, vector_base< T >
& >::type 
operator*= (vector_base< T > &v1, S1 const &gpu_val)
 Scales this vector by a GPU scalar value.
template<typename T , typename S1 >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value, vector_base< T >
& >::type 
operator/= (vector_base< T > &v1, S1 const &gpu_val)
 Scales this vector by a GPU scalar value.
template<typename LHS1 , typename RHS1 , typename OP1 , typename LHS2 , typename RHS2 , typename OP2 >
vector_expression< const
vector_expression< LHS1, RHS1,
OP1 >, const vector_expression
< LHS2, RHS2, OP2 >
, viennacl::op_add
operator+ (vector_expression< LHS1, RHS1, OP1 > const &proxy1, vector_expression< LHS2, RHS2, OP2 > const &proxy2)
 Operator overload for the addition of two vector expressions.
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const
vector_expression< LHS, RHS,
OP >, const vector_base< T >
, viennacl::op_add
operator+ (vector_expression< LHS, RHS, OP > const &proxy, vector_base< T > const &vec)
 Operator overload for the addition of a vector expression with a vector or another vector expression. This is the default implementation for all cases that are too complex in order to be covered within a single kernel, hence a temporary vector is created.
template<typename T , typename LHS , typename RHS , typename OP >
vector_expression< const
vector_base< T >, const
vector_expression< LHS, RHS,
OP >, viennacl::op_add
operator+ (vector_base< T > const &vec, vector_expression< LHS, RHS, OP > const &proxy)
 Operator overload for the addition of a vector with a vector expression. This is the default implementation for all cases that are too complex in order to be covered within a single kernel, hence a temporary vector is created.
template<typename T >
vector_expression< const
vector_base< T >, const
vector_base< T >, op_add > 
operator+ (const vector_base< T > &v1, const vector_base< T > &v2)
 Returns an expression template object for adding up two vectors, i.e. v1 + v2.
template<typename LHS1 , typename RHS1 , typename OP1 , typename LHS2 , typename RHS2 , typename OP2 >
vector_expression< const
vector_expression< LHS1, RHS1,
OP1 >, const vector_expression
< LHS2, RHS2, OP2 >
, viennacl::op_sub
operator- (vector_expression< LHS1, RHS1, OP1 > const &proxy1, vector_expression< LHS2, RHS2, OP2 > const &proxy2)
 Operator overload for the subtraction of two vector expressions.
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const
vector_expression< LHS, RHS,
OP >, const vector_base< T >
, viennacl::op_sub
operator- (vector_expression< LHS, RHS, OP > const &proxy, vector_base< T > const &vec)
 Operator overload for the subtraction of a vector expression with a vector or another vector expression. This is the default implementation for all cases that are too complex in order to be covered within a single kernel, hence a temporary vector is created.
template<typename T , typename LHS , typename RHS , typename OP >
vector_expression< const
vector_base< T >, const
vector_expression< LHS, RHS,
OP >, viennacl::op_sub
operator- (vector_base< T > const &vec, vector_expression< LHS, RHS, OP > const &proxy)
 Operator overload for the subtraction of a vector expression with a vector or another vector expression. This is the default implementation for all cases that are too complex in order to be covered within a single kernel, hence a temporary vector is created.
template<typename T >
vector_expression< const
vector_base< T >, const
vector_base< T >, op_sub > 
operator- (const vector_base< T > &v1, const vector_base< T > &v2)
 Returns an expression template object for subtracting two vectors, i.e. v1 - v2.
template<typename S1 , typename T >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value, vector_expression
< const vector_base< T >
, const S1, op_mult > >::type 
operator* (S1 const &value, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a host scalar (float or double) and v1 is a ViennaCL vector.
template<typename T >
vector_expression< const
vector_base< T >, const T,
op_mult > 
operator* (char value, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a char.
template<typename T >
vector_expression< const
vector_base< T >, const T,
op_mult > 
operator* (short value, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a short.
template<typename T >
vector_expression< const
vector_base< T >, const T,
op_mult > 
operator* (int value, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a int.
template<typename T >
vector_expression< const
vector_base< T >, const T,
op_mult > 
operator* (long value, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a long.
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const
vector_base< T >, const
scalar_expression< LHS, RHS,
OP >, op_mult > 
operator* (scalar_expression< LHS, RHS, OP > const &expr, vector_base< T > const &vec)
 Operator overload for the expression alpha * v1, where alpha is a scalar expression and v1 is a ViennaCL vector.
template<typename T , typename S1 >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value, vector_expression
< const vector_base< T >
, const S1, op_mult > >::type 
operator* (vector_base< T > const &vec, S1 const &value)
 Scales the vector by a scalar 'alpha' and returns an expression template.
template<typename T >
vector_expression< const
vector_base< T >, const T,
op_mult > 
operator* (vector_base< T > const &vec, T const &value)
template<typename LHS , typename RHS , typename OP , typename S1 >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value,
viennacl::vector_expression
< const vector_expression< LHS,
RHS, OP >, const S1, op_mult >
>::type 
operator* (vector_expression< LHS, RHS, OP > const &proxy, S1 const &val)
 Operator overload for the multiplication of a vector expression with a scalar from the right, e.g. (beta * vec1) * alpha. Here, beta * vec1 is wrapped into a vector_expression and then multiplied with alpha from the right.
template<typename S1 , typename LHS , typename RHS , typename OP >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value,
viennacl::vector_expression
< const vector_expression< LHS,
RHS, OP >, const S1, op_mult >
>::type 
operator* (S1 const &val, vector_expression< LHS, RHS, OP > const &proxy)
 Operator overload for the multiplication of a vector expression with a ViennaCL scalar from the left, e.g. alpha * (beta * vec1). Here, beta * vec1 is wrapped into a vector_expression and then multiplied with alpha from the left.
template<typename S1 , typename LHS , typename RHS , typename OP >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value,
viennacl::vector_expression
< const vector_expression< LHS,
RHS, OP >, const S1, op_div >
>::type 
operator/ (vector_expression< LHS, RHS, OP > const &proxy, S1 const &val)
 Operator overload for the division of a vector expression by a scalar from the right, e.g. (beta * vec1) / alpha. Here, beta * vec1 is wrapped into a vector_expression and then divided by alpha.
template<typename T , typename S1 >
viennacl::enable_if
< viennacl::is_any_scalar< S1 >
::value, vector_expression
< const vector_base< T >
, const S1, op_div > >::type 
operator/ (vector_base< T > const &v1, S1 const &s1)
 Returns an expression template for scaling the vector by a GPU scalar 'alpha'.

Detailed Description

The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations such as norms and inner products are located in linalg/vector_operations.hpp.