// Args: // full_data: The complete vector of observed data. The // expectation is that this is owned by a Model. // first: The position of the first data point in *full_data // that this worker should impute. // one_past_end: The position that is one past the last data // point in *full_data that this worker should impute. // // The data will be forgotten (by a call to forget_data()) if // full_data is a nullptr, or first == one_past_end. void assign_data(const std::vector<Ptr<OBSERVED_DATA> > *full_data, std::size_t first, std::size_t one_past_end) { if (!full_data) { forget_data(); return; } if (one_past_end > full_data->size()) { one_past_end = full_data->size(); } if (one_past_end < first) { report_error("Last data point must come after first one."); } if (one_past_end == first) { // It would be nice to combine this with the first if // statement, but since one_past_end might change in the // second one, this check needs its own branch. forget_data(); return; } observed_data_ = full_data; first_data_point_ = first; one_past_end_ = one_past_end; }
LatentDataImputerWorker(Imputer *imputer, const SUFFICIENT_STATISTICS &suf) : imputer_(imputer), suf_(suf) { forget_data(); // If imputer also happens to be a PosteriorSampler, then use // the PosteriorSampler's methods for random number generation. PosteriorSampler *sampler = dynamic_cast<PosteriorSampler *>(imputer); if (sampler) { rng_ = &(sampler->rng()); } else { rng_storage_.reset(new RNG(seed_rng())); rng_ = rng_storage_.get(); } }