From 1af040b9d1610a889fe5e658049509115d3de646 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 20 Dec 2021 16:52:46 -0500 Subject: [PATCH 1/4] fix axpy warning --- gtsam/linear/Errors.cpp | 1 - gtsam/linear/Errors.h | 1 - 2 files changed, 2 deletions(-) diff --git a/gtsam/linear/Errors.cpp b/gtsam/linear/Errors.cpp index 4b30dcc08..41c6c3d09 100644 --- a/gtsam/linear/Errors.cpp +++ b/gtsam/linear/Errors.cpp @@ -110,7 +110,6 @@ double dot(const Errors& a, const Errors& b) { } /* ************************************************************************* */ -template<> void axpy(double alpha, const Errors& x, Errors& y) { Errors::const_iterator it = x.begin(); for(Vector& yi: y) diff --git a/gtsam/linear/Errors.h b/gtsam/linear/Errors.h index e8ba7344e..f6e147084 100644 --- a/gtsam/linear/Errors.h +++ b/gtsam/linear/Errors.h @@ -65,7 +65,6 @@ namespace gtsam { /** * BLAS level 2 style */ - template <> GTSAM_EXPORT void axpy(double alpha, const Errors& x, Errors& y); /** print with optional string */ From e8e4bea84c03f87c0c63c7d04e53f6bc329301ff Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 20 Dec 2021 17:57:24 -0500 Subject: [PATCH 2/4] add alignment macro and modernize typedefs --- gtsam/slam/TriangulationFactor.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gtsam/slam/TriangulationFactor.h b/gtsam/slam/TriangulationFactor.h index 0a15d6861..40e9538e2 100644 --- a/gtsam/slam/TriangulationFactor.h +++ b/gtsam/slam/TriangulationFactor.h @@ -33,18 +33,18 @@ class TriangulationFactor: public NoiseModelFactor1 { public: /// CAMERA type - typedef CAMERA Camera; + using Camera = CAMERA; protected: /// shorthand for base class type - typedef NoiseModelFactor1 Base; + using Base = NoiseModelFactor1; /// shorthand for this class - typedef TriangulationFactor This; + using This = TriangulationFactor; /// shorthand for measurement type, e.g. Point2 or StereoPoint2 - typedef typename CAMERA::Measurement Measurement; + using Measurement = typename CAMERA::Measurement; // Keep a copy of measurement and calibration for I/O const CAMERA camera_; ///< CAMERA in which this landmark was seen @@ -55,9 +55,10 @@ protected: const bool verboseCheirality_; ///< If true, prints text for Cheirality exceptions (default: false) public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW /// shorthand for a smart pointer to a factor - typedef boost::shared_ptr shared_ptr; + using shared_ptr = boost::shared_ptr; /// Default constructor TriangulationFactor() : From af598abc04fdd15d93ed59f5bc46024d920b3de7 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 20 Dec 2021 21:13:57 -0500 Subject: [PATCH 3/4] add class-level GTSAM_EXPORT --- gtsam/discrete/DecisionTree.h | 4 +++- gtsam/discrete/DiscreteKey.h | 16 ++++++++-------- gtsam/discrete/DiscreteMarginals.h | 2 +- gtsam/discrete/Potentials.h | 12 ++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gtsam/discrete/DecisionTree.h b/gtsam/discrete/DecisionTree.h index 0ee0b8be0..0491f3e4d 100644 --- a/gtsam/discrete/DecisionTree.h +++ b/gtsam/discrete/DecisionTree.h @@ -19,6 +19,8 @@ #pragma once +#include + #include #include @@ -35,7 +37,7 @@ namespace gtsam { * Y = function range (any algebra), e.g., bool, int, double */ template - class DecisionTree { + class GTSAM_EXPORT DecisionTree { public: diff --git a/gtsam/discrete/DiscreteKey.h b/gtsam/discrete/DiscreteKey.h index 3462166f4..86f1bcf63 100644 --- a/gtsam/discrete/DiscreteKey.h +++ b/gtsam/discrete/DiscreteKey.h @@ -34,32 +34,32 @@ namespace gtsam { using DiscreteKey = std::pair; /// DiscreteKeys is a set of keys that can be assembled using the & operator - struct DiscreteKeys: public std::vector { + struct GTSAM_EXPORT DiscreteKeys: public std::vector { // Forward all constructors. using std::vector::vector; /// Constructor for serialization - GTSAM_EXPORT DiscreteKeys() : std::vector::vector() {} + DiscreteKeys() : std::vector::vector() {} /// Construct from a key - GTSAM_EXPORT DiscreteKeys(const DiscreteKey& key) { + DiscreteKeys(const DiscreteKey& key) { push_back(key); } /// Construct from a vector of keys - GTSAM_EXPORT DiscreteKeys(const std::vector& keys) : + DiscreteKeys(const std::vector& keys) : std::vector(keys) { } /// Construct from cardinalities with default names - GTSAM_EXPORT DiscreteKeys(const std::vector& cs); + DiscreteKeys(const std::vector& cs); /// Return a vector of indices - GTSAM_EXPORT KeyVector indices() const; + KeyVector indices() const; /// Return a map from index to cardinality - GTSAM_EXPORT std::map cardinalities() const; + std::map cardinalities() const; /// Add a key (non-const!) DiscreteKeys& operator&(const DiscreteKey& key) { @@ -69,5 +69,5 @@ namespace gtsam { }; // DiscreteKeys /// Create a list from two keys - GTSAM_EXPORT DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2); + DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2); } diff --git a/gtsam/discrete/DiscreteMarginals.h b/gtsam/discrete/DiscreteMarginals.h index b118909bc..27352a211 100644 --- a/gtsam/discrete/DiscreteMarginals.h +++ b/gtsam/discrete/DiscreteMarginals.h @@ -29,7 +29,7 @@ namespace gtsam { /** * A class for computing marginals of variables in a DiscreteFactorGraph */ - class DiscreteMarginals { +class GTSAM_EXPORT DiscreteMarginals { protected: diff --git a/gtsam/discrete/Potentials.h b/gtsam/discrete/Potentials.h index 1078b4c61..856b92816 100644 --- a/gtsam/discrete/Potentials.h +++ b/gtsam/discrete/Potentials.h @@ -29,7 +29,7 @@ namespace gtsam { /** * A base class for both DiscreteFactor and DiscreteConditional */ - class Potentials: public AlgebraicDecisionTree { + class GTSAM_EXPORT Potentials: public AlgebraicDecisionTree { public: @@ -46,7 +46,7 @@ namespace gtsam { } // Safe division for probabilities - GTSAM_EXPORT static double safe_div(const double& a, const double& b); + static double safe_div(const double& a, const double& b); // // Apply either a permutation or a reduction // template @@ -55,10 +55,10 @@ namespace gtsam { public: /** Default constructor for I/O */ - GTSAM_EXPORT Potentials(); + Potentials(); /** Constructor from Indices and ADT */ - GTSAM_EXPORT Potentials(const DiscreteKeys& keys, const ADT& decisionTree); + Potentials(const DiscreteKeys& keys, const ADT& decisionTree); /** Constructor from Indices and (string or doubles) */ template @@ -67,8 +67,8 @@ namespace gtsam { } // Testable - GTSAM_EXPORT bool equals(const Potentials& other, double tol = 1e-9) const; - GTSAM_EXPORT void print(const std::string& s = "Potentials: ", + bool equals(const Potentials& other, double tol = 1e-9) const; + void print(const std::string& s = "Potentials: ", const KeyFormatter& formatter = DefaultKeyFormatter) const; size_t cardinality(Key j) const { return cardinalities_.at(j);} From 384494dd8bb69b67f9d8530f0b76f69c07d232fc Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 20 Dec 2021 21:14:11 -0500 Subject: [PATCH 4/4] remove unnecessary instantiations --- gtsam/discrete/Potentials.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gtsam/discrete/Potentials.cpp b/gtsam/discrete/Potentials.cpp index 331a76c13..fa491eba3 100644 --- a/gtsam/discrete/Potentials.cpp +++ b/gtsam/discrete/Potentials.cpp @@ -26,10 +26,6 @@ using namespace std; namespace gtsam { -// explicit instantiation -template class DecisionTree; -template class AlgebraicDecisionTree; - /* ************************************************************************* */ double Potentials::safe_div(const double& a, const double& b) { // cout << boost::format("%g / %g = %g\n") % a % b % ((a == 0) ? 0 : (a / b));