当前位置: 首页>>代码示例>>C++>>正文


C++ ublas::vector类代码示例

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


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

示例1: decodeBPSK

ublas::vector<int> decodeBPSK(const ublas::vector<double> &rx) {
  ublas::vector<int> vHat(rx.size());
  for (unsigned int i = 0; i < rx.size(); i++) {
    vHat(i) = 0.5 * (sign(rx(i)) + 1);
  }

  return vHat;
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:8,代码来源:ldpc_umfpack.cpp

示例2: getHomLength

const float NaoPose::getHomLength(const ublas::vector<float> &vec) {
    float sum = 0.0f;
    for (ublas::vector<float>::const_iterator i = vec.begin(); i != vec.end()
            - 1; ++i) {
        sum += *i * *i;
    }
    return sqrt(sum);
}
开发者ID:chachi,项目名称:nbites,代码行数:8,代码来源:NaoPose.cpp

示例3: addVector

    /**
     * \f$U+=V \f$ where U and V are type
     * uvlas::vector<T> and you
     * want to specify WHERE to add
     * the DenseVector<T> V
     */
    void addVector ( const ublas::vector<value_type>& V,
                     const std::vector<size_type>& dof_indices )
    {
        FEELPP_ASSERT ( V.size() == dof_indices.size() ).error( "invalid dof indices" );

        for ( size_type i=0; i<V.size(); i++ )
            this->add ( dof_indices[i], V( i ) );
    }
开发者ID:bachir151,项目名称:feelpp,代码行数:14,代码来源:vectorpetsc.hpp

示例4: biterr

double biterr(const ublas::vector<int> &u, const ublas::vector<int> &v) {
  int numErr = 0;
  for (unsigned int i = 0; i < u.size(); i++) {
    if (u(i) != v(i)) {
      numErr++;
    }
  }

  return static_cast<double>(numErr) / u.size();
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:10,代码来源:ldpc_umfpack.cpp

示例5: cross

ublas::vector<T>    cross( const ublas::vector<T> &a, const ublas::vector<T> &b )
{
	BOOST_ASSERT(a.size() == 3);
	BOOST_ASSERT(b.size() == 3);

	ublas::vector<T>	result(3);
	result(0) = a(1) * b(2) - a(2) * b(1);
	result(1) = a(2) * b(0) - a(0) * b(2);
	result(2) = a(0) * b(1) - a(1) * b(0);
	return result;
}
开发者ID:veprbl,项目名称:libepecur,代码行数:11,代码来源:ProcessMain.cpp

示例6: printVector

void printVector(const ublas::vector<T> &u) {
  for (unsigned int i = 0; i < u.size(); i++) {
    std::cout << u(i);

    if (i + 1 < u.size()) {
      std::cout << ", ";
    }
  }
  
  std::cout << std::endl;
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:11,代码来源:ldpc_umfpack.cpp

示例7: mod2

ublas::vector<int> mod2(const ublas::vector<int> &u) {
  ublas::vector<int> v(u.size());

  for (unsigned int i = 0; i < u.size(); i++) {
    v(i) = u(i) % 2;

    // modulus result can be negative if u(i) negative, depending on implementation
    if (v(i) < 0) {
      v(i) += 2;
    }
  }

  return v;
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:14,代码来源:ldpc_umfpack.cpp

示例8: diff

ScalarType diff(ublas::vector<ScalarType> & v1, viennacl::vector<ScalarType> & v2)
{
   ublas::vector<ScalarType> v2_cpu(v2.size());
   viennacl::backend::finish();
   viennacl::copy(v2.begin(), v2.end(), v2_cpu.begin());

   for (unsigned int i=0;i<v1.size(); ++i)
   {
      if ( std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) ) > 0 )
      {
        //if (std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) ) < 1e-10 )  //absolute tolerance (avoid round-off issues)
        //  v2_cpu[i] = 0;
        //else
          v2_cpu[i] = std::fabs(v2_cpu[i] - v1[i]) / std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) );
      }
      else
         v2_cpu[i] = 0.0;

      if (v2_cpu[i] > 0.0001)
      {
        //std::cout << "Neighbor: "      << i-1 << ": " << v1[i-1] << " vs. " << v2_cpu[i-1] << std::endl;
        std::cout << "Error at entry " << i   << ": " << v1[i]   << " vs. " << v2_cpu[i]   << std::endl;
        //std::cout << "Neighbor: "      << i+1 << ": " << v1[i+1] << " vs. " << v2_cpu[i+1] << std::endl;
        exit(EXIT_FAILURE);
      }
   }

   return norm_inf(v2_cpu);
}
开发者ID:denis14,项目名称:ViennaCL-1.5.2,代码行数:29,代码来源:scheduler_sparse.cpp

示例9: dirichlet_rnd

ublas::vector<double> dirichlet_rnd(const ublas::vector<int>& nz) {
  //! Returns sample from a Dirichlet distribution with dimension k = len(nz).
  int k = nz.size();
  ublas::vector<double> A(k);
  for (int i=0; i<k; ++i) {
    A(i) = Rmath::rgamma(1+nz(i), 1);
  }

  return A/sum(A);
}
开发者ID:cliburn,项目名称:flow,代码行数:10,代码来源:distributions.cpp

示例10: diff

