16 using namespace Eigen;
21 init_model_(std::move(init_model)),
22 prior_ratio_(prior_ratio)
28 init_model_(std::move(init_model)),
29 prior_ratio_(prior_ratio)
35 init_model_(std::move(init_model))
41 init_model_(std::move(resampling.init_model_))
43 prior_ratio_ = resampling.prior_ratio_;
44 resampling.prior_ratio_ = 0.5;
50 if (
this == &resampling)
55 init_model_ = std::move(resampling.init_model_);
63 int num_prior_particles =
static_cast<int>(std::floor(cor_particles.
state().cols() * prior_ratio_));
64 int num_resample_particles = cor_particles.
state().cols() - num_prior_particles;
69 Ref<VectorXi> res_parents_right(res_parents.tail(num_resample_particles));
74 for (std::size_t i : sort_indices(cor_particles.
weight().array().exp()))
76 if (j >= num_prior_particles)
78 tmp_particles.
state(j - num_prior_particles) = cor_particles.
state(i);
79 tmp_particles.
mean(j - num_prior_particles) = cor_particles.
mean(i);
81 tmp_particles.
weight(j - num_prior_particles) = cor_particles.
weight(i);
91 res_parents_right.array() += num_prior_particles;
94 init_model_->initialize(res_particles_left);
97 res_particles = std::move(res_particles_left + res_particles_right);
100 res_particles.
weight().setConstant(-std::log(cor_particles.
state().cols()));
104 res_parents.head(num_prior_particles).array() = -1;
110 std::vector<unsigned int> idx(vector.size());
111 std::iota(idx.begin(), idx.end(), 0);
113 std::sort(idx.begin(), idx.end(),
114 [&vector](
size_t idx1,
size_t idx2) { return vector[idx1] < vector[idx2]; });