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

C++ aol::Vector类代码示例

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

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



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

示例1: getWeightedMedianValue

typename aol::Vector<_DataType>::RealType aol::Vector<_DataType>:: getWeightedMedianValue( const aol::Vector<RealType> &Weights ) const {
  const int numVals = this->size();

  if ( numVals != Weights.size() )
    throw Exception ( "aol::Vector<DataType>::getWeightedMedianValue: numVals != Weights.size() !\n", __FILE__, __LINE__ );

  if ( Weights.getMinValue() <= 0 )
    throw Exception ( "aol::Vector<DataType>::getWeightedMedianValue: Nonpositive weights are not supported!\n", __FILE__, __LINE__ );

  std::vector<std::pair<_DataType, RealType> > valuesAndWeights;
  valuesAndWeights.reserve ( numVals );
  for ( int i = 0; i < numVals; ++i )
    valuesAndWeights.push_back ( std::pair<_DataType, RealType> ( this->get ( i ), Weights[i] ) );

  std::sort( valuesAndWeights.begin(), valuesAndWeights.end() );
  const RealType halfOfTotalWeight = 0.5 * Weights.sum();

  RealType weight = 0;
  for ( int i = 0; i < numVals; ++i ) {
    weight += valuesAndWeights[i].second;
    if ( ( weight > halfOfTotalWeight ) || ( i == ( numVals - 1 ) ) )
      return valuesAndWeights[i].first;
    else if ( aol::appeqAbsolute ( weight, halfOfTotalWeight ) ) {
      return ( valuesAndWeights[i].first * valuesAndWeights[i].second + valuesAndWeights[i+1].first * valuesAndWeights[i+1].second ) / ( valuesAndWeights[i].second +  valuesAndWeights[i+1].second );
    }
  }
  return valuesAndWeights[numVals-1].first;
}
开发者ID:Wflying1224,项目名称:K2-data-scripts,代码行数:28,代码来源:vec.cpp


示例2:

void aol::Vector<_DataType>::pushBackValues ( const aol::Vector<_DataType> &otherVector ) {
  const int currentSize = this->size();
  this->growBy ( otherVector.size() );
  for ( int i = 0; i < otherVector.size(); ++i ) {
    this->set ( currentSize + i, otherVector.get ( i ) );
  }
}
开发者ID:Wflying1224,项目名称:K2-data-scripts,代码行数:7,代码来源:vec.cpp


示例3: Exception

_DataType aol::Vector<_DataType>::operator* ( const aol::Vector<_DataType> &c ) const {
  if ( c.size() != _size ) {
    throw aol::Exception ( "Vector::operator*: Vectorlengths not equal...", __FILE__, __LINE__ );
  } else {
    return ScalarProduct<DataType> ( this->_pData, c.getData(), _size );
  }
  return 0;
}
开发者ID:Wflying1224,项目名称:K2-data-scripts,代码行数:8,代码来源:vec.cpp


示例4: multCarefullyAtBoundary

void qc::FastUniformGridMatrix<_DataType, qc::QC_2D, BaseClass>::applyAdd ( const aol::Vector<_DataType> &Arg, aol::Vector<_DataType> &Dest ) const {
#ifdef _OPENMP
#pragma omp parallel for
#endif
  for ( int i = 0; i <= _w + 1; ++i ) {
    multCarefullyAtBoundary ( i, Arg, Dest );
  }
#if 1
  const DataType * ArgPtr  = Arg.getData();
  DataType * DestPtr = Dest.getData();
#ifdef _OPENMP
#pragma omp parallel for
#endif
  for ( int i = _w + 2; i < _size - _w - 2; ++i ) {
    for ( int k = 0; k < 3; ++k ) {
      int globos = _w * ( k - 1 ) - 1;
      int g = globos + i;
      for ( int j = 0; j < 3; ++j ) {
        DestPtr[i] += ArgPtr[g++] * _rows[k][i][j];
      }
    }
  }
#endif
#if 0
  const int seg_len = 10;
  for ( int seg = _w + 2; seg < _size - _w - 2; seg += seg_len ) {
    const int seg_end = aol::Min ( seg + seg_len, _size - _w - 2 );
    for ( int k = 0; k < 3; ++k ) {
      int globos = _w * ( k - 1 ) - 1;
      for ( int i = seg; i < seg_end; ++i ) {
        // cerr << "inner row = " << i << endl;
        int g = globos + i;
        for ( int j = 0; j < 3; ++j ) {
          Dest[i] += Arg[g++] * _rows[k][i][j];
        }
      }
    }
  }
#endif
#ifdef _OPENMP
#pragma omp parallel for
#endif
  for ( int i = aol::Max ( _w + 2, _size - _w - 2 ); i < _size; ++i ) {
    multCarefullyAtBoundary ( i, Arg, Dest );
  }
}
开发者ID:Wflying1224,项目名称:K2-data-scripts,代码行数:46,代码来源:fastUniformGridMatrix.cpp


示例5: get

typename aol::Vector<_DataType>::RealType aol::Vector<_DataType>::getWeightedMeanValue ( const aol::Vector<RealType> &Weights ) const {
  const int numVals = this->size();

  RealType mean = 0;
  for ( int i = 0; i < numVals; ++i )
    mean += Weights[i] * get(i);
  mean /= Weights.sum();

  return mean;
}
开发者ID:Wflying1224,项目名称:K2-data-scripts,代码行数:10,代码来源:vec.cpp


示例6: OutOfBoundsException

_DataType aol::Vector<_DataType>::sumWeighted ( aol::Vector<_DataType> const& weight ) const {
#ifdef BOUNDS_CHECK
  if ( weight.size() < _size ) {
    char error[1024];
    sprintf ( error, "Vector<DataType>::sumWeighted: weight vector not long enough (%d), should be %d at least.\n", weight.size(), _size );
    throw OutOfBoundsException ( error, __FILE__, __LINE__ );
  }
#endif
  _DataType ret = 0.;
  _DataType *ptr = _pData;
  for ( int i = 0; i < _size; ++i )
    ret += *ptr++ * weight[i];
  return ret;
}
开发者ID:nmevenkamp,项目名称:pcams,代码行数:14,代码来源:vec.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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