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


C++ Polmap::eval方法代码示例

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


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

示例1: Twiss

MapBeamLine::MapBeamLine(string filename, string filenameerr, int order, int nbthreads, int fmultipole, bool strpl) {
	Twiss t = Twiss(filename);
	Twiss terr = Twiss(filenameerr);
	if (strpl) {
		t.stripLine();
		terr.stripLine();
	}
	omp_set_num_threads(nbthreads);
	vector<vector<Polynom<double>>> v = separateComplexList(EQ(4, order));
	Polynom<double> x = X<double>(order);
	Polynom<double> px = PX<double>(order);
	Polynom<double> y = Y<double>(order);
	Polynom<double> py = PY<double>(order);
	Polynom<double> d = D<double>(order);
	Polynom<double> s = S<double>(order);
	Polmap<double> R = generateDefaultMap(x, px, y, py, d, s);
	
	Polmap<double>* Res = new Polmap<double>[nbthreads];
	for (int i = 0; i < nbthreads; i ++)
		Res[i] = R; 
	
	int size = t.elems.size();
	if (strpl) {	
		#pragma omp parallel for shared(Res) schedule(static)
		for (int i = 0; i < size; i ++) {
			int index = omp_get_thread_num();
			Polmap<double> mp = mapForElement(t.elems[i], v, x, px, y, py, d, s, fmultipole);	
			double dx = atof(terr.elems[i][DX].c_str());
          		double dy = atof(terr.elems[i][DY].c_str());
			mp = mp.eval("x", Polynom<double>(order, 1E-18, "x", 1) + dx); 
			mp = mp.eval("y", Polynom<double>(order, 1E-18, "y", 1) + dy);
			Res[index] = mp * Res[index];		
		}
	}
	else {
		#pragma omp parallel for shared(Res) schedule(static)
                for (int i = 0; i < size; i ++) {
                        int index = omp_get_thread_num();
                        Polmap<double> mp = mapForElement(t.elems[i], v, x, px, y, py, d, s, fmultipole);
                        double dx = atof(terr.elems[i][DX].c_str());
                        double dy = atof(terr.elems[i][DY].c_str());
                        mp = mp.eval("x", Polynom<double>(order, 1E-18, "x", 1) + dx);
                        mp = mp.eval("y", Polynom<double>(order, 1E-18, "y", 1) + dy);
                        if (mp.pols.size() != 0)
				Res[index] = mp * Res[index];
                }

	}
	R = Res[0];
	for (int i = 1; i < nbthreads; i ++)
		R = Res[i] * R;
	polmap = R.getMap();
	for (unordered_map<string, Polynom<double>>:: iterator it = R.pols.begin(); it != R.pols.end(); it ++) 
		pols[it->first] = it->second; 
	delete [] Res; 
}
开发者ID:,项目名称:,代码行数:56,代码来源:


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