本文整理汇总了C++中state_type::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ state_type::begin方法的具体用法?C++ state_type::begin怎么用?C++ state_type::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state_type
的用法示例。
在下文中一共展示了state_type::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lorenz_with_lyap
void lorenz_with_lyap( const state_type &x , state_type &dxdt , double t )
{
lorenz()( x , dxdt , t );
for( size_t l=0 ; l<num_of_lyap ; ++l )
{
const double *pert = x.begin() + 3 + l * 3;
double *dpert = dxdt.begin() + 3 + l * 3;
dpert[0] = - sigma * pert[0] + 10.0 * pert[1];
dpert[1] = ( R - x[2] ) * pert[0] - pert[1] - x[0] * pert[2];
dpert[2] = x[1] * pert[0] + x[0] * pert[1] - b * pert[2];
}
}
示例2: lattice
void lattice( const state_type &x , state_type &dxdt , const double /* t */ )
{
state_type::const_iterator x_begin = x.begin();
state_type::const_iterator x_end = x.end();
state_type::iterator dxdt_begin = dxdt.begin();
x_end--; // stop one before last
while( x_begin != x_end )
{
*(dxdt_begin++) = std::sin( *(x_begin) - *(x_begin++) );
}
*dxdt_begin = sin( *x_begin - *(x.begin()) ); // periodic boundary
}
示例3: operator
void operator()(const state_type& x, state_type& dxdt, const double& t)
{
for (state_type::iterator i(dxdt.begin()); i != dxdt.end(); ++i)
{
*i = 0.0;
}
// XXX
for (reaction_container_type::const_iterator
i(reactions_.begin()); i != reactions_.end(); i++)
{
// Prepare state_array of reactants and products that contain amounts of each reactants.
Ratelaw::state_container_type reactants_states(i->reactants.size());
Ratelaw::state_container_type products_states(i->products.size());
Ratelaw::state_container_type::size_type cnt(0);
for (index_container_type::const_iterator
j((*i).reactants.begin()); j != (*i).reactants.end(); ++j, cnt++)
{
reactants_states[cnt] = x[*j];
}
cnt = 0;
for (index_container_type::const_iterator
j((*i).products.begin()); j != (*i).products.end(); ++j, cnt++)
{
products_states[cnt] = x[*j];
}
double flux;
// Get pointer of Ratelaw object and call it.
if (i->ratelaw.expired() || i->ratelaw.lock()->is_available() == false)
{
boost::scoped_ptr<Ratelaw> temporary_ratelaw_obj(new RatelawMassAction(i->k));
flux = temporary_ratelaw_obj->deriv_func(reactants_states, products_states, volume_);
}
else
{
boost::shared_ptr<Ratelaw> ratelaw = (*i).ratelaw.lock();
flux = (*ratelaw).deriv_func(reactants_states, products_states, volume_);
}
// Merge each reaction's flux into whole dxdt
for (index_container_type::const_iterator
j((*i).reactants.begin()); j != (*i).reactants.end(); ++j)
{
dxdt[*j] -= flux;
}
for (index_container_type::const_iterator
j((*i).products.begin()); j != (*i).products.end(); ++j)
{
dxdt[*j] += flux;
}
}
}
示例4: operator
void operator()(state_type const& x, state_type& dxdt, double const& t)
{
for (state_type::iterator i(dxdt.begin()); i != dxdt.end(); ++i)
{
*i = 0.0;
}
NetworkModel::reaction_rule_container_type const&
reaction_rules(model_->reaction_rules());
for (NetworkModel::reaction_rule_container_type::const_iterator
i(reaction_rules.begin()); i != reaction_rules.end(); ++i)
{
double flux((*i).k() * volume_);
ReactionRule::reactant_container_type const&
reactants((*i).reactants());
ReactionRule::product_container_type const&
products((*i).products());
for (ReactionRule::reactant_container_type::iterator
j(reactants.begin()); j != reactants.end(); ++j)
{
flux *= x[index_map_[*j]] / volume_;
}
for (ReactionRule::reactant_container_type::iterator
j(reactants.begin()); j != reactants.end(); ++j)
{
dxdt[index_map_[*j]] -= flux;
}
for (ReactionRule::product_container_type::iterator
j(products.begin()); j != products.end(); ++j)
{
dxdt[index_map_[*j]] += flux;
}
}
}