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


C++ vector::size方法代码示例

本文整理汇总了C++中boost::numeric::ublas::vector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::size方法的具体用法?C++ vector::size怎么用?C++ vector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::numeric::ublas::vector的用法示例。


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

示例1: if

void ribi::QtUblasVectorDoubleModel::SetRawData(const boost::numeric::ublas::vector<double>& data)
{
  if (!Matrix::VectorsDoubleAreEqual(m_data,data))
  {
    const int new_size = boost::numeric_cast<int>(data.size());
    const int cur_size = this->rowCount();
    if (cur_size < new_size)
    {
      this->insertRows(cur_size,new_size - cur_size,QModelIndex());
    }
    else if (cur_size > new_size)
    {
      this->removeRows(cur_size,cur_size - new_size,QModelIndex());
    }
    //Set the data before emitting signals, as the response to that signal
    //will be dependent on that data
    m_data = data;

    assert(this->rowCount() == boost::numeric_cast<int>(data.size())
      && "So emit layoutChange can work on the newest layout");

    //If you forget this line, the view displays a different number of rows than m_data has
    emit layoutChanged();

    //emit dataChanged(QModelIndex(),QModelIndex());
    const QModelIndex top_left = this->index(0,0);
    const QModelIndex bottom_right = this->index(m_data.size() - 1, 0);
    emit dataChanged(top_left,bottom_right);
  }

  assert(this->rowCount() == boost::numeric_cast<int>(this->m_data.size()));
  assert(this->rowCount() == boost::numeric_cast<int>(m_header_vertical_text.size()));
  assert(this->columnCount() == (this->rowCount() == 0 ? 0 : 1));
}
开发者ID:RLED,项目名称:ProjectRichelBilderbeek,代码行数:34,代码来源:qtublasvectordoublemodel.cpp

示例2: stft

boost::python::tuple
stft_glue(const boost::numeric::ublas::vector<double> &x,
        const int length,
        const int shift)
{
    const int n_frame = ((int)x.size() - length) / shift + 1;
    const int n_freq = length / 2 + 1;
//    std::cerr << n_frame << " " << n_freq << " " << length << " " << shift << std::endl;

    std::vector<double> y(x.size() + length * 10);
    std::cerr << x.size() << " " << y.size() << std::endl;
    for(size_t i = 0; i != y.size(); ++i)
        y[i] = i < x.size() ? x[i] : 0.0;
//    std::cerr << y.size() << std::endl;
    STFT stft(length, shift, n_frame);
    //allocation
    twoDimArray<double> abs_spec(n_frame, n_freq);
    twoDimArray<std::complex<double> > phase_spec(n_frame, n_freq);

    // exec stft
    stft.exec(&(y[0]), &abs_spec, &phase_spec);

    boost::numeric::ublas::matrix<double> abs_spec_boost(n_frame, n_freq);
    boost::numeric::ublas::matrix<double> phase_spec_boost(n_frame, n_freq);

    for(int i = 0; i != n_frame; ++i){
        for(int j = 0; j != n_freq; ++j){
            abs_spec_boost(i,j) = abs_spec[i][j];
            phase_spec_boost(i,j) = std::arg(phase_spec[i][j]);
        }
    }

    auto ret = boost::python::make_tuple(abs_spec_boost, phase_spec_boost);
    return ret;
}
开发者ID:tachi-hi,项目名称:timefreq,代码行数:35,代码来源:python.cpp

示例3: operator

  int operator()(V& v) const {
     using namespace boost::numeric::bindings::blas ;

     typedef typename V::value_type                                                        value_type ;
     typedef typename bindings::remove_imaginary<value_type>::type real_type ;

     // Copy vector from reference
     for (typename V::size_type i=0; i<v_ref_.size(); ++i)
        v[i] = v_ref_(i);

     // Test blas routines and compare with reference
     real_type nrm = nrm2( v );
     if ( std::abs(nrm - norm_2(v_ref_)) > std::numeric_limits< real_type >::epsilon() * norm_2(v_ref_)) {
       std::cout << "nrm2 : " << std::abs(nrm - norm_2(v_ref_)) << " > " << std::numeric_limits< real_type >::epsilon() * norm_2(v_ref_) << std::endl ;
       return 255 ;
     }

     nrm = asum( v );
     if ( std::abs(nrm - abs_sum(v_ref_)) > std::numeric_limits< real_type >::epsilon() * abs_sum(v_ref_)) {
       std::cout << "asum : " << std::abs(nrm - abs_sum(v_ref_)) << " > " << std::numeric_limits< real_type >::epsilon() * abs_sum(v_ref_) << std::endl ;
       return 255 ;
     }

     scal( value_type(2.0), v );
     for (typename V::size_type i=0; i<v_ref_.size(); ++i)
        if (std::abs( v[i] - real_type(2.0)*v_ref_(i) ) > real_type(2.0)*std::abs(v_ref_(i))) return 255 ;

     return 0;
  }
