• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ const_Vector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中const_Vector的典型用法代码示例。如果您正苦于以下问题:C++ const_Vector类的具体用法?C++ const_Vector怎么用?C++ const_Vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了const_Vector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: vector_add

void
vector_add(
  const_Vector<T, Block1> res,
  const_Vector<T, Block2> op1,
  const_Vector<T, Block3> op2)
{
  vsip::dda::Data<Block1, vsip::dda::out> raw_res(res.block());
  float*   p_raw   = raw_res.ptr();
  stride_type str_raw = raw_res.stride(0);

  vsip::dda::Data<Block2, vsip::dda::in> raw1(op1.block());
  float const *p1   = raw1.ptr();
  stride_type str1 = raw1.stride(0);

  vsip::dda::Data<Block3, vsip::dda::in> raw2(op2.block());
  float const *p2   = raw2.ptr();
  stride_type str2 = raw2.stride(0);

  for (index_type i=0; i<res.size(); ++i)
  {
    *p_raw = *p1 + *p2;

    p1    += str1;
    p2    += str2;
    p_raw += str_raw;
  }
}
开发者ID:bambang,项目名称:vsipl,代码行数:27,代码来源:extdata.cpp


示例2: dotp_ext

typename Promotion<T1, T2>::type
dotp_ext(
  const_Vector<T1, Block1> op1,
  const_Vector<T2, Block2> op2)
{
  typedef typename Promotion<T1, T2>::type value_type;

  test_assert(op1.size() == op2.size());

  vsip::dda::Data<Block1, dda::in> raw1(op1.block());
  T1 const *p1   = raw1.ptr();
  stride_type str1 = raw1.stride(0);

  vsip::dda::Data<Block2, dda::in> raw2(op2.block());
  T2 const *p2   = raw2.ptr();
  stride_type str2 = raw2.stride(0);

  value_type sum = value_type();
  
  for (index_type i=0; i<op1.size(); ++i)
  {
    sum  += *p1 * *p2;
    p1 += str1;
    p2 += str2;
  }

  return sum;
}
开发者ID:bambang,项目名称:vsipl,代码行数:28,代码来源:extdata.cpp


示例3: check_replicated_map

