ViennaCL - The Vienna Computing Library: viennacl/vector.hpp File Reference

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Functions
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/detail/vector_def.hpp"`
`#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.

## Classes
class | viennacl::vector_expression< LHS, RHS, OP >
| An expression template class that represents a binary operation that yields a vector. More...
class | viennacl::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 | viennacl::vector_iterator< SCALARTYPE, ALIGNMENT >
| A STL-type iterator for vector elements. Elements can be accessed and manipulated. VERY SLOW!! More...
class | viennacl::vector< SCALARTYPE, ALIGNMENT >
class | viennacl::vector_tuple< ScalarT >
| Tuple class holding pointers to multiple vectors. Mainly used as a temporary object returned from viennacl::tie(). More...

## Namespaces
| 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 > | viennacl::tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1)
template<typename ScalarT >
vector_tuple< ScalarT > | viennacl::tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1)
template<typename ScalarT >
vector_tuple< ScalarT > | viennacl::tie (vector_base< ScalarT > const &v0, vector_base< ScalarT > const &v1, vector_base< ScalarT > const &v2)
template<typename ScalarT >
vector_tuple< ScalarT > | viennacl::tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2)
template<typename ScalarT >
vector_tuple< ScalarT > | viennacl::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 > | viennacl::tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2, vector_base< ScalarT > &v3)
template<typename ScalarT >
vector_tuple< ScalarT > | viennacl::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 > | viennacl::tie (vector_base< ScalarT > &v0, vector_base< ScalarT > &v1, vector_base< ScalarT > &v2, vector_base< ScalarT > &v3, vector_base< ScalarT > &v4)
template<typename NumericT , unsigned int AlignmentV, typename CPU_ITERATOR >
void | viennacl::fast_copy (const const_vector_iterator< NumericT, AlignmentV > &gpu_begin, const const_vector_iterator< NumericT, AlignmentV > &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. More...
template<typename NumericT , typename CPUVECTOR >
void | viennacl::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());. More...
template<typename NumericT , unsigned int AlignmentV, typename CPU_ITERATOR >
void | viennacl::async_copy (const const_vector_iterator< NumericT, AlignmentV > &gpu_begin, const const_vector_iterator< NumericT, AlignmentV > &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. More...
template<typename NumericT , typename CPUVECTOR >
void | viennacl::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());. More...
template<typename NumericT , unsigned int AlignmentV, typename CPU_ITERATOR >
void | viennacl::copy (const const_vector_iterator< NumericT, AlignmentV > &gpu_begin, const const_vector_iterator< NumericT, AlignmentV > &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. More...
template<typename NumericT , unsigned int AlignmentV, typename CPU_ITERATOR >
void | viennacl::copy (const vector_iterator< NumericT, AlignmentV > &gpu_begin, const vector_iterator< NumericT, AlignmentV > &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. More...
template<typename NumericT , typename CPUVECTOR >
void | viennacl::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());. More...
template<typename CPU_ITERATOR , typename NumericT , unsigned int AlignmentV>
void | viennacl::fast_copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< NumericT, AlignmentV > 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. More...
template<typename CPUVECTOR , typename NumericT >
void | viennacl::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());. More...
template<typename CPU_ITERATOR , typename NumericT , unsigned int AlignmentV>
void | viennacl::async_copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< NumericT, AlignmentV > 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. More...
template<typename CPUVECTOR , typename NumericT >
void | viennacl::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());. More...
template<typename NumericT , unsigned int AlignmentV, typename CPU_ITERATOR >
void | viennacl::copy (CPU_ITERATOR const &cpu_begin, CPU_ITERATOR const &cpu_end, vector_iterator< NumericT, AlignmentV > 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. More...
template<typename HostVectorT , typename T >
void | viennacl::copy (HostVectorT const &cpu_vec, vector_base< T > &gpu_vec)
| Transfer from a host vector object to a ViennaCL vector proxy. Requires the vector proxy to have the necessary size. Convenience wrapper for viennacl::linalg::copy(cpu_vec.begin(), cpu_vec.end(), gpu_vec.begin());. More...
template<typename HostVectorT , typename T , unsigned int AlignmentV>
void | viennacl::copy (HostVectorT const &cpu_vec, vector< T, AlignmentV > &gpu_vec)
| Transfer from a host vector object to a ViennaCL vector. Resizes the ViennaCL vector if it has zero size. Convenience wrapper for viennacl::linalg::copy(cpu_vec.begin(), cpu_vec.end(), gpu_vec.begin());. More...
template<typename NumericT , unsigned int AlignmentV_SRC, unsigned int AlignmentV_DEST>
void | viennacl::copy (const_vector_iterator< NumericT, AlignmentV_SRC > const &gpu_src_begin, const_vector_iterator< NumericT, AlignmentV_SRC > const &gpu_src_end, vector_iterator< NumericT, AlignmentV_DEST > gpu_dest_begin)
| Copy (parts of a) GPU vector to another GPU vector. More...
template<typename NumericT , unsigned int AlignmentV_SRC, unsigned int AlignmentV_DEST>
void | viennacl::copy (vector_iterator< NumericT, AlignmentV_SRC > const &gpu_src_begin, vector_iterator< NumericT, AlignmentV_SRC > const &gpu_src_end, vector_iterator< NumericT, AlignmentV_DEST > gpu_dest_begin)
| Copy (parts of a) GPU vector to another GPU vector. More...
template<typename NumericT , unsigned int AlignmentV_SRC, unsigned int AlignmentV_DEST>
void | viennacl::copy (vector< NumericT, AlignmentV_SRC > const &gpu_src_vec, vector< NumericT, AlignmentV_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());. More...
template<typename T >
std::ostream & | viennacl::operator<< (std::ostream &os, vector_base< T > const &val)
| Output stream. Output format is ublas compatible. More...
template<typename LHS , typename RHS , typename OP >
std::ostream & | viennacl::operator<< (std::ostream &os, vector_expression< LHS, RHS, OP > const &proxy)
template<typename T >
void | viennacl::swap (vector_base< T > &vec1, vector_base< T > &vec2)
| Swaps the contents of two vectors, data is copied. More...
template<typename NumericT , unsigned int AlignmentV>
vector< NumericT, AlignmentV > & | viennacl::fast_swap (vector< NumericT, AlignmentV > &v1, vector< NumericT, AlignmentV > &v2)
| Swaps the content of two vectors by swapping OpenCL handles only, NO data is copied. More...
template<typename T , typename S1 >
viennacl::enable_if < viennacl::is_any_scalar< S1 > ::value, vector_base< T > & >::type | viennacl::operator*= (vector_base< T > &v1, S1 const &gpu_val)
| Scales this vector by a GPU scalar value. More...
template<typename T , typename S1 >
viennacl::enable_if < viennacl::is_any_scalar< S1 > ::value, vector_base< T > & >::type | viennacl::operator/= (vector_base< T > &v1, S1 const &gpu_val)
| Scales this vector by a GPU scalar value. More...
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 > | viennacl::operator+ (vector_expression< LHS1, RHS1, OP1 > const &proxy1, vector_expression< LHS2, RHS2, OP2 > const &proxy2)
| Operator overload for the addition of two vector expressions. More...
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const vector_expression< LHS, RHS, OP >, const vector_base< T > , viennacl::op_add > | viennacl::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. More...
template<typename T , typename LHS , typename RHS , typename OP >
vector_expression< const vector_base< T >, const vector_expression< LHS, RHS, OP >, viennacl::op_add > | viennacl::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. More...
template<typename T >
vector_expression< const vector_base< T >, const vector_base< T >, op_add > | viennacl::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. More...
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 > | viennacl::operator- (vector_expression< LHS1, RHS1, OP1 > const &proxy1, vector_expression< LHS2, RHS2, OP2 > const &proxy2)
| Operator overload for the subtraction of two vector expressions. More...
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const vector_expression< LHS, RHS, OP >, const vector_base< T > , viennacl::op_sub > | viennacl::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. More...
template<typename T , typename LHS , typename RHS , typename OP >
vector_expression< const vector_base< T >, const vector_expression< LHS, RHS, OP >, viennacl::op_sub > | viennacl::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. More...
template<typename T >
vector_expression< const vector_base< T >, const vector_base< T >, op_sub > | viennacl::operator- (const vector_base< T > &v1, const vector_base< T > &v2)
| Returns an expression template object for subtracting two vectors, i.e. v1 - v2. More...
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 | viennacl::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. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (char value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a char. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (short value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a short. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (int value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a int. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (long value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a long. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (float value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a float. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::operator* (double value, vector_base< T > const &vec)
| Operator overload for the expression alpha * v1, where alpha is a double. More...
template<typename LHS , typename RHS , typename OP , typename T >
vector_expression< const vector_base< T >, const scalar_expression< LHS, RHS, OP >, op_mult > | viennacl::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. More...
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 | viennacl::operator* (vector_base< T > const &vec, S1 const &value)
| Scales the vector by a scalar 'alpha' and returns an expression template. More...
template<typename T >
vector_expression< const vector_base< T >, const T, op_mult > | viennacl::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 | viennacl::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. More...
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 | viennacl::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. More...
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 | viennacl::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. More...
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 | viennacl::operator/ (vector_base< T > const &v1, S1 const &s1)
| Returns an expression template for scaling the vector by a GPU scalar 'alpha'. More...

## 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.

Definition in file vector.hpp.