本文整理汇总了C++中pod_vector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ pod_vector::resize方法的具体用法?C++ pod_vector::resize怎么用?C++ pod_vector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pod_vector
的用法示例。
在下文中一共展示了pod_vector::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xconvert
static int xconvert(const char* x, pod_vector<T>& out, const char** errPos, int sep) {
if (sep == 0) { sep = Potassco::def_sep; }
typename pod_vector<T>::size_type sz = out.size();
std::size_t t = Potassco::convert_seq<T>(x, out.max_size() - sz, std::back_inserter(out), static_cast<char>(sep), errPos);
if (!t) { out.resize(sz); }
return static_cast<int>(t);
}
示例2: get_rev
void subgraph_info::get_rev(
const play::const_random_iterator<Addr>& random_itr ,
const pod_vector<size_t>& dep_taddr ,
addr_t i_dep ,
pod_vector<addr_t>& subgraph )
{ // check sizes
CPPAD_ASSERT_UNKNOWN( map_user_op_.size() == n_op_ );
// process_range_
CPPAD_ASSERT_UNKNOWN( process_range_[i_dep] == false );
process_range_[i_dep] = true;
// special value; see init_rev_in_subgraph
addr_t depend_yes = addr_t( n_dep_ );
// assumption on i_dep
CPPAD_ASSERT_UNKNOWN( i_dep < depend_yes );
// start with an empty subgraph for this dependent variable
subgraph.resize(0);
// tape index corresponding to this dependent variable
size_t i_var = dep_taddr[i_dep];
// operator corresponding to this dependent variable
size_t i_op = random_itr.var2op(i_var);
i_op = size_t( map_user_op_[i_op] );
// if this variable depends on the selected indepent variables
// process its subgraph
CPPAD_ASSERT_UNKNOWN( in_subgraph_[i_op] != i_dep )
if( in_subgraph_[i_op] <= depend_yes )
{ subgraph.push_back( addr_t(i_op) );
in_subgraph_[i_op] = i_dep;
}
// space used to return set of arguments that are variables
pod_vector<size_t> argument_variable;
// temporary space used by get_argument_variable
pod_vector<bool> work;
// scan all the operators in this subgraph
size_t sub_index = 0;
while(sub_index < subgraph.size() )
{ // this operator connected to this dependent and selected independent
i_op = size_t( subgraph[sub_index] );
CPPAD_ASSERT_UNKNOWN( in_subgraph_[i_op] == i_dep );
//
// There must be a result for this operator
# ifndef NDEBUG
OpCode op = random_itr.get_op(i_op);
CPPAD_ASSERT_UNKNOWN(op == AFunOp || NumRes(op) > 0 );
# endif
//
// which variables are connected to this operator
get_argument_variable(random_itr, i_op, argument_variable, work);
for(size_t j = 0; j < argument_variable.size(); ++j)
{ // add the corresponding operators to the subgraph
size_t j_var = argument_variable[j];
size_t j_op = random_itr.var2op(j_var);
j_op = size_t( map_user_op_[j_op] );
bool add = in_subgraph_[j_op] <= depend_yes;
add &= in_subgraph_[j_op] != i_dep;
if( random_itr.get_op(j_op) == InvOp )
{ CPPAD_ASSERT_UNKNOWN( j_op == j_var );
add &= select_domain_[j_var - 1];
}
if( add )
{ subgraph.push_back( addr_t(j_op) );
in_subgraph_[j_op] = i_dep;
}
}
// we are done scaning this subgraph operator
++sub_index;
}
}
示例3: arg_is_variable
void arg_is_variable(
OpCode op ,
const Addr* arg ,
pod_vector<bool>& is_variable )
{ size_t num_arg = NumArg(op);
is_variable.resize( num_arg );
//
switch(op)
{
// -------------------------------------------------------------------
// cases where true number of arugments = NumArg(op) == 0
case EndOp:
case InvOp:
case FunrvOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 );
break;
// -------------------------------------------------------------------
// cases where NumArg(op) == 1
case AbsOp:
case AcoshOp:
case AcosOp:
case AsinhOp:
case AsinOp:
case AtanhOp:
case AtanOp:
case CoshOp:
case CosOp:
case Expm1Op:
case ExpOp:
case Log1pOp:
case LogOp:
case SignOp:
case SinhOp:
case SinOp:
case SqrtOp:
case TanhOp:
case TanOp:
case FunavOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
is_variable[0] = true;
break;
case BeginOp:
case ParOp:
case FunapOp:
case FunrpOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 );
is_variable[0] = false;
break;
// -------------------------------------------------------------------
// cases where NumArg(op) == 2
case AddpvOp:
case DisOp:
case DivpvOp:
case EqpvOp:
case LepvOp:
case LtpvOp:
case MulpvOp:
case NepvOp:
case PowpvOp:
case SubpvOp:
case ZmulpvOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 );
is_variable[0] = false;
is_variable[1] = true;
break;
case DivvpOp:
case LevpOp:
case LtvpOp:
case PowvpOp:
case SubvpOp:
case ZmulvpOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 );
is_variable[0] = true;
is_variable[1] = false;
break;
case AddvvOp:
case DivvvOp:
case EqvvOp:
case LevvOp:
case LtvvOp:
case MulvvOp:
case NevvOp:
case PowvvOp:
case SubvvOp:
case ZmulvvOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 );
is_variable[0] = true;
is_variable[1] = true;
break;
case ErfOp:
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
//.........这里部分代码省略.........