本文整理汇总了C++中vectorspace::vec_mut_ptr_t::sub_view方法的典型用法代码示例。如果您正苦于以下问题:C++ vec_mut_ptr_t::sub_view方法的具体用法?C++ vec_mut_ptr_t::sub_view怎么用?C++ vec_mut_ptr_t::sub_view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vectorspace::vec_mut_ptr_t
的用法示例。
在下文中一共展示了vec_mut_ptr_t::sub_view方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vp_StMtV
void MatrixOpSubView::Vp_StMtV(
VectorMutable* y, value_type a, BLAS_Cpp::Transp M_trans_in
, const Vector& x, value_type b
) const
{
using BLAS_Cpp::no_trans;
using BLAS_Cpp::trans;
assert_initialized();
BLAS_Cpp::Transp
M_trans_trans = ( M_trans_==no_trans ? M_trans_in : BLAS_Cpp::trans_not(M_trans_in) );
// ToDo: Assert compatibility!
if( rng_rows_.full_range() && rng_cols_.full_range() ) {
AbstractLinAlgPack::Vp_StMtV( // The matrix is just transposed
y, a
,*M_full_, M_trans_trans
,x, b );
return;
}
// y = b*y
Vt_S( y, b );
//
// xt1 = 0.0
// xt3 = xt(op_op_rng_cols) = x
// xt3 = 0.0
//
// [ yt1 ] [ xt1 ]
// [ yt2 ] = a * op(op(M_full)) * [ xt3 ]
// [ yt3 ] [ xt3 ]
//
// =>
//
// y += yt2 = yt(op_op_rng_rows)
//
const Range1D
op_op_rng_rows = ( M_trans_trans == no_trans ? rng_rows_ : rng_cols_ ),
op_op_rng_cols = ( M_trans_trans == no_trans ? rng_cols_ : rng_rows_ );
VectorSpace::vec_mut_ptr_t
xt = ( M_trans_trans == no_trans ? M_full_->space_rows() : M_full_->space_cols() ).create_member(),
yt = ( M_trans_trans == no_trans ? M_full_->space_cols() : M_full_->space_rows() ).create_member();
*xt = 0.0;
*xt->sub_view(op_op_rng_cols) = x;
LinAlgOpPack::V_StMtV( yt.get(), a, *M_full_, M_trans_trans, *xt );
LinAlgOpPack::Vp_V( y, *yt->sub_view(op_op_rng_rows) );
}
示例2: do_step
bool CheckDescentQuasiNormalStep_Step::do_step(
Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type
,poss_type assoc_step_poss
)
{
using BLAS_Cpp::no_trans;
using AbstractLinAlgPack::dot;
using LinAlgOpPack::V_MtV;
NLPAlgo &algo = rsqp_algo(_algo);
NLPAlgoState &s = algo.rsqp_state();
NLP &nlp = algo.nlp();
const Range1D equ_decomp = s.equ_decomp();
EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
std::ostream& out = algo.track().journal_out();
// 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 );
}
const size_type
nb = nlp.num_bounded_x();
// Get iteration quantities
IterQuantityAccess<VectorMutable>
&c_iq = s.c(),
&Ypy_iq = s.Ypy();
const Vector::vec_ptr_t
cd_k = c_iq.get_k(0).sub_view(equ_decomp);
const Vector
&Ypy_k = Ypy_iq.get_k(0);
value_type descent_c = -1.0;
if( s.get_iter_quant_id( Gc_name ) != AlgorithmState::DOES_NOT_EXIST ) {
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
out << "\nGc_k exists; compute descent_c = c_k(equ_decomp)'*Gc_k(:,equ_decomp)'*Ypy_k ...\n";
}
const MatrixOp::mat_ptr_t
Gcd_k = s.Gc().get_k(0).sub_view(Range1D(),equ_decomp);
VectorSpace::vec_mut_ptr_t
t = cd_k->space().create_member();
V_MtV( t.get(), *Gcd_k, BLAS_Cpp::trans, Ypy_k );
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
out << "\nGc_k(:,equ_decomp)'*Ypy_k =\n" << *t;
}
descent_c = dot( *cd_k, *t );
}
else {
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
out << "\nGc_k does not exist; compute descent_c = c_k(equ_decomp)'*FDGc_k(:,equ_decomp)'*Ypy_k "
<< "using finite differences ...\n";
}
VectorSpace::vec_mut_ptr_t
t = nlp.space_c()->create_member();
calc_fd_prod().calc_deriv_product(
s.x().get_k(0),nb?&nlp.xl():NULL,nb?&nlp.xu():NULL
,Ypy_k,NULL,&c_iq.get_k(0),true,&nlp
,NULL,t.get()
,static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ? &out : NULL
);
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
out << "\nFDGc_k(:,equ_decomp)'*Ypy_k =\n" << *t->sub_view(equ_decomp);
}
descent_c = dot( *cd_k, *t->sub_view(equ_decomp) );
}
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
out << "\ndescent_c = " << descent_c << std::endl;
}
if( descent_c > 0.0 ) { // ToDo: add some allowance for > 0.0 for finite difference errors!
if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
out << "\nError, descent_c > 0.0; this is not a descent direction\n"
<< "Throw TestFailed and terminate the algorithm ...\n";
}
TEST_FOR_EXCEPTION(
true, TestFailed
,"CheckDescentQuasiNormalStep_Step::do_step(...) : Error, descent for the decomposed constraints "
"with respect to the quasi-normal step c_k(equ_decomp)'*FDGc_k(:,equ_decomp)'*Ypy_k = "
<< descent_c << " > 0.0; This is not a descent direction!\n" );
}
return true;
}