void
check_replicated_map(
  Replicated_map<Dim> const&          map,
  const_Vector<processor_type, Block> pset)
{
  typedef Replicated_map<Dim> map_type;
  typedef typename map_type::processor_iterator iterator;

  // Check num_processors()
  test_assert(map.num_processors() == pset.size());

  // Check processor_set()
  Vector<processor_type> map_pset = map.processor_set();

  test_assert(map_pset.size() == pset.size());
  for (index_type i=0; i<map_pset.size(); ++i)
    test_assert(map_pset(i) == pset(i));

  // Check processor_begin(), processor_end()
  iterator begin = map.processor_begin(0);
  iterator end   = map.processor_end(0);

  assert(static_cast<length_type>(end - begin) == pset.size());

  iterator cur = begin;
  while (cur != end)
  {
    index_type i = cur - begin;
    test_assert(*cur == pset(i));
    ++cur;
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:32,代码来源:replicated_map.cpp


示例4: error_db

double
error_db(const_Vector<T1, Block1> v1,
	 const_Vector<T2, Block2> v2)
{
  double refmax = 0.0;
  double maxsum = -250;
  double sum;

  Index<1> idx;

  refmax = maxval(magsq(v1), idx);

  for (index_type i=0; i<v1.size(); ++i)
  {
    double val = magsq(v1.get(i) - v2.get(i));

    if (val < 1.e-20)
      sum = -201.;
    else
      sum = 10.0 * log10(val/(2.0*refmax));

    if (sum > maxsum)
      maxsum = sum;
  }

  return maxsum;
}
开发者ID:fsheikh,项目名称:openvsip,代码行数:27,代码来源:matvec.cpp


示例5: check_length

void
check_length(const_Vector<T, Block> vec, length_type len)
{
  test_assert(vec.length() == len);
  test_assert(vec.size() == len);
  test_assert(vec.size(0) == len);
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:7,代码来源:vector.cpp


示例6: equal

inline bool equal(const_Vector<T1, B1> v, const_Vector<T2, B2> w)
{
  if (v.size() != w.size()) return false;
  for (length_type i = 0; i != v.size(); ++i)
    if (!equal(v.get(i), w.get(i)))
      return false;
  return true;
}
开发者ID:fsheikh,项目名称:openvsip,代码行数:8,代码来源:equal.hpp


示例7: check_vector

bool
check_vector(const_Vector<T, Block> vec, int k)
{
  for (index_type i=0; i<vec.size(0); ++i)
    if (!equal(vec.get(i), T(k*i+1)))
      return false;
  return true;
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:8,代码来源:vector.cpp


示例8: sum_view

T
sum_view(const_Vector<T, Block> view)
{
  T sum = T();
  for (index_type i=0; i<view.size(); ++i)
    sum += view.get(i);
  return sum;
}
开发者ID:bambang,项目名称:vsipl,代码行数:8,代码来源:extdata.cpp


示例9: tc_sum_const

T
tc_sum_const(const_Vector<T, Block> vec)
{
  T sumval = T();
  for (index_type i=0; i<vec.size(0); ++i)
    sumval += vec.get(i);
  return sumval;
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:8,代码来源:vector.cpp


示例10: operator

  void operator()(
    char const *            str,
    const_Vector<T, Block1> vin,
    Vector      <T, Block2> vout)
  {
    typedef vsip::impl::Layout<1, row1_type,
      vsip::impl::Stride_unit, vsip::impl::Cmplx_split_fmt>
		LP;
    typedef vsip::impl::Ext_data<Block1, LP> layout1;
    typedef vsip::impl::Ext_data<Block2, LP> layout2;

    // PROFILE: Check sizes, check layout costs.

    // Important to check size.  If vectors are too large, our
    // buffers will overflow.
    test_assert(vin.size()  == size_);
    test_assert(vout.size() == size_);

    if (verbose_)
    {
      cout << "Test_FFT_split: " << str << endl;
      cout << "Block_layout<Block1>:\n";
      print_layout<typename vsip::impl::Block_layout<Block1>::layout_type>(cout);
      cout << endl;
      
      cout << "LP:\n";
      print_layout<LP>(cout);
      cout << endl;
      
      cout << "  access_type<LP>(vin.block()) = "
	   <<    access_type<LP>(vin.block()) << endl;
      cout << "  access_type<LP>(vout.block()) = "
	   <<    access_type<LP>(vout.block()) << endl;
      
      cout << "  mem_required<LP>(vin.block()) = "
	   <<    vsip::impl::mem_required<LP>(vin.block()) << endl;
      cout << "  mem_required<LP>(vout.block()) = "
	   <<    vsip::impl::mem_required<LP>(vout.block()) << endl;
    }

    test_assert(vsip::impl::mem_required<LP>(vin.block())  <= sizeof(T)*size_);
    test_assert(vsip::impl::mem_required<LP>(vout.block()) <= sizeof(T)*size_);

    layout1 rin (vin.block(),  vsip::impl::SYNC_IN,  
		 make_pair(buffer_ + 0, buffer_ + size_));
    layout2 rout(vout.block(), vsip::impl::SYNC_OUT,
		 make_pair(buffer_ + 2*size_, buffer_ + 3*size_));

    test_assert(rin.stride(0) == 1);
    test_assert(rin.size(0) == size_);

    test_assert(rout.stride(0) == 1);
    test_assert(rout.size(0) == size_);

    fft_unit_stride_split(rin.data().first,  rin.data().second,
			  rout.data().first, rout.data().second,
			  size_);
  }
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:58,代码来源:extdata-fft.cpp


示例11: sum

T
sum(const_Vector<T, Block> v)
{
  // std::cout << "sum(" << Block_name<Block>::name() << ")\n";
  T total = T();
  for (index_type i=0; i<v.length(); ++i)
    total += v.get(i);
  return total;
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:9,代码来源:test.cpp


示例12: t_mul

inline
const_Vector<typename Promotion<T1, T2>::type,
	     expr::Binary<expr::op::Mult, Block1, Block2, true> const>
t_mul(const_Vector<T1, Block1> v1, const_Vector<T2, Block2> v2)
{
  typedef typename Promotion<T1, T2>::type RT;
  typedef expr::Binary<expr::op::Mult, Block1, Block2, true> block_t;

  return const_Vector<RT, const block_t>(block_t(v1.block(), v2.block()));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:10,代码来源:test.cpp


示例13: test_view

void
test_view(const_Vector<complex<T>, Block> vec, int k)
{
  for (index_type i=0; i<vec.size(0); ++i)
  {
    if (!equal(vec.get(i), complex<T>(T(k*i+1), T(k*i+2))))
    {
      cout << "ERROR: i        = " << i << endl
	   << "       Got      = " << vec.get(i) << endl
	   << "       expected = " << vec.get(i) << endl;
    }
    test_assert(equal(vec.get(i), complex<T>(T(k*i+1), T(k*i+2))));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:14,代码来源:extdata-fft.cpp


示例14: scale

lazy_Vector<T, Unary<Scale, BlockType> const>
scale(const_Vector<T, BlockType> input, T value)
{
  Scale<BlockType> s(input.block(), value);
  Unary<Scale, BlockType> block(s);
  return lazy_Vector<T, Unary<Scale, BlockType> const>(block);
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:7,代码来源:scale.hpp


示例15: sum_ext

T
sum_ext(const_Vector<T, Block> view)
{
  vsip::dda::Data<Block, dda::in> raw(view.block());
  float const *data   = raw.ptr();
  stride_type stride = raw.stride(0);

  T sum = T();
  
  for (index_type i=0; i<view.size(); ++i)
  {
    sum  += *data;
    data += stride;
  }

  return sum;
}
开发者ID:bambang,项目名称:vsipl,代码行数:17,代码来源:extdata.cpp


示例16: scale

const_Vector<T, Unary<Scale, BlockType> const>
scale(const_Vector<T, BlockType> input, T value)
{
  typedef Unary<Scale, BlockType> block_type;
  Scale<BlockType> s(input.block(), value);
  block_type block(s);
  return const_Vector<T, Unary<Scale, BlockType> const>(block);
}
开发者ID:fsheikh,项目名称:openvsip,代码行数:8,代码来源:scale.hpp


示例17: operator

  void 
  operator()(
    const_Vector<cscalar_f, Block1> in, 
    const_Vector<cscalar_f, Block2> coefficients,
    Vector<cscalar_f, Block3> out)
  {
    if((size() != in.size()) ||
       (size() != coefficients.size()) ||
       (size() != out.size()))
    {
      std::cout << "Error (class Filter): "
                << "all input and output views must be element-conformant" << std::endl;
      return;
    }

    out = i_fft_(coefficients * f_fft_(in));
  }
开发者ID:fsheikh,项目名称:openvsip,代码行数:17,代码来源:filter.cpp


示例18: t_neg

inline
const_Vector<T, expr::Unary<expr::op::Minus, Block, true> const>
t_neg(const_Vector<T, Block> v1)
{
  typedef expr::Unary<expr::op::Minus, Block, true> block_t;

  return const_Vector<T, const block_t>(block_t(v1.block()));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:8,代码来源:test.cpp


示例19: dotp_view

typename Promotion<T1, T2>::type
dotp_view(
  const_Vector<T1, Block1> op1,
  const_Vector<T2, Block2> op2)
{
  typedef typename Promotion<T1, T2>::type value_type;

  test_assert(op1.size() == op2.size());

  value_type sum = value_type();
  
  for (index_type i=0; i<op1.size(); ++i)
  {
    sum  += op1.get(i) * op2.get(i);
  }

  return sum;
}
开发者ID:bambang,项目名称:vsipl,代码行数:18,代码来源:extdata.cpp


示例20: scaled_interpolate

void 
scaled_interpolate(Vector<T, ResultBlockType> result,
                   const_Vector<T, ArgumentBlockType> argument,
                   T scale, length_type new_size)
{
  length_type old_size = argument.size();
  float stretch = static_cast<float>(new_size)/old_size;
  for (index_type i = 0; i != new_size; ++i)
  {
    float pos = i / stretch;
    index_type j = static_cast<index_type>(pos);
    float alpha = pos - j;
    if (j + 1 == old_size)
      result.put(i, scale * (argument.get(j) * alpha));
    else
      result.put(i, scale * (argument.get(j) * alpha + argument.get(j + 1) * (1 - alpha)));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:18,代码来源:evaluation.cpp



注:本文中的const_Vector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ const_additional_buffer_smart_ptr类代码示例发布时间:2022-05-31
下一篇:
C++ connection_ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap