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


C++ System::NumVariables方法代码示例

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


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

示例1: NewtonLoop

			SuccessCode NewtonLoop(Vec<ComplexType> & next_space,
			                       RealType & norm_delta_z,
			                       RealType & norm_J,
			                       RealType & norm_J_inverse,
			                       RealType & condition_number_estimate,
					               System const& S,
					               Vec<ComplexType> const& current_space, // pass by value to get a copy of it
					               ComplexType const& current_time, 
					               RealType const& tracking_tolerance,
					               unsigned min_num_newton_iterations,
					               unsigned max_num_newton_iterations,
					               config::AdaptiveMultiplePrecisionConfig const& AMP_config)
			{
				#ifndef BERTINI_DISABLE_ASSERTS
				assert(max_num_newton_iterations >= min_num_newton_iterations && "max number newton iterations must be at least the min.");
				#endif


				next_space = current_space;
				for (unsigned ii = 0; ii < max_num_newton_iterations; ++ii)
				{
					//TODO: wrap these into a single line.
					auto f = S.Eval(next_space, current_time);
					auto J = S.Jacobian(next_space, current_time);
					auto LU = J.lu();


					if (LUPartialPivotDecompositionSuccessful(LU.matrixLU())!=MatrixSuccessCode::Success)
						return SuccessCode::MatrixSolveFailure;


					auto delta_z = LU.solve(-f);
					next_space += delta_z;


					norm_delta_z = delta_z.norm();
					norm_J = J.norm();
					norm_J_inverse = LU.solve(RandomOfUnits<ComplexType>(S.NumVariables())).norm();
					condition_number_estimate = norm_J*norm_J_inverse;



					if ( (norm_delta_z < tracking_tolerance) && (ii >= (min_num_newton_iterations-1)) )
						return SuccessCode::Success;

					if (!amp::CriterionB(norm_J, norm_J_inverse, max_num_newton_iterations - ii, tracking_tolerance, norm_delta_z, AMP_config))
						return SuccessCode::HigherPrecisionNecessary;

					if (!amp::CriterionC(norm_J_inverse, next_space, tracking_tolerance, AMP_config))
						return SuccessCode::HigherPrecisionNecessary;
				}

				return SuccessCode::FailedToConverge;
			}
开发者ID:aliddell,项目名称:b2,代码行数:54,代码来源:newton_correct.hpp


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