本文整理汇总了C++中vectorspace::vec_mut_ptr_t::set_ele方法的典型用法代码示例。如果您正苦于以下问题:C++ vec_mut_ptr_t::set_ele方法的具体用法?C++ vec_mut_ptr_t::set_ele怎么用?C++ vec_mut_ptr_t::set_ele使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vectorspace::vec_mut_ptr_t
的用法示例。
在下文中一共展示了vec_mut_ptr_t::set_ele方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MatNorm
const MatrixOp::MatNorm
MatrixOpNonsing::calc_cond_num(
EMatNormType requested_norm_type
,bool allow_replacement
) const
{
using BLAS_Cpp::no_trans;
using BLAS_Cpp::trans;
using LinAlgOpPack::V_InvMtV;
const VectorSpace
&space_cols = this->space_cols(),
&space_rows = this->space_rows();
const index_type
num_cols = space_rows.dim();
TEST_FOR_EXCEPTION(
!(requested_norm_type == MAT_NORM_1 || requested_norm_type == MAT_NORM_INF), MethodNotImplemented
,"MatrixOp::calc_norm(...): Error, This default implemenation can only "
"compute the one norm or the infinity norm!"
);
//
// Here we implement Algorithm 2.5 in "Applied Numerical Linear Algebra", Demmel (1997)
// using the momenclature in the text. This is applied to the inverse matrix.
//
const MatrixOpNonsing
&B = *this;
bool
do_trans = requested_norm_type == MAT_NORM_INF;
VectorSpace::vec_mut_ptr_t
x = (do_trans ? space_rows : space_cols).create_member(1.0/num_cols),
w = (do_trans ? space_cols : space_rows).create_member(),
zeta = (do_trans ? space_cols : space_rows).create_member(),
z = (do_trans ? space_rows : space_cols).create_member();
const index_type max_iter = 5; // Recommended by Highman 1988, (see Demmel's reference)
value_type w_nrm = 0.0;
for( index_type k = 0; k <= max_iter; ++k ) {
V_InvMtV( w.get(), B, !do_trans ? no_trans : trans, *x ); // w = B*x
sign( *w, zeta.get() ); // zeta = sign(w)
V_InvMtV( z.get(), B, !do_trans ? trans : no_trans, *zeta ); // z = B'*zeta
value_type z_j = 0.0; // max |z(j)| = ||z||inf
index_type j = 0;
max_abs_ele( *z, &z_j, &j );
const value_type zTx = dot(*z,*x); // z'*x
w_nrm = w->norm_1(); // ||w||1
if( ::fabs(z_j) <= zTx ) { // Update
break;
}
else {
*x = 0.0;
x->set_ele(j,1.0);
}
}
const MatNorm M_nrm = this->calc_norm(requested_norm_type);
return MatNorm( w_nrm * M_nrm.value ,requested_norm_type );
}