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


C++ DoubleVector::begin方法代码示例

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


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

示例1: smoothData

  void LowessSmoothing::smoothData(const DoubleVector& input_x, const DoubleVector& input_y, DoubleVector& smoothed_output)
  {
    if (input_x.size() != input_y.size())
    {
      throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
          "Sizes of x and y values not equal! Aborting... ", String(input_x.size()));
    }

    // unable to smooth over 2 or less data points (we need at least 3)
    if (input_x.size() <= 2)
    {
      smoothed_output = input_y;
      return;
    }

    Size input_size = input_y.size();

    // const Size q = floor( input_size * alpha );
    const Size q = (window_size_ < input_size) ? static_cast<Size>(window_size_) : input_size - 1;

    DoubleVector distances(input_size, 0.0);
    DoubleVector sortedDistances(input_size, 0.0);

    for (Size outer_idx = 0; outer_idx < input_size; ++outer_idx)
    {
      // Compute distances.
      // Size inner_idx = 0;
      for (Size inner_idx = 0; inner_idx < input_size; ++inner_idx)
      {
        distances[inner_idx] = std::fabs(input_x[outer_idx] - input_x[inner_idx]);
        sortedDistances[inner_idx] = distances[inner_idx];
      }

      // Sort distances in order from smallest to largest.
      std::sort(sortedDistances.begin(), sortedDistances.end());

      // Compute weigths.
      std::vector<double> weigths(input_size, 0);
      for (Size inner_idx = 0; inner_idx < input_size; ++inner_idx)
      {
        weigths.at(inner_idx) = tricube_(distances[inner_idx], sortedDistances[q]);
      }

      //calculate regression
      Math::QuadraticRegression qr;
      std::vector<double>::const_iterator w_begin = weigths.begin();
      qr.computeRegressionWeighted(input_x.begin(), input_x.end(), input_y.begin(), w_begin);

      //smooth y-values
      double rt = input_x[outer_idx];
      smoothed_output.push_back(qr.eval(rt));
    }

    return;
  }
开发者ID:OpenMS,项目名称:OpenMS,代码行数:55,代码来源:LowessSmoothing.cpp

示例2: gridSearchParallel

// parallel version with arbitrary dimensions
int gridSearchParallel(DoublePyArrayVector const &controlGridArray, MaximizerCallParams &params, double &rMaxVal, DoubleVector &rArgMaxArray) {  
  int nGrids = controlGridArray.size();
  int i;
  IntVector lenArray(nGrids);
  
  for (i=0; i<nGrids; i++) {
    // check that all grids are 1-dimensional
    assert(controlGridArray[i].ndim() == 1);  
	lenArray[i] = controlGridArray[i].dims()[0];
  }

  unsigned int totalGridSize = 1;
  double totalGridSize2 = 1.0;
  for (i=0; i<nGrids; i++) {
	totalGridSize *= lenArray[i];
	totalGridSize2 *= double(lenArray[i]);
  }
  // check that total grid space isn't too large to be indexed
  assert(totalGridSize2 < double(UINT_MAX));
  
  MaxIndexFnObj2 fnObj(controlGridArray, params);  
  parallel_reduce( blocked_range<size_t>(0, totalGridSize), fnObj);  

  rMaxVal = fnObj.m_value_of_max;
  rArgMaxArray.resize(fnObj.m_argmax.size());
  copy(fnObj.m_argmax.begin(), fnObj.m_argmax.end(), rArgMaxArray.begin());
  return 1;
}
开发者ID:Twizanex,项目名称:bellman,代码行数:29,代码来源:maximizer.cpp

示例3: objectiveFunction

  // must be mt-safe. don't use boost::python handles!
  double objectiveFunction(DoubleVector const &args) const {    
    bpl::list args2;
	for (DoubleVector::const_iterator iter=args.begin(); iter != args.end(); iter++) {
	  args2.append(*iter);
	}
	bpl::object result = m_CallbackFn(args2);
	return bpl::extract<double>(result);
  }
开发者ID:Twizanex,项目名称:bellman,代码行数:9,代码来源:maximizer.cpp

示例4: getRates

void RateMeyerHaeseler::getRates(DoubleVector &rates) {
	rates.clear();
	if (empty()) {
		rates.resize(phylo_tree->aln->size(), 1.0);
	} else {
		rates.insert(rates.begin(), begin(), end());
	} 
}
开发者ID:MichaelWoodhams,项目名称:IQ-TREE,代码行数:8,代码来源:ratemeyerhaeseler.cpp

示例5: print_DoubleVector

void RRSchedule::print_DoubleVector(DoubleVector _invect, std::ostream &stream = std::cout)
{
    for (DoubleVector::const_iterator row = _invect.begin(); row != _invect.end(); ++row)
    {
        print_Vector(*row, stream);
        stream << '\n' << std::flush;
    }
}
开发者ID:cwinton,项目名称:RoundRobinScheduler,代码行数:8,代码来源:Schedule.cpp

示例6: DVectMax

