本文整理汇总了C++中input::insert_item方法的典型用法代码示例。如果您正苦于以下问题:C++ input::insert_item方法的具体用法?C++ input::insert_item怎么用?C++ input::insert_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类input
的用法示例。
在下文中一共展示了input::insert_item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postprocess
void jones_optical::postprocess(input& invals){
#ifdef gen_t_dat
func_dat=fopen("python/grad_data2.out", "w");
func_score = fopen("python/score_data2.out", "w");
#else
func_dat=fopen("python/grad_data.out", "w");
func_score = fopen("python/score_data.out", "w");
#endif
stable_spectral_pde_1d_tmpl<comp>::postprocess(invals);
if(dimension%2){
err("System jones_optical requires an even dimension", "jones_optical::postprocess",
"system/jones_optical.cpp", FATAL_ERROR);
}
int num_segments;
invals.retrieve(num_segments, "num_jones_segments", this);
if(num_segments < 0){
err("Number of jones segments must be greater than or equal to zero",
"jones_optical::postprocess", "system/jones_optical.cpp", FATAL_ERROR);
}
invals.retrieve(jones_int_dist, "jones_int_dist", this);
if(jones_int_dist<0){
err("The distance between jones segments, jones_int_dist, must be greater than or equal to zero",
"jones_optical::postprocess", "system/jones_optical.cpp", FATAL_ERROR);
}
memp.add(dimension, &nvec1);
memp.add(nts, &help, &t, &kurtosis_help, &phold, &nvec2);
double dt = 60.0/nts;
gaussian_noise(ucur, dimension, 0, 0.2);
for(size_t i = 0; i < nts; i++){
t[i] = dt*(i-nts/2.0);
}
for(size_t i = 0; i < nts; i++){
ucur[i] = ucur[i+nts] = 1.00/cosh(t[i]/2.0);
help[i] = _real(ucur[i]);
nvec1[i] = ucur[i];
}
for(size_t i = 0; i < num_pulses; i++){
fft(nvec1 + i*nts, nvec1 +1*nts, nts);
}
//generate variables for the jones matrices
//create jones matrices
std::string name_base = "jones_system_vars";
std::string mat_base = "jones_system_matrices";
for(int i = 0; i < num_segments; i++){
std::vector<std::shared_ptr<variable> > vv(4);
for(auto& val : vv){
val = std::make_shared<variable>();
val->setname(get_unique_name(name_base));
val->holder=holder;
val->parse("0.1");
#ifdef gen_t_dat
val->set(0*2*3.1415*(rand()*1.0/RAND_MAX));
#else
val->set(0);
#endif
invals.insert_item(val);
cont->addvar(val);
}
std::shared_ptr<jones_matrix> m = std::make_shared<jones_matrix>(get_unique_name(mat_base), i, holder);
invals.insert_item(m);
m->setup(vv);
jones_matrices.push_back(m);
}
}
示例2: postprocess
/*!
* This function does the processing for the c_elegans class.
*
* It initializes the various matrices and reads values from the input files
*/
void c_elegans::postprocess(input& in){
rhs_type::postprocess(in);
if(dimension != num_neur*2){
err("Dimension must be 558, which is double the number of neurons",
"", "", FATAL_ERROR);
}
in.retrieve(beta, "beta", this);
in.retrieve(tau, "tau", this);
in.retrieve(gelec, "gelec", this);
in.retrieve(gchem, "gchem", this);
in.retrieve(memV, "memV", this);
in.retrieve(memG, "memG", this);
in.retrieve(EchemEx, "EchemEx", this);
in.retrieve(EchemInh, "EchemInh", this);
in.retrieve(ar, "ar", this);
in.retrieve(ad, "ad", this);
std::string ag_fname, a_fname;
in.retrieve(ag_fname, "ag_mat", this);
in.retrieve(a_fname, "a_mat", this);
sparse_type a_m(num_neur, num_neur);
ag_full.resize(num_neur, num_neur);
laplacian.resize(num_neur, num_neur);
read_mat(ag_fname, ag_full);
read_mat(a_fname, a_m);
//create transposed sparse matrix AEchem
AEchem_trans_full.resize(num_neur, num_neur);
AEchem_trans_full = a_m.transpose();
AEchem_trans.resize(num_neur, num_neur);
//do any needed fake iterations, must make more general at some point
size_t num_comb;
int iterations;
in.retrieve(num_comb, "num_comb", this);
in.retrieve(iterations, "iterations", this);
in.retrieve(cur_ind, "!start_ind", this);
abl_neur.resize(num_comb);
for(auto& val : abl_neur){
val = 0;
}
if(abl_neur.size() != 1){
next_comb(abl_neur, num_neur);
}
for(int i = 0; i < cur_ind; i++){
for(int j = 0; j < iterations; j++){
if(next_comb(abl_neur, num_neur)){
char ind_str[20];//won't ever have a 20 digit index
//handy buffer to overflow for those hacking this.
sprintf(ind_str, "%d", (int)cur_ind);
err(std::string("Combinations exhausted in index ") + ind_str,
"c_elegans::postprocess","rhs/c_elegans.cpp", FATAL_ERROR);
}
}
}
auto dat_inds =
std::shared_ptr<writer>(new writer(true));
dat_inds->add_data(data::create("Ablations", abl_neur.data(), abl_neur.size()), writer::OTHER);
holder->add_writer(dat_inds);
//write first ablation data
//set up dummy connection to toroidal controller for now
controller* cont;
in.retrieve(cont, "controller", this);
auto val = std::make_shared<variable>();
val->setname("c_elegans_quickfix");
val->holder = holder;
val->parse("0.1");
in.insert_item(val);
cont->addvar(val);
in.retrieve(dummy, val->name(), this);
has_gone=true; //is true at first to allow update of zero index to occur
first_round=true;
update();
}