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


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

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


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

示例1: run_Zmatrices_calculation_scattered_field

void run_Zmatrices_calculation_scattered_field(Zmatrices& Z_matrices, UINT Lagrange_degree,
	MATRIX M, MATRIX J, GRID& rho, double material_param, const char* result_file)
{
	// Simulation parameters
	int N_T = Z_matrices.z_N_T;
	double dt = Z_matrices.z_dt;
	double c = Z_matrices.z_c;
	UINT inner_points = 1;
	printf("\nSimulation parameters for scattered field:"
		"\n\tNumber of grid vertices = %i"
		"\n\tMaterial parameter = %e"
		"\n\tc = %e"
		"\n\tdt = %e"
		"\n\tN_T = %i"
		"\n\tinner_points = %i"
		"\n\tLagrange_degree = %i\n\n",
		(int)rho.size(), material_param, c, dt, N_T, inner_points, Lagrange_degree);

	// Lagrange interpolators (temporal basis functions)
	CLagrange_interp timeBasis = CLagrange_interp(dt, Lagrange_degree);
	Z_matrices.timeBasis_D = timeBasis;
	CLagrange_interp timeBasis_Ns = timeBasis;
	timeBasis_Ns.diff();
	Z_matrices.timeBasis_Ns = timeBasis_Ns;

	Z_matrices.z_inner_points = inner_points;

	// do main computation
	cube S, D;
#ifdef OS_WIN
	clock_t t;
#else
	struct timeval * t = new struct timeval;
#endif
	start_timing(t);
	Z_matrices.compute_fields(S, D, rho);
	S *= material_param;
	finish_timing(t);

	start_timing(t);
	MATRIX rhs(D.n_rows, N_T, fill::zeros);
	VECTOR rhs_(D.n_rows, fill::zeros);
	printf("%s\n\n", "Marching on in time...");
	int j(0), k(0);
//#pragma omp parallel default(shared) private(j,k)
	for (j = 0; j < N_T; j++)
	{
//#pragma omp for
		for (k = 0; k < j+1; k++)
		{
			rhs_ += D.slice(k)*M.col(j - k) - S.slice(k)*J.col(j - k);
		}

		rhs.col(j) = rhs_;
		rhs_.zeros();

		//Status
		printf("\r%i ", j + 1);
		fflush(stdout);
	}

	finish_timing(t);

	// Output MAT file that stores the operators
	printf("Compressing matrices into Matlab form...");
	mat_t *matfpZ = NULL;
	matvar_t *matvar = NULL;

	// Save matrices as separate matlab variables
	if (CreateMatFile(&matfpZ, result_file) == -1)
	{
		return;
	}
	else
	{
		double NT = (double)N_T;
		InsertVar(&matfpZ, "N_T", &NT);
		InsertMatrix(&matfpZ, "E", rhs);
		FinishMatFile(&matfpZ);

		// free memory
		S.clear(), D.clear();

		printf("\t- done.\nOutput file location: %s\n\n", result_file);
	}
}
开发者ID:dan-phd,项目名称:2DTDBEM,代码行数:86,代码来源:Start.cpp


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