开发者ID:JordanBlocher,项目名称:boost-numeric_bindings,代码行数:29,代码来源:blas1.cpp

示例4: pprint

      void pprint(const boost::numeric::ublas::vector<double>& v) {
	cout << "[";
	for( uint i=0; i < v.size(); i++) {
	  cout << v(i);
	  if(i != v.size()-1)
	    cout << " , ";
	}
	cout << "]\n";
      }
开发者ID:bilian1995,项目名称:Delite,代码行数:9,代码来源:OptiML.hpp

示例5: compute_distance

double compute_distance(const ublas::vector<double>& pt1, const ublas::vector<double>& pt2)
{
	assert(pt1.size()==pt2.size());
	double sum = 0;
	for(UINT i = 0; i<pt1.size(); i++)
	{
		sum += pow((double)(pt1(i) - pt2(i)), 2.0);
	}
	return sqrt(sum);
}
开发者ID:qiangd6,项目名称:QTK,代码行数:10,代码来源:k_mean_cluster.cpp

示例6: norm

double norm(const boost::numeric::ublas::vector<double>& v1, const boost::numeric::ublas::vector<double>& v2) {
    assert (v1.size() == v2.size());
    double sum = 0;
    for (size_t i=0; i<v1.size(); ++i)
    {
        double minus = v1(i) - v2(i);
        double r = minus * minus;
        sum += r;
    }

    return sqrt(sum);
}
开发者ID:faisal-w,项目名称:Linear-Discriminant-Analysis,代码行数:12,代码来源:util.hpp

示例7: hotelling_t2_1test

T hotelling_t2_1test(
  boost::numeric::ublas::vector<T> mean1,
  boost::numeric::ublas::vector<T> mean2,
  boost::numeric::ublas::matrix<T> cov1,
  unsigned n1
){
  unsigned k=mean1.size();  

  boost::numeric::ublas::vector<T > mean_diff=mean1-mean2;
  boost::numeric::ublas::matrix<T>  cov_inv(cov1);
  invert_matrix(cov1  ,cov_inv);
  T t2_score=
  boost::numeric::ublas::inner_prod(
			      boost::numeric::ublas::prod( cov_inv,mean_diff)
			      ,mean_diff)*n1;
  T f_score= (t2_score*(n1 - k))/(k*(n1-1));

  std::cout << t2_score   << std::endl;
  std::cout << f_score   << std::endl;

  boost::math::fisher_f dist(k, n1-k);
  T p_score =boost::math::cdf(dist, f_score);

  std::cout << p_score << std::endl;
  T p_comp =boost::math::cdf(complement(dist, f_score));
  std::cout << p_comp << std::endl;
  //return p_comp;
  return p_score;
}
开发者ID:niitsuma,项目名称:hotelling_t_square_test,代码行数:29,代码来源:ublas_hotelling_t2.hpp

示例8: clear

void clear(boost::numeric::ublas::vector<T> &x) {
    const ptrdiff_t n = x.size();

#pragma omp parallel for schedule(dynamic, 1024)
    for(ptrdiff_t i = 0; i < n; ++i)
        x[i] = 0;
}
开发者ID:KratosCSIC,项目名称:trunk,代码行数:7,代码来源:operations_ublas.hpp

示例9: generateCircularSpreading

void generateCircularSpreading(boost::numeric::ublas::vector<double> &spr,
  const std::vector<double> &pars) {
  spr(0) = initiateCircularSpreading(pars);
  for (unsigned int i=1; i<spr.size(); ++i) {
    spr(i) = circularMap(spr(i-1), pars);
  }
}
开发者ID:scidom,项目名称:csk,代码行数:7,代码来源:spreading_circular.cpp

示例10: hotelling_t2_2test

