// Control parameters for the population size calculation. [err] is // the max error between the true distribution and the estimated // distribution. [z] is the upper standard normal quantile for (1 - // p), where p is the probability that the error on the estimated // distrubition will be less than [err]. pf->pop_err = 0.01; pf->pop_z = 3; pf->dist_threshold = 0.5; pf->current_set = 0; for (j = 0; j < 2; j++) { set = pf->sets + j;
// Initialize the filter using a guassian voidpf_init(pf_t *pf, pf_vector_t mean, pf_matrix_t cov) { int i; pf_sample_set_t *set; pf_sample_t *sample; pf_pdf_gaussian_t *pdf; set = pf->sets + pf->current_set; // Create the kd tree for adaptive sampling pf_kdtree_clear(set->kdtree);
set->sample_count = pf->max_samples;
pdf = pf_pdf_gaussian_alloc(mean, cov); // Compute the new sample poses for (i = 0; i < set->sample_count; i++) { sample = set->samples + i; sample->weight = 1.0 / pf->max_samples; sample->pose = pf_pdf_gaussian_sample(pdf);
// Add sample to histogram pf_kdtree_insert(set->kdtree, sample->pose, sample->weight); }
Base b; cout<<"----------------"<<endl; Derived d(b);
运行结果:
1 2 3 4 5 6 7 8 9 10 11 12 13
base constructor ---------------- base copy constructor base constructor base constructor base operator = derived constructor base destructor ---------------- derived destructor base destructor base destructor base destructor