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


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

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


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

示例1: forwardEstimation

void ThetaOperator::forwardEstimation(
		boost::ptr_vector<MeshContext>& contextStack ,
		                        FitobCalculator* calc ,
		                        int& stackIndex ,
		                        double& timeStamp ){

	FITOB_OUT_LEVEL3(verb(),"ThetaOperator::forwardEstimation stackIndex:" << stackIndex << "timeStamp"
			<< timeStamp << " contextStack.size():" << contextStack.size());

	MeshContext& actualContext = contextStack[stackIndex];

	if (thetaExpression_->isConstantExpression(actualContext) == false){
		FITOB_ERROR_EXIT(" ThetaOperator, theta expression is not constant ");
	}
    // evaluate the the expression (theta time) and store it
	thetaTime_ = thetaExpression_->eval(actualContext.minGlobCoord());

	// todo: these values now are not taken in consideration,
	// This might be a future feature, to split up one Theta operator in small theta operators
	// in case of too large macro time step
	// 19.09.2010 -> at todays knowledge this is not necessary, this would only make things worse
	maxThetaTime_ = 10.0; //calc->getXMLConfiguration().get()->getDoubleConfiguration("thetaconfigurations.solver.maxThetaStep.<xmlattr>.value" );
	nr_Theta_ = ceil(thetaTime_/maxThetaTime_);

	const boost::shared_ptr<ModelCollection>& factorModels = calc->getModelCollection();
	const boost::shared_ptr<ScriptModel>& scriptModel = calc->getScriptModel();
	const OperatorSequence& scriptBody = scriptModel->bodyOpSeq();
	const Domain& actDom = actualContext.getDom();
	int nrFactors = factorModels->nrFactors();

	Domain newDom(actDom);

	FITOB_OUT_LEVEL3(verb(),"ThetaOperator::forwardEstimation nrFactors:" << factorModels->nrFactors() << " thetaTime:" << thetaTime_ );
	for (int factorIndex = 0 ; factorIndex < nrFactors ; factorIndex++)
	{
		const FactorModelBase& model = factorModels->getModel(factorIndex);
		int globalIndex = model.getGlobalIndex();

		const DVector& startVal = calc->getStartDomain()->getGradedAxis(globalIndex);

		// get the points of the normal distribution
		DVector stdPoints;
		returnScaledNormalDistribution( actDom.getMaximalLevel() ,
				factorModels->stdFactor(factorIndex) , 1 ,  stdPoints );

		FITOB_OUT_LEVEL3(verb(),"ThetaOperator::forwardEstimation factorIndex:" << factorIndex << " P.size():" << stdPoints.size());
		// here we calculate the scaling
		if (startVal.size() > 1){
			for (unsigned int pointI = 0; pointI < stdPoints.size() ; pointI++ ){
				double endVal = 0.0;
				model.forwardEstimation(startVal[pointI] , timeStamp + thetaTime_ ,
						stdPoints[pointI] , actDom.getAverage() , endVal );
				if (verb()>3){
					std::cout << endVal << ",";
				}
				stdPoints[pointI] = endVal;
			}
			if (verb()>3) std::cout << std::endl;
		} else {
			for (unsigned int pointI = 0; pointI < stdPoints.size() ; pointI++ ){
				double endVal = 0.0;
				model.forwardEstimation(startVal[0] , timeStamp + thetaTime_ ,
						stdPoints[pointI] , actDom.getAverage() , endVal );
				if (verb()>3){
					std::cout << endVal << ",";
				}
				stdPoints[pointI] = endVal;
			}
			if (verb()>3) std::cout << std::endl;
		}

		//and call forwardEstimation_DiffusionEnlarement
		int stackIndex_tmp = 0;
		scriptBody.forwardEstimation_DiffusionEnlarement( contextStack ,
                calc ,stdPoints , globalIndex , stackIndex_tmp  , timeStamp );

		// sort stdPoints vector - not necessary (even in mean reversion case)
		// - this is not necessary since we estimate the values from 0 till T and not for dT
		std::sort( stdPoints.begin(),stdPoints.end() );

		// set the axis in the new domain
		newDom.setAxis(stdPoints,globalIndex);
	}

	// add new context, extend contextStack
	contextStack.push_back(new MeshContext(newDom,timeStamp));
	FITOB_OUT_LEVEL3(verb(),"ThetaOperator::forwardEstimation New Domain:" << newDom.toString() );
	timeStamp = timeStamp + thetaTime_;
	stackIndex = stackIndex + 1;

}
开发者ID:,项目名称:,代码行数:91,代码来源:


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