T hotelling_t2_2test(
  boost::numeric::ublas::vector<T> mean1,
  boost::numeric::ublas::vector<T> mean2,
  boost::numeric::ublas::matrix<T> cov1,
  boost::numeric::ublas::matrix<T> cov2, 
  unsigned n1,
  unsigned n2){
  unsigned k=mean1.size();  
//int n = n1 + n2 -1;
  boost::numeric::ublas::vector<T > mean_diff=mean1-mean2;
  boost::numeric::ublas::matrix<T>  
  pooled_cov=(cov1*(n1-1)+cov2*(n2-1))*1.0/(n1+n2-2) ;
  pooled_cov *= (1.0/n1+1.0/n2 );
  boost::numeric::ublas::matrix<T>  pooled_cov_inv(pooled_cov);
  invert_matrix(   pooled_cov  ,pooled_cov_inv);
//std::cout << mean_diff << std::endl;  
  T t2_score=
  boost::numeric::ublas::inner_prod(
			      boost::numeric::ublas::prod( pooled_cov_inv,mean_diff)
			      ,mean_diff);
  T f_score= (t2_score*(n1 + n2 - 1- k))/(k*(  n1 + n2 - 2));

  std::cout << t2_score   << std::endl;
  std::cout << f_score   << std::endl;

  boost::math::fisher_f dist(k, n1+n2-1-k);
  T p_score =boost::math::cdf(dist, f_score);

  std::cout << p_score << std::endl;
  T p_comp =boost::math::cdf(complement(dist, f_score));
  std::cout << p_comp << std::endl;
  //return p_comp;
  return p_score;
}
开发者ID:niitsuma,项目名称:hotelling_t_square_test,代码行数:34,代码来源:ublas_hotelling_t2.hpp

示例11: vector_print

void vector_print(ublas::vector<ScalarType>& v )
{

    std::cout << "vector_print!\n";
    for (unsigned int i = 0; i < v.size(); i++)
      std::cout << v(i) << "\t";
    std::cout << "\n";
}
开发者ID:andiselinger,项目名称:ViennaCL-1.5.2,代码行数:8,代码来源:bidiag_test.cpp

示例12: generateValleySpreading

void generateValleySpreading(boost::numeric::ublas::vector<double> &spr,
  const std::vector<double> &pars) {
  spr(0) =
    boost::random::uniform_real_distribution<>(pars[0], pars[2])(rng);
  for (unsigned int i=1; i<spr.size(); ++i) {
    spr(i) = valleyMap(spr(i-1), pars);
  }
}
开发者ID:scidom,项目名称:csk,代码行数:8,代码来源:spreading_valley.cpp

示例13: result

	boost::python::object
	ublas_to_numpy(
		const boost::numeric::ublas::vector< T > & m )
	{
		//create a numpy array to put it in
		boost::python::object result(
			array_type(
				boost::python::make_tuple( m.size() ),
				dtype ) );

		//copy the elements
		for( unsigned i = 0; m.size() != i; ++i )
		{
            result[i] = m(i);
		}

		return result;
	}
开发者ID:capoe,项目名称:soapxx,代码行数:18,代码来源:numpy.hpp

示例14: iszero

bool
UZRectMollerup::converges (const ublas::vector<double>& previous,
			   const ublas::vector<double>& current) const
{
  size_t size = previous.size ();
  daisy_assert (current.size () == size);

  for (unsigned int i = 0; i < size; i++)
    {
      if (   fabs (current[i] - previous[i]) > max_absolute_difference
	  && (   iszero (previous[i])
              || iszero (current[i])
	      || (  fabs ((current[i] - previous[i]) / previous[i])
		  > max_relative_difference)))
	return false;
    }
  return true;
}
开发者ID:perabrahamsen,项目名称:daisy-model,代码行数:18,代码来源:uzrect_Mollerup.C

示例15: norm

T norm(const boost::numeric::ublas::vector<T> &x) {
    const ptrdiff_t n = x.size();
    T sum = 0;

#pragma omp parallel for schedule(dynamic, 1024) reduction(+:sum)
    for(ptrdiff_t i = 0; i < n; ++i)
        sum += x[i] * x[i];

    return sqrt(sum);
}
开发者ID:KratosCSIC,项目名称:trunk,代码行数:10,代码来源:operations_ublas.hpp


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