本文整理汇总了C++中vectorspace::vec_mut_ptr_t::dim方法的典型用法代码示例。如果您正苦于以下问题:C++ vec_mut_ptr_t::dim方法的具体用法?C++ vec_mut_ptr_t::dim怎么用?C++ vec_mut_ptr_t::dim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vectorspace::vec_mut_ptr_t
的用法示例。
在下文中一共展示了vec_mut_ptr_t::dim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finite_diff_check
//.........这里部分代码省略.........
const value_type
rand_y_l = -1.0, rand_y_u = 1.0,
small_num = ::sqrt(std::numeric_limits<value_type>::epsilon());
try {
// ///////////////////////////////////////////////
// (1) Check Gf
if(Gf) {
switch( Gf_testing_method() ) {
case FD_COMPUTE_ALL: {
// Compute FDGf outright
TEST_FOR_EXCEPT(true); // ToDo: update above!
break;
}
case FD_DIRECTIONAL: {
// Compute FDGF'*y using random y's
if(out)
*out
<< "\nComparing products Gf'*y with finite difference values FDGf'*y for "
<< "random y's ...\n";
vec_mut_ptr_t y = space_x->create_member();
value_type max_warning_viol = 0.0;
int num_warning_viol = 0;
const int num_fd_directions_used = ( num_fd_directions() > 0 ? num_fd_directions() : 1 );
for( int direc_i = 1; direc_i <= num_fd_directions_used; ++direc_i ) {
if( num_fd_directions() > 0 ) {
random_vector( rand_y_l, rand_y_u, y.get() );
if(out)
*out
<< "\n****"
<< "\n**** Random directional vector " << direc_i << " ( ||y||_1 / n = "
<< (y->norm_1() / y->dim()) << " )"
<< "\n***\n";
}
else {
*y = 1.0;
if(out)
*out
<< "\n****"
<< "\n**** Ones vector y ( ||y||_1 / n = "<<(y->norm_1()/y->dim())<<" )"
<< "\n***\n";
}
value_type
Gf_y = dot( *Gf, *y ),
FDGf_y;
preformed_fd = fd_deriv_prod.calc_deriv_product(
xo,xl,xu
,*y,NULL,NULL,true,nlp,&FDGf_y,NULL,out,dump_all(),dump_all()
);
if( !preformed_fd )
goto FD_NOT_PREFORMED;
assert_print_nan_inf(FDGf_y, "FDGf'*y",true,out);
const value_type
calc_err = ::fabs( ( Gf_y - FDGf_y )/( ::fabs(Gf_y) + ::fabs(FDGf_y) + small_num ) );
if( calc_err >= Gf_warning_tol() ) {
max_warning_viol = my_max( max_warning_viol, calc_err );
++num_warning_viol;
}
if(out)
*out
<< "\nrel_err(Gf'*y,FDGf'*y) = "
<< "rel_err(" << Gf_y << "," << FDGf_y << ") = "
<< calc_err << endl;
if( calc_err >= Gf_error_tol() ) {