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


C++ MATRIX::at方法代码示例

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


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

示例1: compute

void CTempConvs::compute(MATRIX& P,
	CLagrange_interp& intTB, CLagrange_interp& TB, CLagrange_interp& dTB,
	MATRIX& Fh, MATRIX& Fs, MATRIX& dF)
{
	const UINT num_partitions( intTB.m_partition.size() - 1 );
	const UINT num_degree( intTB.m_coeffs.n_cols - 1 );

	double *Ia, *Ib, *dIa, *dIb;

	int i, n, ii;
#pragma omp parallel default(shared) private(i, ii, n, Ia, Ib, dIa, dIb)
	{
		Ia = (double*)(calloc(sizeof(double), num_degree+1));
		Ib = (double*)(calloc(sizeof(double), num_degree + 1));
		dIa = (double*)(calloc(sizeof(double), num_degree + 1));
		dIb = (double*)(calloc(sizeof(double), num_degree + 1));

#pragma omp for schedule(static)
		for (ii = 0; ii < (int)P.n_elem; ii++)
		{

			//Current distance
			double PP(P(ii));

			for (i = 0; i<(int)num_partitions; i++)
			{
				//Current partition properties
				double partition_start(intTB.m_partition(i));	   //(k-i)dt  
				double partition_end(intTB.m_partition(i + 1));    //(k-i+1)dt

				//Integration limits
				double a(max(PP, partition_start));
				double b(max(PP, partition_end));

				//Differentiated limits wrt P (using Heaviside)
				double da(heaviside(PP - partition_start));
				double db(heaviside(PP - partition_end));

				//Compute dI_1 term and set this term to 0 after threshold point
				double tmp1(a*da - PP);
				double tmp2(sqrt(a*a - PP*PP));
				double dI1a(dotdiv(tmp1, tmp2));
				if (dI1a>partition_start) dI1a = 0;

				double tmp3(b*db - PP);
				double tmp4(sqrt(b*b - PP*PP));
				double dI1b(dotdiv(tmp3, tmp4));
				if (dI1b > partition_end) dI1b = 0;

				//First integral equation, I_0 and dI_0
				tmp2 += a;
				tmp4 += b;
				Ia[0] = log(tmp2);
				Ib[0] = log(tmp4);
				dIa[0] = (da + dI1a) / tmp2;
				dIb[0] = (db + dI1b) / tmp4;

				//Convolve polynomial coefficients with solved integral
				tmp1 = Ib[0] - Ia[0];
				Fh.at(ii) += tmp1 * intTB.m_coeffs(i, num_degree);
				Fs.at(ii) += tmp1 * TB.m_coeffs(i, num_degree);
				dF.at(ii) += (dIb[0] - dIa[0]) * dTB.m_coeffs(i, num_degree);

				//Second integral equation, I_1
				if (num_degree > 0)
				{
					//I_1
					Ia[1] = sqrt(a*a - PP*PP);
					Ib[1] = sqrt(b*b - PP*PP);

					//dI_1
					dIa[1] = dI1a;
					dIb[1] = dI1b;

					//Convolve
					tmp1 = Ib[1] - Ia[1];
					Fh.at(ii) += tmp1 * intTB.m_coeffs(i, num_degree - 1);
					Fs.at(ii) += tmp1 * TB.m_coeffs(i, num_degree - 1);
					dF.at(ii) += (dIb[1] - dIa[1]) * dTB.m_coeffs(i, num_degree - 1);

					//All other integral equations, I_2...I_p
					for (n = 2; n <= (int)num_degree; n++)
					{
						double over_n(1 / (double)n);

						// I_2...I_p
						Ia[n] = (dotpow(a, n - 1) * Ia[1] + (n - 1) * PP*PP * Ia[n - 2]) * over_n;
						Ib[n] = (dotpow(b, n - 1) * Ib[1] + (n - 1) * PP*PP * Ib[n - 2]) * over_n;

						//dI_2 ... dI_p
						tmp1 = dotpow(da, n - 1) * Ia[1];
						tmp2 = dotpow(a, n - 1) * dIa[1];
						tmp3 = (n - 1)*(2 * PP * Ia[n - 2] + PP*PP * dIa[n - 2]);
						dIa[n] = (tmp1 + tmp2 + tmp3) * over_n;

						tmp1 = dotpow(db, n - 1) * Ib[1];
						tmp2 = dotpow(b, n - 1) * dIb[1];
						tmp3 = (n - 1)*(2 * PP * Ib[n - 2] + PP*PP * dIb[n - 2]);
						dIb[n] = (tmp1 + tmp2 + tmp3) * over_n;

//.........这里部分代码省略.........
开发者ID:dan-phd,项目名称:2DTDBEM,代码行数:101,代码来源:TempConvs.cpp


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