diff --git a/gtsam/linear/NoiseModel.cpp b/gtsam/linear/NoiseModel.cpp index 18a29f5b3..7ee2158be 100644 --- a/gtsam/linear/NoiseModel.cpp +++ b/gtsam/linear/NoiseModel.cpp @@ -282,15 +282,10 @@ Diagonal::Diagonal(const Vector& sigmas) /* ************************************************************************* */ Diagonal::shared_ptr Diagonal::Variances(const Vector& variances, bool smart) { - if (smart) { - // check whether all the same entry - if ((variances.array() == variances(0)).all()) { - return Isotropic::Variance(variances.size(), variances(0), true); - } else - goto full; - } -full: - return shared_ptr(new Diagonal(variances.cwiseSqrt())); + // check whether all the same entry + return (smart && (variances.array() == variances(0)).all()) + ? Isotropic::Variance(variances.size(), variances(0), true) + : shared_ptr(new Diagonal(variances.cwiseSqrt())); } /* ************************************************************************* */