本文整理汇总了C++中AbstractLinAlgPack::inv_of_difference方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractLinAlgPack::inv_of_difference方法的具体用法?C++ AbstractLinAlgPack::inv_of_difference怎么用?C++ AbstractLinAlgPack::inv_of_difference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractLinAlgPack
的用法示例。
在下文中一共展示了AbstractLinAlgPack::inv_of_difference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_step
bool PostEvalNewPointBarrier_Step::do_step(
Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type
,poss_type assoc_step_poss
)
{
using Teuchos::dyn_cast;
using IterationPack::print_algorithm_step;
using AbstractLinAlgPack::inv_of_difference;
using AbstractLinAlgPack::correct_upper_bound_multipliers;
using AbstractLinAlgPack::correct_lower_bound_multipliers;
using LinAlgOpPack::Vp_StV;
NLPAlgo &algo = dyn_cast<NLPAlgo>(_algo);
IpState &s = dyn_cast<IpState>(_algo.state());
NLP &nlp = algo.nlp();
EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
std::ostream& out = algo.track().journal_out();
if(!nlp.is_initialized())
nlp.initialize(algo.algo_cntr().check_results());
// print step header.
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
{
using IterationPack::print_algorithm_step;
print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out );
}
IterQuantityAccess<VectorMutable> &x_iq = s.x();
IterQuantityAccess<MatrixSymDiagStd> &Vl_iq = s.Vl();
IterQuantityAccess<MatrixSymDiagStd> &Vu_iq = s.Vu();
///***********************************************************
// Calculate invXl = diag(1/(x-xl))
// and invXu = diag(1/(xu-x)) matrices
///***********************************************************
// get references to x, invXl, and invXu
VectorMutable& x = x_iq.get_k(0);
MatrixSymDiagStd& invXu = s.invXu().set_k(0);
MatrixSymDiagStd& invXl = s.invXl().set_k(0);
//std::cout << "xu=\n";
//nlp.xu().output(std::cout);
inv_of_difference(1.0, nlp.xu(), x, &invXu.diag());
inv_of_difference(1.0, x, nlp.xl(), &invXl.diag());
//std::cout << "invXu=\v";
//invXu.output(std::cout);
//std::cout << "\ninvXl=\v";
//invXl.output(std::cout);
// Check for divide by zeros -
using AbstractLinAlgPack::assert_print_nan_inf;
assert_print_nan_inf(invXu.diag(), "invXu", true, &out);
assert_print_nan_inf(invXl.diag(), "invXl", true, &out);
// These should never go negative either - could be a useful check
// Initialize Vu and Vl if necessary
if ( /*!Vu_iq.updated_k(0) */ Vu_iq.last_updated() == IterQuantity::NONE_UPDATED )
{
VectorMutable& vu = Vu_iq.set_k(0).diag();
vu = 0;
Vp_StV(&vu, s.barrier_parameter().get_k(-1), invXu.diag());
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
{
out << "\nInitialize Vu with barrier_parameter * invXu ...\n";
}
}
if ( /*!Vl_iq.updated_k(0) */ Vl_iq.last_updated() == IterQuantity::NONE_UPDATED )
{
VectorMutable& vl = Vl_iq.set_k(0).diag();
vl = 0;
Vp_StV(&vl, s.barrier_parameter().get_k(-1), invXl.diag());
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
{
out << "\nInitialize Vl with barrier_parameter * invXl ...\n";
}
}
if (s.num_basis().updated_k(0))
{
// Basis changed, reorder Vl and Vu
if (Vu_iq.updated_k(-1))
{ Vu_iq.set_k(0,-1); }
if (Vl_iq.updated_k(-1))
{ Vl_iq.set_k(0,-1); }
VectorMutable& vu = Vu_iq.set_k(0).diag();
VectorMutable& vl = Vl_iq.set_k(0).diag();
s.P_var_last().permute( BLAS_Cpp::trans, &vu ); // Permute back to original order
s.P_var_last().permute( BLAS_Cpp::trans, &vl ); // Permute back to original order
//.........这里部分代码省略.........