ScalarType diff ( ublas::vector<ScalarType> & v1, viennacl::vector<ScalarType,Alignment> & v2 ) {
    ublas::vector<ScalarType> v2_cpu ( v2.size() );
    viennacl::copy( v2.begin(), v2.end(), v2_cpu.begin() );
    for ( unsigned int i=0; i<v1.size(); ++i ) {
        if ( std::max ( fabs ( v2_cpu[i] ), fabs ( v1[i] ) ) > 0 )
            v2_cpu[i] = fabs ( v2_cpu[i] - v1[i] ) / std::max ( fabs ( v2_cpu[i] ), fabs ( v1[i] ) );
        else
            v2_cpu[i] = 0.0;
    }
    return norm_inf ( v2_cpu );
}
开发者ID:kyle-jhchen,项目名称:viennacl-dev,代码行数:11,代码来源:generator_blas1.cpp

示例11:

    /** returns the first n elites
     * @param p_start start value of the elite values
     * @param p_end end value of the elite values ([start, end) elite elements must be created)
     * @param p_population const reference to the population
     * @param p_rankIndex rank index (first index has the position of the population element, that has the smalles fitness value)
     * @param p_elite vector with elite individual
     **/
    template<typename T, typename L> inline void bestof<T,L>::getElite( const std::size_t& p_start, const std::size_t& p_end, const std::vector< boost::shared_ptr< individual::individual<L> > >& p_population, const ublas::vector<T>&, const ublas::vector<std::size_t>& p_rankIndex, const ublas::vector<std::size_t>&, std::vector< boost::shared_ptr< individual::individual<L> > >& p_elite )
    {
        const std::size_t l_end = std::min(p_end, m_number);

        std::size_t n = p_start;
        for(std::size_t i=p_start; i < p_end; ++i) {
            p_elite.push_back( p_population[p_rankIndex[p_rankIndex.size()-1-n]] );
            n++;
            if (n >= l_end)
                n = p_start;
        }
    }
开发者ID:JackieXie168,项目名称:MachineLearning,代码行数:19,代码来源:bestof.hpp

示例12: diff

ScalarType diff(ublas::vector<ScalarType> const & v1, VCLVectorType const & v2)
{
   ublas::vector<ScalarType> v2_cpu(v2.size());
   viennacl::backend::finish();  //workaround for a bug in APP SDK 2.7 on Trinity APUs (with Catalyst 12.8)
   viennacl::copy(v2.begin(), v2.end(), v2_cpu.begin());

   for (unsigned int i=0;i<v1.size(); ++i)
   {
      if (v2_cpu[i] != v1[i])
        return 1;
   }

   return 0;
}
开发者ID:denis14,项目名称:ViennaCL-1.5.2,代码行数:14,代码来源:matrix_vector_int.cpp

示例13: ranks

Serialization SDPSeriationGen::Impl::readout_plain(ublas::vector<double>& x,const AdjMat::AdjMatT& adj)
{
	unsigned int n = x.size();

	// tricky: make sure x > 0 at all times.
	x += ublas::scalar_vector<double>(n, 1 - (*min_element(x.begin(),x.end())));

	Serialization::RankT ranks(n);
	std::vector<bool> done(n,false);

	// find highest component of x
	ublas::vector<double>::iterator it = BEST_ELEM(x);
	int idx = std::distance(x.begin(),it);

	L("Determine Actual Path through Graph.\n");
	for(unsigned int i=0;i<n;i++){
		ranks[i] = idx;
		done[idx] = true;
		*it = 0.0; 
		it = BEST_ELEM(x);
		idx = std::distance(x.begin(),it);
	}
	return Serialization(ranks);
}
开发者ID:temporaer,项目名称:seralign,代码行数:24,代码来源:sdp_seriation_gen.cpp

示例14: diff

ScalarType diff(ublas::vector<ScalarType> & v1, viennacl::vector<ScalarType> & v2)
{
   ublas::vector<ScalarType> v2_cpu(v2.size());
   viennacl::backend::finish();  //workaround for a bug in APP SDK 2.7 on Trinity APUs (with Catalyst 12.8)
   viennacl::copy(v2.begin(), v2.end(), v2_cpu.begin());

   for (std::size_t i=0;i<v1.size(); ++i)
   {
      if ( std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) ) > 0 )
         v2_cpu[i] = std::fabs(v2_cpu[i] - v1[i]) / std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) );
      else
         v2_cpu[i] = 0.0;
   }

   return norm_inf(v2_cpu);
}
开发者ID:GnsP,项目名称:viennacl-dev,代码行数:16,代码来源:blas3_prod_float_double.hpp

示例15: image2vector_2d

    void image2vector_2d(const ublas::fixed_vector<size_t, 2> size, const float_accessor_t & image, ublas::vector<float_t> & vector)
    {
      if(image.size() != size)
        throw Exception("Exception: Dimensions of image and grid do not agree in Image2Grid::image2vector().");

      size_t n_x_vertices = size(0);
      size_t n_y_vertices = size(1);
  
      vector.resize(n_x_vertices * n_y_vertices, false);
  
      for(size_t i = 0; i < n_x_vertices; i++)
        for(size_t j = 0; j < n_y_vertices; ++j)
        {
          size_t vertex_index = i + j * n_x_vertices;
          vector(vertex_index) = image[ublas::fixed_vector<size_t, 2>(i, j)];
        }
    }
开发者ID:axkibe,项目名称:imaging2,代码行数:17,代码来源:Image2Grid_impl.hpp


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