From 02c8f02a104a57f59c5793bb5c78f1470da249c2 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Tue, 28 Jan 2025 18:19:35 -0500 Subject: [PATCH] 5% speedup by using faster setAllZero --- gtsam/base/SymmetricBlockMatrix.h | 7 ++++++- gtsam/linear/HessianFactor.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gtsam/base/SymmetricBlockMatrix.h b/gtsam/base/SymmetricBlockMatrix.h index 378e91144..f6d4fa9c2 100644 --- a/gtsam/base/SymmetricBlockMatrix.h +++ b/gtsam/base/SymmetricBlockMatrix.h @@ -256,11 +256,16 @@ namespace gtsam { full().triangularView() = xpr.template triangularView(); } - /// Set the entire active matrix zero. + /// Set the entire *active* matrix zero. void setZero() { full().triangularView().setZero(); } + /// Set entire matrix zero. + void setAllZero() { + matrix_.setZero(); + } + /// Negate the entire active matrix. void negate(); diff --git a/gtsam/linear/HessianFactor.cpp b/gtsam/linear/HessianFactor.cpp index 701e79f41..f2130f068 100644 --- a/gtsam/linear/HessianFactor.cpp +++ b/gtsam/linear/HessianFactor.cpp @@ -245,7 +245,7 @@ HessianFactor::HessianFactor(const GaussianFactorGraph& factors, // Form A' * A gttic(update); - info_.setZero(); + info_.setAllZero(); for(const auto& factor: factors) if (factor) factor->updateHessian(keys_, &info_);