本文整理汇总了C++中Thyra::eval_g_DgDp方法的典型用法代码示例。如果您正苦于以下问题:C++ Thyra::eval_g_DgDp方法的具体用法?C++ Thyra::eval_g_DgDp怎么用?C++ Thyra::eval_g_DgDp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thyra
的用法示例。
在下文中一共展示了Thyra::eval_g_DgDp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tab
NonlinearCGUtils::ESolveReturn
NonlinearCG<Scalar>::doSolve(
const Ptr<Thyra::VectorBase<Scalar> > &p_inout,
const Ptr<ScalarMag> &g_opt_out,
const Ptr<const ScalarMag> &g_reduct_tol_in,
const Ptr<const ScalarMag> &g_grad_tol_in,
const Ptr<const ScalarMag> &alpha_init_in,
const Ptr<int> &numIters_out
)
{
typedef ScalarTraits<Scalar> ST;
typedef ScalarTraits<ScalarMag> SMT;
using Teuchos::null;
using Teuchos::as;
using Teuchos::tuple;
using Teuchos::rcpFromPtr;
using Teuchos::optInArg;
using Teuchos::inOutArg;
using GlobiPack::computeValue;
using GlobiPack::PointEval1D;
using Thyra::VectorSpaceBase;
using Thyra::VectorBase;
using Thyra::MultiVectorBase;
using Thyra::scalarProd;
using Thyra::createMember;
using Thyra::createMembers;
using Thyra::get_ele;
using Thyra::norm;
using Thyra::V_StV;
using Thyra::Vt_S;
using Thyra::eval_g_DgDp;
typedef Thyra::Ordinal Ordinal;
typedef Thyra::ModelEvaluatorBase MEB;
namespace NCGU = NonlinearCGUtils;
using std::max;
// Validate input
g_opt_out.assert_not_null();
// Set streams
const RCP<Teuchos::FancyOStream> out = this->getOStream();
linesearch_->setOStream(out);
// Determine what step constants will be computed
const bool compute_beta_PR =
(
solverType_ == NCGU::NONLINEAR_CG_PR_PLUS
||
solverType_ == NCGU::NONLINEAR_CG_FR_PR
);
const bool compute_beta_HS = (solverType_ == NCGU::NONLINEAR_CG_HS);
//
// A) Set up the storage for the algorithm
//
const RCP<DefaultPolyLineSearchPointEvaluator<Scalar> >
pointEvaluator = defaultPolyLineSearchPointEvaluator<Scalar>();
const RCP<UnconstrainedOptMeritFunc1D<Scalar> >
meritFunc = unconstrainedOptMeritFunc1D<Scalar>(
model_, paramIndex_, responseIndex_ );
const RCP<const VectorSpaceBase<Scalar> >
p_space = model_->get_p_space(paramIndex_),
g_space = model_->get_g_space(responseIndex_);
// Stoarge for current iteration
RCP<VectorBase<Scalar> >
p_k = rcpFromPtr(p_inout), // Current solution for p
p_kp1 = createMember(p_space), // Trial point for p (in line search)
g_vec = createMember(g_space), // Vector (size 1) form of objective g(p)
g_grad_k = createMember(p_space), // Gradient of g DgDp^T
d_k = createMember(p_space), // Search direction
g_grad_k_diff_km1 = null; // g_grad_k - g_grad_km1 (if needed)
// Storage for previous iteration
RCP<VectorBase<Scalar> >
g_grad_km1 = null, // Will allocate if we need it!
d_km1 = null; // Will allocate if we need it!
ScalarMag
alpha_km1 = SMT::zero(),
g_km1 = SMT::zero(),
g_grad_km1_inner_g_grad_km1 = SMT::zero(),
g_grad_km1_inner_d_km1 = SMT::zero();
if (compute_beta_PR || compute_beta_HS) {
g_grad_km1 = createMember(p_space);
g_grad_k_diff_km1 = createMember(p_space);
}
if (compute_beta_HS) {
d_km1 = createMember(p_space);
}
//.........这里部分代码省略.........