int RRSchedule::DVectMax(DoubleVector _invect)
{
    int global_max = 0;
    for (DoubleVector::const_iterator tslot = _invect.begin(); tslot != _invect.end(); ++tslot)
    {
        global_max = std::max(VectMax(*tslot), global_max);
        
    }
    return global_max;
}
开发者ID:cwinton,项目名称:RoundRobinScheduler,代码行数:10,代码来源:Schedule.cpp

示例7: DVectMin

int RRSchedule::DVectMin(DoubleVector _invect)
{
    int global_min = max_per_time;
    for (DoubleVector::const_iterator tslot = _invect.begin(); tslot != _invect.end(); ++tslot)
    {
        global_min = std::min(VectMin(*tslot), global_min);
        
    }
    return global_min;
}
开发者ID:cwinton,项目名称:RoundRobinScheduler,代码行数:10,代码来源:Schedule.cpp

示例8: initialiseIndexScore

static void initialiseIndexScore ()
{
	int numEntries;
	char* info = getFileInfo ( MsparamsDir::instance ().getParamPath ( "indicies.txt" ), '>', 1, true, &numEntries );

	for ( int i = 0 ; i < numEntries ; i++ ) {
		names.push_back ( ( i == 0 ) ? strtok ( info, "\n" ) : strtok ( NULL, "\n" ) );
		DoubleVector dv (52);
		indexV.push_back ( dv );
		fill ( dv.begin (), dv.end (), 0.0 );
		for ( ; ; ) {
			char aa;
			double value;
			char* line = strtok ( NULL, "\n" );

			if ( !strcmp ( line, ">" ) ) break;
			sscanf ( line, "%c %lf", &aa, &value );
			indexV [i][aa-'A'] = value;
		}
	}
	initialised = true;
}
开发者ID:proteinprospector,项目名称:prospector,代码行数:22,代码来源:lu_indicies.cpp

示例9: compute_team_waits_for_week

Vector RRSchedule::compute_team_waits_for_week(DoubleVector _week)
// Compute how long each team will wait in a week
{
    DoubleVector team_played_counts;
    Vector team_wait;
    
    init2DEmpty(team_played_counts, max_teams, max_per_night);
    
    // First determine in which timeslot each team played
    int tslotNum = 0;
    for (DoubleVector::const_iterator _tslot = _week.begin(); _tslot != _week.end(); ++_tslot)
    {
        for (Vector::const_iterator team = _tslot->begin(); team != _tslot->end(); ++team)
        {
            team_played_counts[*team].push_back(tslotNum);
        }
        tslotNum ++;
    }
    
    
    // From that, determine how long a team will wait that week
    for (DoubleVector::const_iterator _team = team_played_counts.begin(); _team != team_played_counts.end(); ++_team)
    {
        if (_team->size() > 0)
        {
            team_wait.push_back(VectMax(*_team) - VectMin(*_team) - int(_team->size()) + 1);
        }
        else
        {
            team_wait.push_back(0);
        }
        
    }
    
    return team_wait;
}
开发者ID:cwinton,项目名称:RoundRobinScheduler,代码行数:36,代码来源:Schedule.cpp

示例10: gridSearch

// single-threaded grid search with an arbitrary number of dimensions
int gridSearch(DoublePyArrayVector const &controlGridArray, MaximizerCallParams &params, double &rMaxVal, DoubleVector &rArgMaxArray) {  
  int nGrids = controlGridArray.size();
  int i;
  IntVector lenArray(nGrids), strideArray(nGrids), dataIndexArray(nGrids);
  
  for (i=0; i<nGrids; i++) {
    // check that all grids are 1-dimensional
    assert(controlGridArray[i].ndim() == 1);  
	lenArray[i] = controlGridArray[i].dims()[0];
	strideArray[i] = controlGridArray[i].strides()[0];
	dataIndexArray[i] = 0;
  }

  DoubleVector argArray(nGrids);  
  int nIter = 0;
  int nMaxMultiplicity = 0;  
  bool bDone = false;
  
  // check for zero size, if one grid has zero size then there's nothing to do
  for (i=0; i<nGrids; i++) {
    if (lenArray[i] == 0) {
	  bDone = true;
	  break;
	}
  }
  double max = -DBL_MAX;
  while (!bDone) {
    double result;
	// get double array args from char* data
	for (i=0; i<nGrids; i++) {
	  char *pData = (char*) (controlGridArray[i].array().data());
	  char *pArg = pData + (strideArray[i] * dataIndexArray[i]);
	  argArray[i] = *(double*) pArg;
	}
	result = params.objectiveFunction(argArray);
	if (nIter == 0) {			// first iteration
      max = result;
	  rArgMaxArray.resize(argArray.size());
	  copy(argArray.begin(), argArray.end(), rArgMaxArray.begin());		
	  nMaxMultiplicity = 1;
    } else {
      if (result > max) {
        max = result;
		rArgMaxArray.resize(argArray.size());
		copy(argArray.begin(), argArray.end(), rArgMaxArray.begin());		
	    nMaxMultiplicity = 1;
	  } else if (result == max) {
	    nMaxMultiplicity++;
	  }
	}
	nIter++;

    // increment indices for next iteration
	bDone = true;
	for (i=nGrids-1; i>=0; i--) {
	  // increment index i
	  dataIndexArray[i] += 1;
	  if (dataIndexArray[i] == lenArray[i]) {
	    // cycle this index
		dataIndexArray[i] = 0;
	  } else {
	    bDone = false;
		break;
	  }
	  // if we make it here, all indices have cycled, therefore we are done
	}
	
  }
  rMaxVal = max;
  return nMaxMultiplicity;
}
开发者ID:Twizanex,项目名称:bellman,代码行数:72,代码来源:maximizer.cpp

