本文整理汇总了C++中vector_expression类的典型用法代码示例。如果您正苦于以下问题:C++ vector_expression类的具体用法?C++ vector_expression怎么用?C++ vector_expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector_expression类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assign
void assign(
vector_expression<V>& v, vector_expression<E> const& e,
dense_random_access_iterator_tag, packed_random_access_iterator_tag
) {
SIZE_CHECK(v().size() == e().size());
typedef typename E::const_iterator EIterator;
typedef typename V::scalar_type scalar_type;
EIterator eiter = e.begin();
EIterator eend = e.end();
//special case:
//right hand side is completely 0
if(eiter == eend) {
v().clear();
return;
}
EIterator viter = v.begin();
EIterator vend = v.end();
//set the first elements to zero
for(; viter.index() != eiter.index(); ++viter) {
*viter= scalar_type/*zero*/();
}
//copy contents of right-hand side
for(; eiter != eend; ++eiter,++viter) {
*viter= *eiter;
}
for(; viter!= vend; ++viter) {
*viter= scalar_type/*zero*/();
}
}
开发者ID:sunmeng007,项目名称:Shark,代码行数:31,代码来源:vector_assign.hpp
示例2: assign
void assign(
vector_expression<V>& v, vector_expression<E> const& e,
packed_random_access_iterator_tag, packed_random_access_iterator_tag
) {
SIZE_CHECK(v().size() == e().size());
typedef typename E::const_iterator EIterator;
EIterator eiter = e.begin();
EIterator eend = e.end();
//special case:
//right hand side is completely 0
if(eiter == eend){
v().clear();
return;
}
EIterator viter = v.begin();
EIterator vend = v.end();
//check for compatible layout
SIZE_CHECK(vend-viter);//empty ranges can't be compatible
//check whether the right hand side range is included in the left hand side range
SIZE_CHECK(viter.index() <= eiter.index());
SIZE_CHECK(viter.index()+(vend-viter) >= eiter.index()+(eend-eiter));
//copy contents of right-hand side
viter += eiter.index()-viter.index();
for(;eiter != eend; ++eiter,++viter){
*viter= *eiter;
}
}
开发者ID:CptCapy,项目名称:Programming_Shark,代码行数:29,代码来源:vector_assign.hpp
示例3: assert
viennacl::vector<SCALARTYPE, ALIGNMENT>
viennacl::vector<SCALARTYPE, ALIGNMENT>::operator-(const vector_expression< const hankel_matrix<SCALARTYPE, MAT_ALIGNMENT>,
const vector<SCALARTYPE, ALIGNMENT>,
op_prod> & proxy)
{
assert(proxy.get_lhs().size1() == size());
vector<SCALARTYPE, ALIGNMENT> result(size());
viennacl::linalg::prod_impl(proxy.lhs(), proxy.rhs(), result);
result = *this - result;
return result;
}
开发者ID:aokomoriuta,项目名称:ViennaCLFiles,代码行数:11,代码来源:hankel_matrix_operations.hpp
示例4: size
vcl_size_t size(vector_expression<LHS, const int, op_matrix_diag> const & proxy)
{
int k = proxy.rhs();
int A_size1 = static_cast<int>(size1(proxy.lhs()));
int A_size2 = static_cast<int>(size2(proxy.lhs()));
int row_depth = std::min(A_size1, A_size1 + k);
int col_depth = std::min(A_size2, A_size2 - k);
return std::min(row_depth, col_depth);
}
开发者ID:KratosCSIC,项目名称:trunk,代码行数:11,代码来源:size.hpp
示例5: apply
static void apply(vector_base<T> & lhs, vector_expression<const vandermonde_matrix<T, A>, const vector_base<T>, op_prod> const & rhs)
{
// check for the special case x = A * x
if (viennacl::traits::handle(lhs) == viennacl::traits::handle(rhs.rhs()))
{
viennacl::vector<T> temp(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), temp);
lhs = temp;
}
else
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), lhs);
}
开发者ID:GnsP,项目名称:viennacl-dev,代码行数:12,代码来源:vandermonde_matrix.hpp
示例6: size
typename viennacl::enable_if< viennacl::is_any_matrix<LHS>::value
&& viennacl::is_any_dense_nonstructured_vector<RHS>::value,
vcl_size_t >::type
size(vector_expression<const LHS, const RHS, op_prod> const & proxy) //matrix-vector product
{
return proxy.lhs().size1();
}
开发者ID:AngeloTorelli,项目名称:CompuCell3D,代码行数:7,代码来源:size.hpp
示例7: element_op
void element_op(vector_base<T> & vec1,
vector_expression<const vector_base<T>, const vector_base<T>, op_element_binary<OP> > const & proxy)
{
typedef T value_type;
typedef viennacl::linalg::detail::op_applier<op_element_binary<OP> > OpFunctor;
value_type * data_vec1 = detail::extract_raw_pointer<value_type>(vec1);
value_type const * data_vec2 = detail::extract_raw_pointer<value_type>(proxy.lhs());
value_type const * data_vec3 = detail::extract_raw_pointer<value_type>(proxy.rhs());
std::size_t start1 = viennacl::traits::start(vec1);
std::size_t inc1 = viennacl::traits::stride(vec1);
std::size_t size1 = viennacl::traits::size(vec1);
std::size_t start2 = viennacl::traits::start(proxy.lhs());
std::size_t inc2 = viennacl::traits::stride(proxy.lhs());
std::size_t start3 = viennacl::traits::start(proxy.rhs());
std::size_t inc3 = viennacl::traits::stride(proxy.rhs());
#ifdef VIENNACL_WITH_OPENMP
#pragma omp parallel for if (size1 > VIENNACL_OPENMP_VECTOR_MIN_SIZE)
#endif
for (std::size_t i = 0; i < size1; ++i)
OpFunctor::apply(data_vec1[i*inc1+start1], data_vec2[i*inc2+start2], data_vec3[i*inc3+start3]);
}
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:26,代码来源:vector_operations.hpp
示例8: element_op
void element_op(vector_base<NumericT> & vec1,
vector_expression<const vector_base<NumericT>, const vector_base<NumericT>, op_element_unary<OpT> > const & proxy)
{
typedef NumericT value_type;
typedef viennacl::linalg::detail::op_applier<op_element_unary<OpT> > OpFunctor;
value_type * data_vec1 = detail::extract_raw_pointer<value_type>(vec1);
value_type const * data_vec2 = detail::extract_raw_pointer<value_type>(proxy.lhs());
vcl_size_t start1 = viennacl::traits::start(vec1);
vcl_size_t inc1 = viennacl::traits::stride(vec1);
vcl_size_t size1 = viennacl::traits::size(vec1);
vcl_size_t start2 = viennacl::traits::start(proxy.lhs());
vcl_size_t inc2 = viennacl::traits::stride(proxy.lhs());
#ifdef VIENNACL_WITH_OPENMP
#pragma omp parallel for if (size1 > VIENNACL_OPENMP_VECTOR_MIN_SIZE)
#endif
for (long i = 0; i < static_cast<long>(size1); ++i)
OpFunctor::apply(data_vec1[static_cast<vcl_size_t>(i)*inc1+start1], data_vec2[static_cast<vcl_size_t>(i)*inc2+start2]);
}
开发者ID:d-meiser,项目名称:viennacl-dev,代码行数:22,代码来源:vector_operations.hpp
示例9: size
vcl_size_t size(vector_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
const vector_base<NumericT>,
op_prod> const & proxy)
{
return size1(proxy.lhs());
}
开发者ID:a9raag,项目名称:mahout,代码行数:6,代码来源:size.hpp
示例10: op_aliasing
bool op_aliasing(vector_base<NumericT> const & lhs, vector_expression<const LhsT, const RhsT, OpT> const & rhs)
{
return op_aliasing(lhs, rhs.lhs()) || op_aliasing(lhs, rhs.rhs());
}
开发者ID:10imaging,项目名称:viennacl,代码行数:4,代码来源:op_executor.hpp
注:本文中的vector_expression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论