All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vector_operations.hpp File Reference

Implementations of NMF operations using a plain single-threaded or OpenMP-enabled execution on CPU. More...

`#include <cmath>`
`#include <algorithm>`
`#include "viennacl/forwards.h"`
`#include "viennacl/scalar.hpp"`
`#include "viennacl/tools/tools.hpp"`
`#include "viennacl/meta/predicate.hpp"`
`#include "viennacl/meta/enable_if.hpp"`
`#include "viennacl/traits/size.hpp"`
`#include "viennacl/traits/start.hpp"`
`#include "viennacl/linalg/host_based/common.hpp"`
`#include "viennacl/linalg/detail/op_applier.hpp"`
`#include "viennacl/traits/stride.hpp"`

Go to the source code of this file.

## Namespaces

| viennacl
| Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
| viennacl::linalg
| Provides all linear algebra operations which are not covered by operator overloads.
| viennacl::linalg::host_based
| Holds all compute kernels with conventional host-based execution (buffers in CPU RAM).
| viennacl::linalg::host_based::detail
| Helper functions for the host-based linear algebra backend.

## Macros

#define | VIENNACL_OPENMP_VECTOR_MIN_SIZE 5000
#define | VIENNACL_INNER_PROD_IMPL_1(RESULTSCALART, TEMPSCALART)
#define | VIENNACL_INNER_PROD_IMPL_2(RESULTSCALART)
#define | VIENNACL_NORM_1_IMPL_1(RESULTSCALART, TEMPSCALART)
#define | VIENNACL_NORM_1_IMPL_2(RESULTSCALART, TEMPSCALART)
#define | VIENNACL_NORM_2_IMPL_1(RESULTSCALART, TEMPSCALART)
#define | VIENNACL_NORM_2_IMPL_2(RESULTSCALART, TEMPSCALART)

## Functions

template<typename NumericT >
NumericT | viennacl::linalg::host_based::detail::flip_sign (NumericT val)
unsigned long | viennacl::linalg::host_based::detail::flip_sign (unsigned long val)
unsigned int | viennacl::linalg::host_based::detail::flip_sign (unsigned int val)
unsigned short | viennacl::linalg::host_based::detail::flip_sign (unsigned short val)
unsigned char | viennacl::linalg::host_based::detail::flip_sign (unsigned char val)
template<typename DestNumericT , typename SrcNumericT >
void | viennacl::linalg::host_based::convert (vector_base< DestNumericT > &dest, vector_base< SrcNumericT > const &src)
template<typename NumericT , typename ScalarT1 >
void | viennacl::linalg::host_based::av (vector_base< NumericT > &vec1, vector_base< NumericT > const &vec2, ScalarT1 const &alpha, vcl_size_t, bool reciprocal_alpha, bool flip_sign_alpha)
template<typename NumericT , typename ScalarT1 , typename ScalarT2 >
void | viennacl::linalg::host_based::avbv (vector_base< NumericT > &vec1, vector_base< NumericT > const &vec2, ScalarT1 const &alpha, vcl_size_t, bool reciprocal_alpha, bool flip_sign_alpha, vector_base< NumericT > const &vec3, ScalarT2 const &beta, vcl_size_t, bool reciprocal_beta, bool flip_sign_beta)
template<typename NumericT , typename ScalarT1 , typename ScalarT2 >
void | viennacl::linalg::host_based::avbv_v (vector_base< NumericT > &vec1, vector_base< NumericT > const &vec2, ScalarT1 const &alpha, vcl_size_t, bool reciprocal_alpha, bool flip_sign_alpha, vector_base< NumericT > const &vec3, ScalarT2 const &beta, vcl_size_t, bool reciprocal_beta, bool flip_sign_beta)
template<typename NumericT >
void | viennacl::linalg::host_based::vector_assign (vector_base< NumericT > &vec1, const NumericT &alpha, bool up_to_internal_size=false)
| Assign a constant value to a vector (-range/-slice) More...
template<typename NumericT >
void | viennacl::linalg::host_based::vector_swap (vector_base< NumericT > &vec1, vector_base< NumericT > &vec2)
| Swaps the contents of two vectors, data is copied. More...
template<typename NumericT , typename OpT >
void | viennacl::linalg::host_based::element_op (vector_base< NumericT > &vec1, vector_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_element_binary< OpT > > const &proxy)
| Implementation of the element-wise operation v1 = v2 .* v3 and v1 = v2 ./ v3 (using MATLAB syntax) More...
template<typename NumericT , typename OpT >
void | viennacl::linalg::host_based::element_op (vector_base< NumericT > &vec1, vector_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_element_unary< OpT > > const &proxy)
| Implementation of the element-wise operation v1 = v2 .* v3 and v1 = v2 ./ v3 (using MATLAB syntax) More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::inner_prod_impl (vector_base< NumericT > const &vec1, vector_base< NumericT > const &vec2, ScalarT &result)
| Computes the inner product of two vectors - implementation. Library users should call inner_prod(vec1, vec2). More...
template<typename NumericT >
void | viennacl::linalg::host_based::inner_prod_impl (vector_base< NumericT > const &x, vector_tuple< NumericT > const &vec_tuple, vector_base< NumericT > &result)
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::norm_1_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the l^1-norm of a vector. More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::norm_2_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the l^2-norm of a vector - implementation. More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::norm_inf_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the supremum-norm of a vector. More...
template<typename NumericT >
vcl_size_t | viennacl::linalg::host_based::index_norm_inf (vector_base< NumericT > const &vec1)
| Computes the index of the first entry that is equal to the supremum-norm in modulus. More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::max_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the maximum of a vector. More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::min_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the minimum of a vector. More...
template<typename NumericT , typename ScalarT >
void | viennacl::linalg::host_based::sum_impl (vector_base< NumericT > const &vec1, ScalarT &result)
| Computes the sum of all elements from the vector. More...
template<typename NumericT >
void | viennacl::linalg::host_based::plane_rotation (vector_base< NumericT > &vec1, vector_base< NumericT > &vec2, NumericT alpha, NumericT beta)
| Computes a plane rotation of two vectors. More...
template<typename NumericT >
void | viennacl::linalg::host_based::detail::vector_scan_impl (vector_base< NumericT > const &vec1, vector_base< NumericT > &vec2, bool is_inclusive)
| Implementation of inclusive_scan and exclusive_scan for the host (OpenMP) backend. More...
template<typename NumericT >
void | viennacl::linalg::host_based::inclusive_scan (vector_base< NumericT > const &vec1, vector_base< NumericT > &vec2)
| This function implements an inclusive scan on the host using OpenMP. More...
template<typename NumericT >
void | viennacl::linalg::host_based::exclusive_scan (vector_base< NumericT > const &vec1, vector_base< NumericT > &vec2)
| This function implements an exclusive scan on the host using OpenMP. More...

