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

C++ vsip_csl类代码示例

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

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



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

示例1: test_view_cast

void
test_view_cast(length_type size)
{
  Vector<T1> src(size);
  Vector<T2> dst(size);

  Rand<T1> rand(0);

  src = T1(100) * rand.randu(size);

  dst = vsip_csl::view_cast<T2>(src);

  for (index_type i=0; i<size; ++i)
    test_assert(equal(dst.get(i),
		      static_cast<T2>(src.get(i))));

  src = ramp(T1(0), T1(1), size);

  dst = vsip_csl::view_cast<T2>(src);

  T1 src_sum = expect_vector<T1>(src);
  T2 dst_sum = expect_vector<T2>(vsip_csl::view_cast<T2>(src));

  for (index_type i=0; i<size; ++i)
    test_assert(equal(dst.get(i),
		      static_cast<T2>(src.get(i))));

  test_assert(equal(dst_sum, static_cast<T2>(src_sum)));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:29,代码来源:view_cast.cpp


示例2: test_ukernel

void
test_ukernel(length_type rows, length_type cols)
{
  Madd_kernel obj;

  vsip_csl::ukernel::Ukernel<Madd_kernel> madd_uk(obj);

  Matrix<T1> in0(rows, cols);
  Matrix<T2> in1(rows, cols);
  Matrix<T2> in2(rows, cols);
  Matrix<T2> out(rows, cols);

  Rand<T1> gen1(0, 0);
  in0 = gen1.randu(rows, cols);

  Rand<T2> gen2(1, 0);
  in1 = gen2.randu(rows, cols);
  in2 = gen2.randu(rows, cols);

  madd_uk(in0, in1, in2, out);


  for (index_type i=0; i < rows; ++i)
    for (index_type j=0; j < cols; ++j)
    {
      T2 madd = in0.get(i, j) * in1.get(i, j) + in2.get(i, j);
      if (!equal(madd, out.get(i, j)))
      {
        std::cout << "index " << i << ", " << j << " : "
                  << in0.get(i, j) << " * "
                  << in1.get(i, j) << " + "
                  << in2.get(i, j) << " = "
                  << in0.get(i, j) * in1.get(i, j) + in2.get(i, j) << "  vs  "
                  << out.get(i, j)
                  << std::endl;
      }
      test_assert(equal(
          in0.get(i, j) * in1.get(i, j) + in2.get(i, j), 
          out.get(i, j)));
    }
}
开发者ID:somaproject,项目名称:thirdparty-packages,代码行数:41,代码来源:madd.cpp


示例3: A

void
test_vmul(length_type size)
{
  typedef impl::Layout<1, row1_type, impl::Stride_unit_dense, ComplexFmt>
		LP;
  typedef impl::Fast_block<1, T, LP> block_type;

  Vector<T, block_type> A(size, T(3));
  Vector<T, block_type> B(size, T(4));
  Vector<T, block_type> Z(size);

  Rand<T> gen(0, 0);
  A = gen.randu(size);
  B = gen.randu(size);

  Z = A * B;
  for (index_type i=0; i<size; ++i)
  {
    // Note: almost_equal is necessary for Cbe since SPE and PPE will not
    //       compute idential results.
#if VERBOSE
    if (!almost_equal(Z(i), A(i) * B(i)))
    {
      std::cout << "Z(i)        = " << Z(i) << std::endl;
      std::cout << "A(i) * B(i) = " << A(i) * B(i) << std::endl;
    }
#endif
    test_assert(almost_equal(Z.get(i), A(i) * B(i)));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:30,代码来源:large_vmul.cpp


示例4: uk

void
test_ukernel(length_type size)
{
  Id1 cuk;

  Ukernel<Id1> uk(cuk);

  Vector<T> in(size);
  Vector<T> out(size);

  in = ramp<T>(0, 0.1, size);

  uk(in, out);

  for (index_type i=0; i<size; ++i)
  {
    if (!equal(out.get(i), in.get(i) + T(i)))
    {
      std::cout << i << ": " << out.get(i) << " != "
		<< in.get(i) << " + " << T(i)
		<< std::endl;
    }
    test_assert(equal(out.get(i), in.get(i) + T(i)));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:25,代码来源:id1.cpp


示例5: T

void
test_funcall()
{
  length_type const len = 10;
  Vector<T> v1(len, T());
  Vector<T> v2(len, T());
  Vector<T> v3(len, T());

  v1.put(1, T(1));
  v2.put(1, T(2));
  v3.put(1, T(3));

  T s1 = sum(v1);

  T s2 = sum(t_add(v1, v2));

  const_Vector<T, expr::Binary<expr::op::Add, Dense<1, T>, Dense<1, T>, true> const> vx(t_add(v1, v2));
  T s3 = sum(vx);

  T s4 = sum(t_add(t_mul(v2, v3), t_neg(t_add(v1, v3))));

#if ILLEGALCASE == 1
  // It should not be possible to pass an expression template (which is
  // a const_Vector) to a function expecting a Vector.
  T s5 = vector_sum(t_add(t_mul(v2, v3), t_neg(t_add(v1, v3))));
#endif

  test_assert(equal(s1, T(1)));
  test_assert(equal(s2, T(3)));
  test_assert(equal(s3, T(3)));
  test_assert(equal(s4, T(2)));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:32,代码来源:test.cpp


示例6: T

void
test_transpose_readonly(MatrixT view)
{
  typedef typename MatrixT::value_type T;

  // Check that view is initialized
  check_matrix(view, 0);

  length_type const size1 = view.size(1);

  typename MatrixT::const_transpose_type trans = view.transpose();

  test_assert(trans.size(0) == view.size(1));
  test_assert(trans.size(1) == view.size(0));

  for (index_type idx0=0; idx0<trans.size(0); ++idx0)
    for (index_type idx1=0; idx1<trans.size(1); ++idx1)
    {
      T expected = T(idx1 * size1 + idx0 + 0);
      test_assert(equal(trans.get(idx0, idx1), expected));
      test_assert(equal(trans.get(idx0,  idx1),
		   view. get(idx1, idx0)));
      }

  // Check that view is unchanged
  check_matrix(view, 0);
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:27,代码来源:matrix-transpose.cpp


示例7: T

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


示例8: operator

  void operator()(length_type size, length_type loop, float& time)
  {
    Vector<T>   A(size, T());
    Vector<T>   Z(size);

#if 0
    // int const no_times = 0; // FFTW_PATIENT
    int const no_times = 15; // not > 12 = FFT_MEASURE

    typedef Fft<const_Vector, T, T, fft_fwd, by_reference, no_times, alg_time>
      fft_type;
#else
    typedef ErsatzFFT<-1, T> fft_type;
#endif

    fft_type fft(Domain<1>(size), 1.f);

    A = T(1);
    
    vsip::impl::profile::Timer t1;
    
    t1.start();
    for (index_type l=0; l<loop; ++l)
      fft(A, Z);
    t1.stop();
    
    if (!equal(Z(0), T(size)))
    {
      std::cout << "t_fft: ERROR" << std::endl;
      abort();
    }
    
    time = t1.delta();
  }
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:34,代码来源:fft_ext.cpp


示例9: fftm

void
test_fftm_op_align(
  length_type rows,
  length_type size,
  length_type gap,
  length_type align)
{
#if VERBOSE
  std::cout << "fftm_op_align(" << rows << " x " << size
	    << ", gap " << gap
	    << ", align " << align << ")\n";
#endif

  typedef impl::Stride_unit_dense sud_type;
  typedef impl::Layout<2, row2_type, sud_type, ComplexFmt> lp_type;

  typedef impl::Fast_block<2, T, lp_type> block_type;

  typedef Fftm<T, T, row, fft_fwd, by_reference, 1, alg_space> fftm_type;

  fftm_type fftm(Domain<2>(rows, size), 1.f);

  Matrix<T, block_type> in (rows, size + gap);
  Matrix<T, block_type> out(rows, size + gap);

  for (index_type i=0; i<rows; ++i)
    in.row(i) = T(i+1);

  fftm(in (Domain<2>(rows, Domain<1>(align, 1, size))),
       out(Domain<2>(rows, Domain<1>(align, 1, size))));

  for (index_type i=0; i<rows; ++i)
  {
    T got = out.get(i, align);
#if VERBOSE
    if (!equal(got, T((i+1)*size)))
    {
      std::cout << "Error: row " << i << std::endl
		<< "     : expected " << T((i+1)*size) << std::endl
		<< "     : got      " << got << std::endl
		<< "     : got      " << out.get(i, align) << std::endl
	;
    }
#endif
    test_assert(equal(got, T((i+1)*size)));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:47,代码来源:fftm_unaligned.cpp


示例10: fun

bool
check_interleaved_array(
  T*                 data,
  Domain<Dim> const& dom,
  Func               fun)
{
  Length<Dim> ext = impl::extent(dom);
  for (Index<Dim> idx; valid(ext,idx); next(ext, idx))
  {
    index_type i = to_index<Order>(ext, idx);
    complex<T> val = fun(i);
    if (!equal(data[2*i+0], val.real()) ||
	!equal(data[2*i+1], val.imag()))
      return false;
  }
  return true;
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:17,代码来源:user_storage.cpp


示例11: block

void
test_1_low()
{
  length_type const size = 10;

  typedef typename Block::value_type value_type;

  Block block(size, 0.0);

  value_type val0 =  1.0f;
  value_type val1 =  2.78f;
  value_type val2 =  3.14f;
  value_type val3 = -1.5f;

  // Place values in block.
  block.put(0, val0);
  block.put(1, val1);

  {
    vsip::dda::impl::Accessor<Block,
      typename Block::layout_type,
      AccessTag>
      raw(block);

    // Check properties of LLDI.
    test_assert(raw.stride(&block, 0) == 1);
    test_assert(raw.size(&block, 0) == size);

    float* data = raw.ptr(&block);
    raw.begin(&block, true);

    // Check that block values are reflected.
    test_assert(equal(data[0], val0));
    test_assert(equal(data[1], val1));

    // Place values in raw data.
    data[1] = val2;
    data[2] = val3;

    raw.end(&block, true);
  }

  // Check that raw data values are reflected.
  test_assert(equal(block.get(1), val2));
  test_assert(equal(block.get(2), val3));
}
开发者ID:bambang,项目名称:vsipl,代码行数:46,代码来源:extdata.cpp


示例12: exec

  void exec(length_type rows, length_type cols, length_type loop, float& time)
  {
    Matrix<T1, src_block_t>   A(rows, cols);
    Matrix<T2, dst_block_t>   Z(rows, cols, T2());
    for (index_type i = 0; i < rows; ++i)
      for (index_type j = 0; j < cols; ++j)
        A.put(i, j, T1(i * cols + j, -0.5));

    // Scoping is used to control the lifetime of Ext_data<> objects.  These 
    // must be destroyed before accessing data through the view again.
    {     
      impl::cuda::Device_memory<src_block_t const> dev_a(A.block());
      impl::cuda::Device_memory<dst_block_t> dev_z(Z.block());
      T1 const* pA = dev_a.data();
      T2* pZ = dev_z.data();

      // Benchmark the operation
      vsip::impl::profile::Timer t1;
      t1.start();
      for (index_type l = 0; l < loop; ++l)
      {
        this->functor_(pA, pZ, rows, cols);
        cudaThreadSynchronize();
      }
      t1.stop();
      time = t1.delta();
    }

    // validate results
    for (index_type i = 0; i < rows; ++i)
      for (index_type j = 0; j < cols; ++j)
      {
#if DEBUG
        if (!equal(F::apply(A.get(i, j)), Z.get(i, j)))
        {
          cout << "ERROR: at location " << i << ", " << j << endl
                    << "       expected: " << F::apply(A.get(i, j)) << endl
                    << "       got     : " << Z.get(i, j) << endl;
        }
#endif
        test_assert(equal(F::apply(A.get(i, j)), Z.get(i, j)));
      }
  }
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:43,代码来源:unary.cpp


示例13: a

void
test_real_subview_vector_freqswap( length_type m )
{
  Vector<complex<T> > a(m);

  a.real() = ramp<T>(0, 1, m);
  a.imag() = T(0);

  Vector<T> b(m);
  Vector<complex<T> > c(m, T());
  b = vsip::freqswap(a.real());
  c.real() = a.real(); c.real() = vsip::freqswap(c.real());

  for ( index_type i = 0; i < m; i++ )
  {
    test_assert(equal( b.get(i), a.real().get(((m+1)/2 + i) % m ) ));
    test_assert(equal( c.real().get(i), a.real().get(((m+1)/2 + i) % m ) ));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:19,代码来源:freqswap.cpp


示例14: operator

  void operator()(length_type size, length_type loop, float& time)
  {
    using namespace vsip::impl;

    typedef Dense<1,T,row1_type,MapT> block_type;
    typedef reduction_op_eval<Max_value,T,block_type,1,Tag> eval;

    create_test_vector_helper<MapT,Vector,float,Dense<1,T,row1_type,MapT> >
      ctvh(size);

    T                      val = T();
    Index<1>               idx;

    Rand<T>     gen(0, 0);

    if (init_ == 0)
      ctvh.assign_view(gen.randu(size));
    else if (init_ == 1)
      ctvh.assign_view(ramp(T(0), T(1), size));
    else if (init_ == 2)
      ctvh.assign_view(ramp(T(size-1), T(-1), size));
   
    vsip::impl::profile::Timer t1;
    
    t1.start();
    for (index_type l=0; l<loop; ++l)
      eval::exec(val, ctvh.view.block(), idx);
    t1.stop();

    if (init_ == 1)
    {
      test_assert(equal(val, T(size-1)));
      test_assert(idx == size-1);
    }
    else if (init_ == 2)
    {
      test_assert(equal(val, T(size-1)));
      test_assert(idx == 0);
    }
    
    time = t1.delta();
  }
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:42,代码来源:maxval.cpp


示例15: a

void
test_cvjdot_rand(length_type m)
{
  typedef typename Promotion<T0, T1>::type return_type;
  typedef typename vsip::impl::Scalar_of<return_type>::type scalar_type;

  Vector<T0> a(m);
  Vector<T1> b(m);

  randv(a);
  randv(b);

  // Test vector-vector prod
  return_type val  = cvjdot(a, b);
  return_type chk1 = dot(a, conj(b));
  return_type chk2 = ref::dot(a, conj(b));

  test_assert(equal(val, chk1));
  test_assert(equal(val, chk2));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:20,代码来源:matvec-dot.cpp


示例16: float

void
test_view_functions()
{
  length_type size = 10;
  Vector<float> view1(size);
  Vector<float> view2(size);
  
  for (index_type i=0; i<size; ++i)
  {
    view1.put(i, float(i+1));
    view2.put(i, float(2*i+1));
  }

  test_assert(equal(sum_view(view1), sum_ext(view1)));
  test_assert(equal(sum_view(view2), sum_ext(view2)));

  float prod_v = dotp_view(view1, view2);
  float prod_e  = dotp_ext(view1, view2);

  test_assert(equal(prod_v, prod_e));
}
开发者ID:bambang,项目名称:vsipl,代码行数:21,代码来源:extdata.cpp


示例17:

void
test_mag()
{
  Storage<Dim, T1> Z;
  Storage<Dim, T2> A;

  put_nth(A.view, 0, T2(-3));

  Z.view = vsip::mag(A.view);

  test_assert(equal(get_nth(Z.view, 0), T1(3)));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:12,代码来源:fns_scalar.cpp


示例18: get

void
check_block(Block& blk, int k)
{
  typedef typename Block::value_type value_type;

  Length<Dim> ex = extent<Dim>(blk);
  for (Index<Dim> idx; valid(ex,idx); next(ex, idx))
  {
    test_assert(equal( get(blk, idx),
		  identity<value_type>(ex, idx, k)));
  }
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:12,代码来源:fast-block.cpp


示例19: input

void
test_arg()
{
  Storage<Dim, T1> Z;
  Storage<Dim, T2> A;

  T2 input(3., 6.);

  put_nth(A.view, 0, input);

  Z.view = vsip::arg(A.view);

  test_assert(equal(get_nth(Z.view, 0), std::arg(input)));
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:14,代码来源:fns_scalar.cpp


示例20:

bool
check_array(
  T*                 data,
  Domain<Dim> const& dom,
  Func               fun)
{
  Length<Dim> ext = impl::extent(dom);
  for (Index<Dim> idx; valid(ext,idx); next(ext, idx))
  {
    index_type i = to_index<Order>(ext, idx);
    if (!equal(data[i], fun(i)))
      return false;
  }
  return true;
}
开发者ID:BackupTheBerlios,项目名称:openvsipl,代码行数:15,代码来源:user_storage.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ vstring类代码示例发布时间:2022-05-31
下一篇:
C++ vs_output类代码示例发布时间: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