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

C++ V1类代码示例

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

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



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

示例1: apply

 static void apply(Alpha a, const V1 &x, const V2 &y, Beta b, V3 &z)
 {
     if (!math::is_zero(b))
         z.array() = a * x.array() * y.array() + b * z.array();
     else
         z.array() = a * x.array() * y.array();
 }
开发者ID:HongLi15,项目名称:amgcl,代码行数:7,代码来源:eigen.hpp


示例2: foo

void foo( D *p )
{
    for( int i = 0; i < 10; ++i ) {
        V1 *q = p;                      // assignment to 'q' should be brought
                                        // outside the loop
        q->bar( p->V1::v1 + p->V2::v1, p->V1::v2 + p->V2::v2 );
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:8,代码来源:vbase01.c


示例3: renormalise

void bi::renormalise(V1 lws) {
  thrust::replace_if(lws.begin(), lws.end(), is_not_finite_functor<real>(),
      bi::log(0.0));
  real mx = max_reduce(lws);
  if (is_finite(mx)) {
    sub_elements(lws, mx, lws);
  }
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:8,代码来源:misc.hpp


示例4: cov

void bi::cov(const M1 X, const V1 mu, M2 Sigma) {
  /* pre-conditions */
  BI_ASSERT(X.size2() == mu.size());
  BI_ASSERT(Sigma.size1() == mu.size() && Sigma.size2() == mu.size());

  const int N = X.size1();
  typename sim_temp_matrix<M2>::type Y(X.size1(), X.size2());
  Y = X;
  sub_rows(Y, mu);
  syrk(1.0/(N - 1.0), Y, 0.0, Sigma, 'U', 'T');
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:11,代码来源:misc.hpp


示例5: GECODE_ME_CHECK

 ExecStatus
 Int<V0,V1,Idx,Val>::post(Home home, IntSharedArray& c, V0 x0, V1 x1) {
   if (x0.assigned()) {
     GECODE_ME_CHECK(x1.eq(home,c[x0.val()]));
   } else if (x1.assigned()) {
     GECODE_ES_CHECK(assigned_val(home,c,x0,x1));
   } else {
     (void) new (home) Int<V0,V1,Idx,Val>(home,c,x0,x1);
   }
   return ES_OK;
 }
开发者ID:,项目名称:,代码行数:11,代码来源:


示例6: MiscCheckTheParallelEnvironment

void
MiscCheckTheParallelEnvironment(const V1& vec1, const V2& vec2)
{
  const BaseEnvironment& env = vec1.env();

  if (env.numSubEnvironments() == (unsigned int) env.fullComm().NumProc()) {
    UQ_FATAL_TEST_MACRO(env.subRank() != 0,
                        env.worldRank(),
                        "MiscCheckTheParallelEnvironment<V1,V2>()",
                        "there should exist only one processor per sub environment");
    UQ_FATAL_TEST_MACRO((vec1.numOfProcsForStorage() != 1) ||
                        (vec2.numOfProcsForStorage() != 1),
                        env.worldRank(),
                        "MiscCheckTheParallelEnvironment<V1,V2>()",
                        "only 1 processor (per sub environment) should be necessary for the storage of a parameter vector");
  }
  else if (env.numSubEnvironments() < (unsigned int) env.fullComm().NumProc()) {
    UQ_FATAL_TEST_MACRO(env.fullComm().NumProc()%env.numSubEnvironments() != 0,
                        env.worldRank(),
                        "MiscCheckTheParallelEnvironment<V1,V2>()",
                        "total number of processors should be a multiple of the number of sub environments");
    unsigned int numProcsPerSubEnvironment = env.fullComm().NumProc()/env.numSubEnvironments();
    UQ_FATAL_TEST_MACRO(env.subComm().NumProc() != (int) numProcsPerSubEnvironment,
                        env.worldRank(),
                        "MiscCheckTheParallelEnvironment<V1,V2>()",
                        "inconsistent number of processors per sub environment");
    if ((vec1.numOfProcsForStorage() == 1) &&
        (vec2.numOfProcsForStorage() == 1)) {
      // Ok
    }
    else if ((vec1.numOfProcsForStorage() == numProcsPerSubEnvironment) &&
             (vec2.numOfProcsForStorage() == numProcsPerSubEnvironment)) {
      UQ_FATAL_TEST_MACRO(true,
                          env.worldRank(),
                          "MiscCheckTheParallelEnvironment<V1,V2>()",
                          "parallel vectors are not supported yet");
    }
    else {
      UQ_FATAL_TEST_MACRO(true,
                          env.worldRank(),
                          "MiscCheckTheParallelEnvironment<V1,V2>()",
                          "number of processors required for a vector storage should be equal to either 1 or to the number of processors in the sub environment");
    }
  }
  else {
    UQ_FATAL_TEST_MACRO(true,
                        env.worldRank(),
                        "MiscCheckTheParallelEnvironment<V1,V2>()",
                        "number of processors per sub environment is less than 1!");
  }

  return;
}
开发者ID:brianw525,项目名称:queso,代码行数:53,代码来源:Miscellaneous.C


示例7: var

void bi::var(const M1 X, const V1 mu, V2 sigma) {
  /* pre-conditions */
  BI_ASSERT(X.size2() == mu.size());
  BI_ASSERT(sigma.size() == mu.size());

  const int N = X.size1();
  typename sim_temp_matrix<M1>::type Z(X.size2(), X.size1());
  Z = X;
  sub_rows(Z, mu);
  dot_columns(Z, sigma);
  scal(1.0/(N - 1.0), sigma);
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:12,代码来源:misc.hpp


示例8: cross

void bi::cross(const M1 X, const M2 Y, const V1 muX, const V2 muY,
    M3 SigmaXY) {
  /* pre-conditions */
  BI_ASSERT(X.size2() == muX.size());
  BI_ASSERT(Y.size2() == muY.size());
  BI_ASSERT(X.size1() == Y.size1());
  BI_ASSERT(SigmaXY.size1() == muX.size() && SigmaXY.size2() == muY.size());

  const int N = X.size1();

  gemm(1.0/(N - 1.0), X, Y, 0.0, SigmaXY, 'T', 'N');
  ger(-N/(N - 1.0), muX, muY, SigmaXY);
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:13,代码来源:misc.hpp


示例9: BI_ASSERT

void bi::inverse_gamma_log_densities(const M1 Z, const T1 alpha, const T1 beta,
    V1 p, const bool clear) {
  /* pre-condition */
  BI_ASSERT(Z.size1() == p.size());

  op_elements(vec(Z), vec(Z), inverse_gamma_log_density_functor<T1>(alpha, beta));
  if (clear) {
    sum_columns(Z, p);
  } else {
    typename sim_temp_vector<V1>::type p1(p.size());
    sum_columns(Z, p1);
    add_elements(p, p1, p);
  }
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:14,代码来源:primitive.hpp


示例10: lws

void bi::MetropolisResamplerHost::ancestors(Random& rng, const V1 lws,
    V2 as, int B) {
  const int P1 = lws.size(); // number of particles
  const int P2 = as.size(); // number of ancestors to draw

  #pragma omp parallel
  {
    real alpha, lw1, lw2;
    int k, p1, p2, p;

    #pragma omp for
    for (p = 0; p < P2; ++p) {
      p1 = p;
      lw1 = lws(p);
      for (k = 0; k < B; ++k) {
        p2 = rng.uniformInt(0, P1 - 1);
        lw2 = lws(p2);
        alpha = rng.uniform<real>();

        if (bi::log(alpha) < lw2 - lw1) {
          /* accept */
          p1 = p2;
          lw1 = lw2;
        }
      }

      /* write result */
      as(p) = p1;
    }
  }
}
开发者ID:JohannesBuchner,项目名称:LibBi,代码行数:31,代码来源:MetropolisResamplerHost.hpp


示例11: apply_incompatible

 result_type apply_incompatible( const V1& src, const V2& dst) const
 {
     //copy_pixels( color_converted_view<typename V2::value_type>( src, _cc),dst);
     tbb::parallel_for( tbb::blocked_range<std::size_t>( 0, src.height()),
                         detail::make_tbb_copy_pixels_fun( color_converted_view<typename V2::value_type>( src, _cc), dst),
                         GIL_TBB_ALGORITHMS_DEFAULT_PARTITIONER());
 }
开发者ID:JohanAberg,项目名称:Ramen,代码行数:7,代码来源:tbb_copy.hpp


示例12: inplace_solve

    typename viennacl::enable_if<    viennacl::is_any_dense_nonstructured_matrix<M1>::value
                                  && viennacl::is_any_dense_nonstructured_vector<V1>::value
                                >::type
    inplace_solve(const matrix_expression< const M1, const M1, op_trans> & proxy,
                  V1 & vec,
                  SOLVERTAG)
    {
      assert( (proxy.lhs().size1() == vec.size()) && bool("Size check failed in inplace_solve(): size1(A) != size(b)"));
      assert( (proxy.lhs().size2() == vec.size()) && bool("Size check failed in inplace_solve(): size2(A) != size(b)"));

      switch (viennacl::traits::handle(proxy.lhs()).get_active_handle_id())
      {
        case viennacl::MAIN_MEMORY:
          viennacl::linalg::host_based::inplace_solve(proxy, vec, SOLVERTAG());
          break;
#ifdef VIENNACL_WITH_OPENCL
        case viennacl::OPENCL_MEMORY:
          viennacl::linalg::opencl::inplace_solve(proxy, vec, SOLVERTAG());
          break;
#endif
#ifdef VIENNACL_WITH_CUDA
        case viennacl::CUDA_MEMORY:
          viennacl::linalg::cuda::inplace_solve(proxy, vec, SOLVERTAG());
          break;
#endif
        default:
          throw "not implemented";
      }
    }
开发者ID:AngeloTorelli,项目名称:CompuCell3D,代码行数:29,代码来源:direct_solve.hpp


示例13: rot

     void rot (const T1 &t1, V1 &v1, const T2 &t2, V2 &v2) 
 {
         typedef typename promote_traits<typename V1::value_type, typename V2::value_type>::promote_type promote_type;
         vector<promote_type> vt (t1 * v1 + t2 * v2);
         v2.assign (- t2 * v1 + t1 * v2);
         v1.assign (vt);
     }
开发者ID:imos,项目名称:icfpc2015,代码行数:7,代码来源:blas.hpp


示例14: inner_prod

 double inner_prod( const V1& v1, const V2& v2 ) {
   double inner_res;
   inner_res = 0;
   for (int i=0; i<v1.size(); ++i) { 
     inner_res += v1[i]*v2[i] ; 
   }
   return inner_res;
 }
开发者ID:DriesDS,项目名称:C-oef,代码行数:8,代码来源:vector.hpp


示例15: throw

void bi::MultinomialResamplerHost::ancestors(Random& rng, const V1 lws, V2 as,
    MultinomialPrecompute<ON_HOST>& pre)
    throw (ParticleFilterDegeneratedException) {
  typedef typename V1::value_type T1;

  const int P = as.size();
  const int lwsSize = lws.size();

  T1 lW;

  /* weights */
  if (pre.W > 0) {
    lW = bi::log(pre.W);

    #pragma omp parallel
    {
      int Q = P/bi_omp_max_threads;
      int start = bi_omp_tid*Q + bi::min(bi_omp_tid, P % bi_omp_max_threads); // min() handles leftovers
      if (bi_omp_tid < P % bi_omp_max_threads) {
        ++Q; // pick up a leftover
      }

      int i, j = lwsSize;
      T1 lMax = 0.0, lu;
      for (i = Q; i > 0; --i) {
        lMax += bi::log(rng.uniform<T1>())/i;
        lu = lW + lMax;

        while (j > 0 && lu < bi::log(pre.Ws(j - 1))) {
          --j;
        }
        if (pre.sort) {
          as(start + i - 1) = pre.ps(j);
        } else {
          as(start + i - 1) = j;
        }
      }
    }
  } else {
    throw ParticleFilterDegeneratedException();
  }

  /* post-condition */
  BI_ASSERT(max_reduce(as) < lws.size());
}
开发者ID:JohannesBuchner,项目名称:LibBi,代码行数:45,代码来源:MultinomialResamplerHost.hpp


示例16: BI_ASSERT

void bi::mean(const M1 X, V1 mu) {
  /* pre-condition */
  BI_ASSERT(X.size2() == mu.size());

  const int N = X.size1();
  typename sim_temp_vector<V1>::type w(N);
  set_elements(w, 1.0);
  gemv(1.0/N, X, w, 0.0, mu, 'T');
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:9,代码来源:misc.hpp


示例17: mean

inline void bi::mean(const GammaPdf& q, V1 mu) {
  /* pre-condition */
  BI_ASSERT(mu.size() == q.size());

  real alpha = q.shape();
  real beta = q.scale();

  set_elements(mu, alpha*beta);
}
开发者ID:milthorpe,项目名称:LibBi,代码行数:9,代码来源:misc.hpp


示例18: checkDenseVectorAssignment

void checkDenseVectorAssignment(V1& v1, V2 const& v2){
	BOOST_REQUIRE_EQUAL(v1.size(),v2.size());
	//indexed access
	for(std::size_t i = 0; i != v2.size(); ++i){
		v1(i) = 0;
		BOOST_CHECK_EQUAL(v1(i),0);
		v1(i) = v2(i);
		BOOST_CHECK_EQUAL(v1(i),v2(i));
		v1(i) = 0;
		BOOST_CHECK_EQUAL(v1(i),0);
	}
	//iterator access rows
	typedef typename V1::iterator Iter;
	BOOST_REQUIRE_EQUAL(v1.end()-v1.begin(), v1.size());
	std::size_t k = 0;
	for(Iter it = v1.begin(); it != v1.end(); ++it,++k){
		BOOST_CHECK_EQUAL(k,it.index());
		*it = 0;
		BOOST_CHECK_EQUAL(v1(k),0);
		*it = v2(k);
		BOOST_CHECK_EQUAL(v1(k),v2(k));
		*it = 0;
		BOOST_CHECK_EQUAL(v1(k),0);
	}
	//test that the actual iterated length equals the number of elements
	BOOST_CHECK_EQUAL(k, v2.size());
}
开发者ID:Shark-ML,项目名称:Shark,代码行数:27,代码来源:matrix_proxy.cpp


示例19: r

 ExecStatus
 Int<V0,V1,Idx,Val>::assigned_val(Space& home, IntSharedArray& c, 
                                  V0 x0, V1 x1) {
   Region r(home);
   int* v = r.alloc<int>(x0.size());
   int n = 0;
   for (ViewValues<V0> i(x0); i(); ++i)
     if (c[i.val()] != x1.val())
       v[n++]=i.val();
   Iter::Values::Array iv(v,n);
   GECODE_ME_CHECK(x0.minus_v(home,iv,false));
   return ES_OK;
 }
开发者ID:,项目名称:,代码行数:13,代码来源:


示例20: addVectors

template <typename V, typename V1> void addVectors(V &a, const V1 &b) {
#ifdef FLOAT_REALS
  cblas_saxpy
#else
  cblas_daxpy
#endif
      (a.size(), 1, b.data(), 1, a.data(), 1);
#ifdef FLOAT_REALS
  cblas_sscal
#else
  cblas_dscal
#endif
      (a.size(), 0.5, a.data(), 1);
}
开发者ID:alongwithyou,项目名称:rnnlib,代码行数:14,代码来源:Agg.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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