## Detailed Description

Implementations of NMF operations using a plain single-threaded or OpenMP-enabled execution on CPU.

Implementations of vector operations using a plain single-threaded or OpenMP-enabled execution on CPU.

Definition in file vector_operations.hpp.

## Macro Definition Documentation

#define VIENNACL_INNER_PROD_IMPL_1 | ( |  | RESULTSCALART,
|  |  | TEMPSCALART
| ) |  |

Value:
inline RESULTSCALART inner_prod_impl(RESULTSCALART const * data_vec1, vcl_size_t start1, vcl_size_t inc1, vcl_size_t size1, \
RESULTSCALART const * data_vec2, vcl_size_t start2, vcl_size_t inc2) { \
TEMPSCALART temp = 0;
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::traits::start2
result_of::size_type< T >::type start2(T const &obj)
Definition: start.hpp:84
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::linalg::inner_prod_impl
void inner_prod_impl(vector_base< T > const &x, vector_tuple< T > const &y_tuple, vector_base< T > &result)
Computes the inner products <x, y1>, <x, y2>, ..., <x, y_N> and writes the result to a (sub-)vector...
Definition: vector_operations.hpp:530

Definition at line 405 of file vector_operations.hpp.

#define VIENNACL_INNER_PROD_IMPL_2 | ( |  | RESULTSCALART | ) |

Value:
for (long i = 0; i < static_cast<long>(size1); ++i) \
temp += data_vec1[static_cast<vcl_size_t>(i)*inc1+start1] * data_vec2[static_cast<vcl_size_t>(i)*inc2+start2]; \
return static_cast<RESULTSCALART>(temp); \
}
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::traits::start2
result_of::size_type< T >::type start2(T const &obj)
Definition: start.hpp:84
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75

Definition at line 410 of file vector_operations.hpp.

#define VIENNACL_NORM_1_IMPL_1 | ( |  | RESULTSCALART,
|  |  | TEMPSCALART
| ) |  |

Value:
inline RESULTSCALART norm_1_impl(RESULTSCALART const * data_vec1, vcl_size_t start1, vcl_size_t inc1, vcl_size_t size1) { \
TEMPSCALART temp = 0;
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::linalg::norm_1_impl
void norm_1_impl(viennacl::vector_expression< LHS, RHS, OP > const &vec, S2 &result)
Computes the l^1-norm of a vector - interface for a vector expression. Creates a temporary.
Definition: vector_operations.hpp:598

Definition at line 558 of file vector_operations.hpp.

#define VIENNACL_NORM_1_IMPL_2 | ( |  | RESULTSCALART,
|  |  | TEMPSCALART
| ) |  |

Value:
for (long i = 0; i < static_cast<long>(size1); ++i) \
temp += static_cast<TEMPSCALART>(std::fabs(static_cast<double>(data_vec1[static_cast<vcl_size_t>(i)*inc1+start1]))); \
return static_cast<RESULTSCALART>(temp); \
}
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65

Definition at line 562 of file vector_operations.hpp.

#define VIENNACL_NORM_2_IMPL_1 | ( |  | RESULTSCALART,
|  |  | TEMPSCALART
| ) |  |

Value:
inline RESULTSCALART norm_2_impl(RESULTSCALART const * data_vec1, vcl_size_t start1, vcl_size_t inc1, vcl_size_t size1) { \
TEMPSCALART temp = 0;
viennacl::linalg::opencl::norm_2_impl
void norm_2_impl(vector_base< T > const &vec, scalar< T > &result)
Computes the l^2-norm of a vector - implementation using OpenCL summation at second step...
Definition: vector_operations.hpp:801
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75

Definition at line 667 of file vector_operations.hpp.

#define VIENNACL_NORM_2_IMPL_2 | ( |  | RESULTSCALART,
|  |  | TEMPSCALART
| ) |  |

Value:
for (long i = 0; i < static_cast<long>(size1); ++i) { \
RESULTSCALART data = data_vec1[static_cast<vcl_size_t>(i)*inc1+start1]; \
temp += static_cast<TEMPSCALART>(data * data); \
} \
return static_cast<RESULTSCALART>(temp); \
}
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::traits::start1
result_of::size_type< T >::type start1(T const &obj)
Definition: start.hpp:65
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75

Definition at line 671 of file vector_operations.hpp.

#define VIENNACL_OPENMP_VECTOR_MIN_SIZE 5000

Definition at line 45 of file vector_operations.hpp.