本文整理汇总了C++中viennacl::vector_base::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_base::size方法的具体用法?C++ vector_base::size怎么用?C++ vector_base::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viennacl::vector_base
的用法示例。
在下文中一共展示了vector_base::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memory_exception
typename viennacl::enable_if< viennacl::is_any_sparse_matrix<SparseMatrixType>::value>::type
prod_impl(const SparseMatrixType & mat,
const viennacl::vector_base<ScalarType> & vec,
viennacl::vector_base<ScalarType> & result)
{
assert( (mat.size1() == result.size()) && bool("Size check failed for compressed matrix-vector product: size1(mat) != size(result)"));
assert( (mat.size2() == vec.size()) && bool("Size check failed for compressed matrix-vector product: size2(mat) != size(x)"));
switch (viennacl::traits::handle(mat).get_active_handle_id())
{
case viennacl::MAIN_MEMORY:
viennacl::linalg::host_based::prod_impl(mat, vec, result);
break;
#ifdef VIENNACL_WITH_OPENCL
case viennacl::OPENCL_MEMORY:
viennacl::linalg::opencl::prod_impl(mat, vec, result);
break;
#endif
#ifdef VIENNACL_WITH_CUDA
case viennacl::CUDA_MEMORY:
viennacl::linalg::cuda::prod_impl(mat, vec, result);
break;
#endif
case viennacl::MEMORY_NOT_INITIALIZED:
throw memory_exception("not initialised!");
default:
throw memory_exception("not implemented");
}
}
示例2: assert
typename viennacl::enable_if< viennacl::is_any_sparse_matrix<SparseMatrixType>::value,
viennacl::vector<SCALARTYPE> >::type
operator-(viennacl::vector_base<SCALARTYPE> & result,
const viennacl::vector_expression< const SparseMatrixType, const viennacl::vector_base<SCALARTYPE>, viennacl::op_prod> & proxy)
{
assert(proxy.lhs().size1() == result.size() && bool("Dimensions for addition of sparse matrix-vector product to vector don't match!"));
vector<SCALARTYPE> temp(proxy.lhs().size1());
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), temp);
result += temp;
return result;
}
示例3: prod_impl
void prod_impl(const viennacl::toeplitz_matrix<SCALARTYPE, ALIGNMENT> & mat,
const viennacl::vector_base<SCALARTYPE> & vec,
viennacl::vector_base<SCALARTYPE> & result)
{
assert(mat.size1() == result.size());
assert(mat.size2() == vec.size());
viennacl::vector<SCALARTYPE> tmp(vec.size() * 4); tmp.clear();
viennacl::vector<SCALARTYPE> tmp2(vec.size() * 4);
viennacl::vector<SCALARTYPE> tep(mat.elements().size() * 2);
viennacl::linalg::real_to_complex(mat.elements(), tep, mat.elements().size());
viennacl::copy(vec.begin(), vec.end(), tmp.begin());
viennacl::linalg::real_to_complex(tmp, tmp2, vec.size() * 2);
viennacl::linalg::convolve(tep, tmp2, tmp);
viennacl::linalg::complex_to_real(tmp, tmp2, vec.size() * 2);
viennacl::copy(tmp2.begin(), tmp2.begin() + static_cast<vcl_ptrdiff_t>(vec.size()), result.begin());
}
示例4: prod_impl
void prod_impl(viennacl::circulant_matrix<NumericT, AlignmentV> const & mat,
viennacl::vector_base<NumericT> const & vec,
viennacl::vector_base<NumericT> & result)
{
assert(mat.size1() == result.size() && bool("Dimension mismatch"));
assert(mat.size2() == vec.size() && bool("Dimension mismatch"));
//result.clear();
//Rcpp::Rcout << "prod(circulant_matrix" << ALIGNMENT << ", vector) called with internal_nnz=" << mat.internal_nnz() << std::endl;
viennacl::vector<NumericT> circ(mat.elements().size() * 2);
viennacl::linalg::real_to_complex(mat.elements(), circ, mat.elements().size());
viennacl::vector<NumericT> tmp(vec.size() * 2);
viennacl::vector<NumericT> tmp2(vec.size() * 2);
viennacl::linalg::real_to_complex(vec, tmp, vec.size());
viennacl::linalg::convolve(circ, tmp, tmp2);
viennacl::linalg::complex_to_real(tmp2, result, vec.size());
}
示例5:
static vcl_size_t size2(viennacl::vector_base<ScalarType> const & /*lhs*/,
viennacl::vector_base<ScalarType> const & rhs) { return rhs.size(); }