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


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

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


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

示例1: doAnalysisConvergence

void ConvergenceAnaly::doAnalysisConvergence(
		DVector& prices , DVector& conv,
		DVector& norm_L2 , DVector& norm_Inf,
		DVector& rate_L2 , DVector& rate_Linf, DVector& rate_pointw ){

	// resize the result vectors
	prices.resize(highLevel_-lowLevel_+1);
	conv.resize(highLevel_-lowLevel_+1);
	norm_L2.resize(highLevel_-lowLevel_+1);
	norm_Inf.resize(highLevel_-lowLevel_+1);
	rate_pointw.resize(highLevel_-lowLevel_+1);
	rate_L2.resize(highLevel_-lowLevel_+1);
	rate_Linf.resize(highLevel_-lowLevel_+1);

	std::vector< boost::shared_ptr<FullGrid> > fullgridarray( highLevel_-lowLevel_+1 );

	XMLConfiguration conf(confXMLFile_);

	for (int run = 0 ; run <= highLevel_-lowLevel_ ; run++){
		// create the calculator with the prescribed level
    	FitobCalculator calc( confXMLFile_ , sciprtFile_ , lowLevel_ + run , run);
    	// get the pice and the standard mesh
    	FITOB_OUT_LEVEL3( verb() , "ConvergenceAnaly::doAnalysisConvergence() , start calculating level:" << lowLevel_ + run );
    	fullgridarray[run] = calc.evaluateScript_FG( prices[run] );
    	FITOB_OUT_LEVEL3( verb() , "ConvergenceAnaly::doAnalysisConvergence() , calc level:" << lowLevel_ + run <<::std::setprecision( 12 ) << " , Price:" << prices[run]);


//    in case of MPI only rank 0 should do this
#if defined(FITOB_MPI)
	// evaluate the grid on the evaluation point
	if ( FITOB_MPI_Comm_rank() == 0 ) {
#endif
    	// calculate the convergence values
    	FITOB_OUT( " ====== ConvergenceAnaly::doAnalysisConvergence , printing results ====== " );
    	// for new output
    	FITOB_OUT( "  ");
		FITOB_OUT( "level, price, L-inf err, L2 err, L-inf rate, L2 rate, pointw. err, pointw. rate");
		FITOB_OUT( "-------------------------------------------------------------------------------");
    	for (int ii = 0 ; ii <= run ; ii++){
    		norm_L2[ii] = fitob::l2_norm( &(fullgridarray[ii]->unknVect()) , &(fullgridarray[run]->unknVect()) );
    		norm_Inf[ii] = fitob::inf_norm( &(fullgridarray[ii]->unknVect()) , &(fullgridarray[run]->unknVect()) );
    		conv[ii] = (prices[ii] - prices[run]) / prices[run];

    		rate_L2[ii] = log(norm_L2[0]/norm_L2[ii])/log(2.0)/ii;
    		rate_Linf[ii] = log(norm_Inf[0]/norm_Inf[ii])/log(2.0)/ii;
    		rate_pointw[ii] = log(fabs(conv[0]/conv[ii]))/log(2.0)/ii;


    		if (dimensionAdaptive_){
    			// todo: print the level vector
    			IVector dimensionAdaptiveLevels;
    			conf.getIntVectorConfiguration("thetaconfigurations.gridproperties.convergence-tool.CONV_DIM_ADAPT",
            	        ii , "<xmlattr>.level_vect" , ',' , dimensionAdaptiveLevels);
            	std::cout << "(";
            	for (int jj = 0 ; jj < (int)dimensionAdaptiveLevels.size() ; jj++){
            		std::cout << dimensionAdaptiveLevels[jj] << ",";
            	}
            	std::cout << ")";
    		}
    		// old output
    		//FITOB_OUT( "L"<<lowLevel_+ii<<" Price: " << prices[ii] << " , conv(rel):" << conv[ii] << " , L2:" << norm_L2[ii] << " , Inf:" << norm_Inf[ii] );
    		// new output
    		FITOB_OUT( (lowLevel_+ii) << ", " << prices[ii] << ", " << norm_Inf[ii] << ", " << norm_L2[ii] << ", " << rate_Linf[ii] << ", " << rate_L2[ii] << ", " << conv[ii] << ", " << rate_pointw[ii] );


    		// ===== plott the error of the grid ====
    		/*
    		FullGrid* fg = (fullgridarray[ii].get());
    		DVector copyVect;
    		copyVect.resize(fg->unknVect().size());
    		for (int tmp_ii = 0 ; tmp_ii < (int)fg->unknVect().size() ; tmp_ii++ ) { copyVect[tmp_ii] = fg->unknVect()[tmp_ii]; }

    		GridPlotter* plotter = calc.getPlotter().get();
    		Domain dom = Domain(calc.getNormEvalDomain());
    		MeshContext meshcontex = MeshContext( dom , 0.0 );
    		IVector specialLevels = dom.getLevelVector();
    		boost::shared_ptr<MeshBase> fgnew = boost::shared_ptr<MeshBase>(new FullGrid( &dom , specialLevels , &copyVect ));
    		meshcontex.setMesh( fgnew );
    		fitob::vect_diff( &copyVect , &(fullgridarray[run]->unknVect()));
    		string filename = "convergence_" + boost::lexical_cast<std::string>(ii) + "_";
    		// plot the error mesh
    		plotter->plot( &meshcontex , filename );*/
    	}
#if defined(FITOB_MPI)
	  } // the condition from the MPI so that this section is executed only by the 0-th rank
#endif
	}
	FITOB_OUT( " ====== ConvergenceAnaly::doAnalysisConvergence , END ====== " );
}
开发者ID:,项目名称:,代码行数:89,代码来源:


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