示例11: computePatternRates

int RateMeyerDiscrete::computePatternRates(DoubleVector &pattern_rates, IntVector &pattern_cat) {
	pattern_rates.insert(pattern_rates.begin(), begin(), end());
	pattern_cat.insert(pattern_cat.begin(), ptn_cat, ptn_cat + size());
    return ncategory;
}
开发者ID:Cibiv,项目名称:IQ-TREE,代码行数:5,代码来源:ratemeyerdiscrete.cpp

示例12: if

bool
RandomNumberInputHandler::handleInput(const yarp::os::Bottle &     input,
                                      const YarpString &           senderChannel,
                                      yarp::os::ConnectionWriter * replyMechanism,
                                      const size_t                 numBytes)
{
#if (! defined(ODL_ENABLE_LOGGING_))
# if MAC_OR_LINUX_
#  pragma unused(senderChannel,replyMechanism,numBytes)
# endif // MAC_OR_LINUX_
#endif // ! defined(ODL_ENABLE_LOGGING_)
    ODL_OBJENTER(); //####
    ODL_S2s("senderChannel = ", senderChannel, "got ", input.toString()); //####
    ODL_P1("replyMechanism = ", replyMechanism); //####
    ODL_I1("numBytes = ", numBytes); //####
    bool result = true;

    try
    {
        if (0 < input.size())
        {
            BaseChannel *        theOutput = _shared.getOutput();
            RandomNumberClient * theClient = (RandomNumberClient *) _shared.getClient();

            if (theClient && theOutput)
            {
                int             count;
                yarp::os::Value argValue(input.get(0));

                if (argValue.isInt())
                {
                    count = argValue.asInt();
                }
                else if (argValue.isDouble())
                {
                    count = static_cast<int>(argValue.asDouble());
                }
                else
                {
                    count = 1;
                }
                if (0 > count)
                {
                    count = 1;
                }
                if (1 < count)
                {
                    DoubleVector randResult;

                    if (theClient->getRandomNumbers(count, randResult))
                    {
                        yarp::os::Bottle message;

                        if (0 < randResult.size())
                        {
                            for (DoubleVector::const_iterator it(randResult.begin());
                                 randResult.end() != it; ++it)
                            {
                                message.addDouble(*it);
                            }
                        }
                        _shared.lock();
                        if (! theOutput->write(message))
                        {
                            ODL_LOG("(! theOutput->write(message))"); //####
#if defined(MpM_StallOnSendProblem)
                            Stall();
#endif // defined(MpM_StallOnSendProblem)
                        }
                        _shared.unlock();
                    }
                    else
                    {
                        ODL_LOG("! (theClient->getRandomNumbers(count, randResult))"); //####
                    }
                }
                else if (0 < count)
                {
                    double randResult;

                    if (theClient->getOneRandomNumber(randResult))
                    {
                        yarp::os::Bottle message;

                        message.addDouble(randResult);
                        _shared.lock();
                        if (! theOutput->write(message))
                        {
                            ODL_LOG("(! theOutput->write(message))"); //####
#if defined(MpM_StallOnSendProblem)
                            Stall();
#endif // defined(MpM_StallOnSendProblem)
                        }
                        _shared.unlock();
                    }
                    else
                    {
                        ODL_LOG("! (theClient->getOneRandomNumber(randResult))"); //####
                    }
                }
//.........这里部分代码省略.........
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:101,代码来源:m+mRandomNumberInputHandler.cpp

示例13: setRates

void RateMeyerHaeseler::setRates(DoubleVector &rates) {
	clear();
	insert(begin(), rates.begin(), rates.end());
}
开发者ID:MichaelWoodhams,项目名称:IQ-TREE,代码行数:4,代码来源:ratemeyerhaeseler.cpp

示例14: computePatternRates

int RateMeyerHaeseler::computePatternRates(DoubleVector &pattern_rates, IntVector &pattern_cat) {
	pattern_rates.insert(pattern_rates.begin(), begin(), end());
    return size();
}
开发者ID:MichaelWoodhams,项目名称:IQ-TREE,代码行数:4,代码来源:ratemeyerhaeseler.cpp

示例15: isPresent

bool RRSchedule::isPresent(DoubleVector _vect, Vector item)
{
    return (std::find(_vect.begin(), _vect.end(), item) != _vect.end());
}
开发者ID:cwinton,项目名称:RoundRobinScheduler,代码行数:4,代码来源:Schedule.cpp


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