本文整理汇总了C++中StateSet::get_num_states方法的典型用法代码示例。如果您正苦于以下问题:C++ StateSet::get_num_states方法的具体用法?C++ StateSet::get_num_states怎么用?C++ StateSet::get_num_states使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateSet
的用法示例。
在下文中一共展示了StateSet::get_num_states方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_stateset
// Write a whole StateSet in one go. The optional argument sort_order can be
// given to write states in an order different from their order in the
// StateSet (for example, in order of increasing energy).
void Datafile::write_stateset(StateSet const& stateset, int step, std::list<size_t> const* sort_order) {
hsize_t states_cur_size[2];
hsize_t state_history_cur_size[1];
try {
ensure_states_data();
ensure_state_history_data();
// calculate current size of states_data
states_data.getSpace().getSimpleExtentDims(states_cur_size);
// new slot for states will be same as states_cur_size[0]
const hsize_t new_slot = states_cur_size[0];
state_history_pair pair;
pair.step = step;
pair.index = static_cast<int>(new_slot);
// calculate current size of state_history_data and extend by one
state_history_data.getSpace().getSimpleExtentDims(state_history_cur_size);
hsize_t new_size = state_history_cur_size[0]+1;
state_history_data.extend(&new_size);
space_1d.setExtentSimple(1, &new_size);
space_1d.selectElements(H5S_SELECT_SET, 1, state_history_cur_size);
validate_selection(space_1d);
// record what was the step when states were saved
state_history_data.write(&pair, state_history_type, scalar_space, space_1d);
// write states
const size_t N = stateset.get_num_states();
if (sort_order == NULL)
for (size_t m=0; m<N; m++)
write_state(new_slot, m, stateset[m]);
else {
std::list<size_t>::const_iterator it = sort_order->begin();
for (size_t m=0; m<N; m++) {
write_state(new_slot, m, stateset[*it]);
it++;
}
}
}
catch(H5::Exception& e) {
e.printError();
throw;
}
}