本文整理汇总了C++中viennacl::vector_base::handle方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_base::handle方法的具体用法?C++ vector_base::handle怎么用?C++ vector_base::handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viennacl::vector_base
的用法示例。
在下文中一共展示了vector_base::handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NumericT
void MyOperator<NumericT>::apply_host(viennacl::vector_base<NumericT> const & x, viennacl::vector_base<NumericT> & y) const
{
NumericT const * values_x = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericT>(x.handle());
NumericT * values_y = viennacl::linalg::host_based::detail::extract_raw_pointer<NumericT>(y.handle());
NumericT dx = NumericT(1) / NumericT(N_ + 1);
NumericT dy = NumericT(1) / NumericT(N_ + 1);
/**
* In the following we iterate over all \f$ N \times N \f$ points and apply the five-point stencil directly.
* This is done in a straightforward manner for illustration purposes.
* Multi-threaded execution via OpenMP can be obtained by uncommenting the pragma below.
*
* Feel free to apply additional optimizations with respect to data access patterns and the like.
**/
// feel free to use
// #pragma omp parallel for
// here
for (std::size_t i=0; i<N_; ++i)
for (std::size_t j=0; j<N_; ++j)
{
NumericT value_right = (j < N_ - 1) ? values_x[ i *N_ + j + 1] : 0;
NumericT value_left = (j > 0 ) ? values_x[ i *N_ + j - 1] : 0;
NumericT value_top = (i < N_ - 1) ? values_x[(i+1)*N_ + j ] : 0;
NumericT value_bottom = (i > 0 ) ? values_x[(i-1)*N_ + j ] : 0;
NumericT value_center = values_x[i*N_ + j];
values_y[i*N_ + j] = ((value_right - value_center) / dx - (value_center - value_left) / dx) / dx
+ ((value_top - value_center) / dy - (value_center - value_bottom) / dy) / dy;
}
}