From 9243655e3b612a94892c44c7a8193d53de74e689 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 14:13:14 -0400 Subject: [PATCH] simplify --- gtsam/linear/NoiseModel.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gtsam/linear/NoiseModel.cpp b/gtsam/linear/NoiseModel.cpp index 18a29f5b33..7ee2158bee 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())); } /* ************************************************************************* */