diff --git a/cpp/ConditionalGaussian.h b/cpp/ConditionalGaussian.h index 83c68aea4..1fca89b5f 100644 --- a/cpp/ConditionalGaussian.h +++ b/cpp/ConditionalGaussian.h @@ -91,10 +91,10 @@ namespace gtsam { const Matrix& get_R() const {return R_;} /** STL like, return the iterator pointing to the first node */ - const_iterator const parentsBegin(){ return parents_.begin(); } + const_iterator const parentsBegin() const { return parents_.begin(); } /** STL like, return the iterator pointing to the last node */ - const_iterator const parentsEnd(){ return parents_.end(); } + const_iterator const parentsEnd() const { return parents_.end(); } /** find the number of parents */ size_t size() const {return parents_.size();} diff --git a/cpp/FGConfig.h b/cpp/FGConfig.h index 1701343f5..4e70209b2 100644 --- a/cpp/FGConfig.h +++ b/cpp/FGConfig.h @@ -33,7 +33,7 @@ namespace gtsam { virtual ~FGConfig() {}; /** return all the nodes in the graph **/ - std::vector get_names(){ + std::vector get_names() { std::vector names; for(iterator it=values.begin(); it!=values.end(); it++) names.push_back(it->first); diff --git a/cpp/FactorGraph.h b/cpp/FactorGraph.h index 48c6505d6..13016db9f 100644 --- a/cpp/FactorGraph.h +++ b/cpp/FactorGraph.h @@ -37,7 +37,7 @@ namespace gtsam { public: /** get the factors to a specific node */ - const std::list& get_factors_to_node(const std::string& key) { + const std::list& get_factors_to_node(const std::string& key) const { return node_to_factors_[key]; } diff --git a/cpp/LinearFactor.h b/cpp/LinearFactor.h index bdbd51fb7..47b8b0475 100644 --- a/cpp/LinearFactor.h +++ b/cpp/LinearFactor.h @@ -105,10 +105,10 @@ public: std::size_t size() const { return As.size();} /** STL like, return the iterator pointing to the first node */ - const_iterator const begin() { return As.begin();} + const_iterator const begin() const { return As.begin();} /** STL like, return the iterator pointing to the last node */ - const_iterator const end() { return As.end(); } + const_iterator const end() const { return As.end(); } /** check if empty */ bool empty() const { return b.size() == 0;} @@ -142,7 +142,7 @@ public: * return the number of rows from the b vector * @return a integer with the number of rows from the b vector */ - int numberOfRows() { return b.size();} + int numberOfRows() const { return b.size();} /** * Find all variables and their dimensions diff --git a/cpp/Matrix.cpp b/cpp/Matrix.cpp index b747e058f..03eff4272 100644 --- a/cpp/Matrix.cpp +++ b/cpp/Matrix.cpp @@ -86,7 +86,7 @@ Matrix diag(const Vector& v) { /* ************************************************************************* */ /** Check if two matrizes are the same */ /* ************************************************************************* */ -bool equal_with_abs_tol(const Matrix& A, const Matrix& B, double tol){ +bool equal_with_abs_tol(const Matrix& A, const Matrix& B, double tol) { size_t n1 = A.size2(), m1 = A.size1(); size_t n2 = B.size2(), m2 = B.size1(); diff --git a/cpp/Matrix.h b/cpp/Matrix.h index 801f3100a..2462f2360 100644 --- a/cpp/Matrix.h +++ b/cpp/Matrix.h @@ -76,7 +76,7 @@ bool assert_equal(const Matrix& A, const Matrix& B, double tol = 1e-9); /** * overload * for matrix-vector multiplication (as BOOST does not) */ -inline Vector operator*(const Matrix& A, const Vector & v) { +inline Vector operator*(const Matrix& A, const Vector & v) { if (A.size2()!=v.size()) throw(std::invalid_argument("Matrix operator* : A.n!=v.size")); return Vector(prod(A,v)); } diff --git a/cpp/NonlinearFactor.h b/cpp/NonlinearFactor.h index 7997b5bc9..7dbe52a23 100644 --- a/cpp/NonlinearFactor.h +++ b/cpp/NonlinearFactor.h @@ -111,7 +111,7 @@ namespace gtsam { /** Check if two factors are equal */ bool equals(const Factor& f, double tol=1e-9) const; - std::string dump() {return "";} + std::string dump() const {return "";} }; /* ************************************************************************* */ diff --git a/cpp/NonlinearFactorGraph.cpp b/cpp/NonlinearFactorGraph.cpp index c0db8471c..da065d3f8 100644 --- a/cpp/NonlinearFactorGraph.cpp +++ b/cpp/NonlinearFactorGraph.cpp @@ -118,7 +118,7 @@ bool NonlinearFactorGraph::check_convergence(const FGConfig& config1, const FGConfig& config2, double relativeErrorTreshold, double absoluteErrorTreshold, - int verbosity) + int verbosity) const { double currentError = calculate_error(*this, config1, verbosity); double newError = calculate_error(*this, config2, verbosity); @@ -211,7 +211,7 @@ pair NonlinearFactorGraph::OneIterationLM( FGConfig double absoluteErrorTreshold, int verbosity, double lambda0, - double lambdaFactor) { + double lambdaFactor) const { double lambda = lambda0; bool converged = false; diff --git a/cpp/NonlinearFactorGraph.h b/cpp/NonlinearFactorGraph.h index 996e698ce..90ead895c 100644 --- a/cpp/NonlinearFactorGraph.h +++ b/cpp/NonlinearFactorGraph.h @@ -71,7 +71,7 @@ public: // these you will probably want to use bool check_convergence(const FGConfig& config1, const FGConfig& config2, double relativeErrorTreshold, double absoluteErrorTreshold, - int verbosity = 0); + int verbosity = 0) const; /** * Optimize using Levenberg-Marquardt. Really Levenberg's @@ -105,7 +105,7 @@ public: // these you will probably want to use double absoluteErrorTreshold, int verbosity, double lambda0, - double lambdaFactor) ; + double lambdaFactor) const ; }; } diff --git a/cpp/Ordering.cpp b/cpp/Ordering.cpp index ade78a67b..fc587bc45 100644 --- a/cpp/Ordering.cpp +++ b/cpp/Ordering.cpp @@ -23,7 +23,7 @@ void Ordering::print() const { } /* ************************************************************************* */ -bool Ordering::equals(Ordering &ord){ +bool Ordering::equals(Ordering &ord){ if(this->size() != ord.size()) return false; diff --git a/cpp/Point2.h b/cpp/Point2.h index 93b25f73f..7ccb6c503 100644 --- a/cpp/Point2.h +++ b/cpp/Point2.h @@ -45,7 +45,7 @@ namespace gtsam { } /** operators */ - inline bool operator ==(const Point2& q) {return x_==q.x_ && q.y_==q.y_;} + inline bool operator ==(const Point2& q) const {return x_==q.x_ && q.y_==q.y_;} inline Point2 operator + (const Point2& q) const {return Point2(x_+q.x_,y_+q.y_);} inline Point2 operator - (const Point2& q) const {return Point2(x_-q.x_,y_-q.y_);} diff --git a/cpp/Point3.h b/cpp/Point3.h index bc25dcfc8..64293c301 100644 --- a/cpp/Point3.h +++ b/cpp/Point3.h @@ -67,7 +67,7 @@ namespace gtsam { bool equals(const Point3& p, double tol = 1e-9) const; /** friends */ - friend Point3 cross(const Point3 &p1, const Point3 &p2); + friend Point3 cross(const Point3 &p1, const Point3 &p2); private: /** Serialization function */