make sigmas initialization cleaner

release/4.3a0
Varun Agrawal 2022-12-24 10:31:56 +05:30
parent 77b4028e47
commit da86e06efc
1 changed files with 3 additions and 13 deletions

View File

@ -300,21 +300,11 @@ double GaussianConditional::logDeterminant() const {
"conditionals");
}
// Noise model to sample from.
noiseModel::Diagonal::shared_ptr _model;
if (!model_) {
// Initialize model_ to Unit noiseModel if not initialized.
// Unit noise model specifies sigmas as 1, since
// the noise information should already be in information matrix A.
// Dim should be number of rows since
// noise model dimension should match (Ax - b)
_model = noiseModel::Unit::Create(rows());
} else {
_model = model_;
}
VectorValues solution = solve(parentsValues);
Key key = firstFrontalKey();
const Vector& sigmas = _model->sigmas();
// The vector of sigma values for sampling.
// If no model, initialize sigmas to 1, else to model sigmas
const Vector& sigmas = (!model_) ? Vector::Ones(rows()) : model_->sigmas();
solution[key] += Sampler::sampleDiagonal(sigmas, rng);
return solution;
}