Merge pull request #228 from borglab/fix/override_warnings

Added override everywhere where it was needed
release/4.3a0
Frank Dellaert 2020-02-23 13:59:40 -05:00 committed by GitHub
commit 09b0f03542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 44 deletions

View File

@ -186,25 +186,28 @@ namespace gtsam {
virtual ~HessianFactor() {}
/** Clone this HessianFactor */
virtual GaussianFactor::shared_ptr clone() const {
GaussianFactor::shared_ptr clone() const override {
return boost::make_shared<HessianFactor>(*this); }
/** Print the factor for debugging and testing (implementing Testable) */
virtual void print(const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const;
void print(const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
/** Compare to another factor for testing (implementing Testable) */
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const;
bool equals(const GaussianFactor& lf, double tol = 1e-9) const override;
/** Evaluate the factor error f(x), see above. */
virtual double error(const VectorValues& c) const; /** 0.5*[x -1]'*H*[x -1] (also see constructor documentation) */
/**
* Evaluate the factor error f(x).
* returns 0.5*[x -1]'*H*[x -1] (also see constructor documentation)
*/
double error(const VectorValues& c) const override;
/** Return the dimension of the variable pointed to by the given key iterator
* todo: Remove this in favor of keeping track of dimensions with variables?
* @param variable An iterator pointing to the slot in this factor. You can
* use, for example, begin() + 2 to get the 3rd variable in this factor.
*/
virtual DenseIndex getDim(const_iterator variable) const {
DenseIndex getDim(const_iterator variable) const override {
return info_.getDim(std::distance(begin(), variable));
}
@ -216,10 +219,10 @@ namespace gtsam {
* stored stored in this factor.
* @return a HessianFactor with negated Hessian matrices
*/
virtual GaussianFactor::shared_ptr negate() const;
GaussianFactor::shared_ptr negate() const override;
/** Check if the factor is empty. TODO: How should this be defined? */
virtual bool empty() const { return size() == 0 /*|| rows() == 0*/; }
bool empty() const override { return size() == 0 /*|| rows() == 0*/; }
/** Return the constant term \f$ f \f$ as described above
* @return The constant term \f$ f \f$
@ -280,7 +283,7 @@ namespace gtsam {
* representation of the augmented information matrix, which stores only the
* upper triangle.
*/
virtual Matrix augmentedInformation() const;
Matrix augmentedInformation() const override;
/// Return self-adjoint view onto the information matrix (NOT augmented).
Eigen::SelfAdjointView<SymmetricBlockMatrix::constBlock, Eigen::Upper> informationView() const;
@ -288,33 +291,33 @@ namespace gtsam {
/** Return the non-augmented information matrix represented by this
* GaussianFactor.
*/
virtual Matrix information() const;
Matrix information() const override;
/// Return the diagonal of the Hessian for this factor
virtual VectorValues hessianDiagonal() const;
VectorValues hessianDiagonal() const override;
/// Raw memory access version of hessianDiagonal
virtual void hessianDiagonal(double* d) const;
void hessianDiagonal(double* d) const override;
/// Return the block diagonal of the Hessian for this factor
virtual std::map<Key,Matrix> hessianBlockDiagonal() const;
std::map<Key,Matrix> hessianBlockDiagonal() const override;
/// Return (dense) matrix associated with factor
virtual std::pair<Matrix, Vector> jacobian() const;
std::pair<Matrix, Vector> jacobian() const override;
/**
* Return (dense) matrix associated with factor
* The returned system is an augmented matrix: [A b]
* @param set weight to use whitening to bake in weights
*/
virtual Matrix augmentedJacobian() const;
Matrix augmentedJacobian() const override;
/** Update an information matrix by adding the information corresponding to this factor
* (used internally during elimination).
* @param keys THe ordered vector of keys for the information matrix to be updated
* @param info The information matrix to be updated
*/
void updateHessian(const KeyVector& keys, SymmetricBlockMatrix* info) const;
void updateHessian(const KeyVector& keys, SymmetricBlockMatrix* info) const override;
/** Update another Hessian factor
* @param other the HessianFactor to be updated
@ -325,19 +328,19 @@ namespace gtsam {
}
/** y += alpha * A'*A*x */
void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const;
void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const override;
/// eta for Hessian
VectorValues gradientAtZero() const;
VectorValues gradientAtZero() const override;
/// Raw memory access version of gradientAtZero
virtual void gradientAtZero(double* d) const;
void gradientAtZero(double* d) const override;
/**
* Compute the gradient at a key:
* \grad f(x_i) = \sum_j G_ij*x_j - g_i
*/
Vector gradient(Key key, const VectorValues& x) const;
Vector gradient(Key key, const VectorValues& x) const override;
/**
* In-place elimination that returns a conditional on (ordered) keys specified, and leaves

View File

@ -186,19 +186,19 @@ namespace gtsam {
virtual ~JacobianFactor() {}
/** Clone this JacobianFactor */
virtual GaussianFactor::shared_ptr clone() const {
GaussianFactor::shared_ptr clone() const override {
return boost::static_pointer_cast<GaussianFactor>(
boost::make_shared<JacobianFactor>(*this));
}
// Implementing Testable interface
virtual void print(const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const;
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const;
void print(const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
bool equals(const GaussianFactor& lf, double tol = 1e-9) const override;
Vector unweighted_error(const VectorValues& c) const; /** (A*x-b) */
Vector error_vector(const VectorValues& c) const; /** (A*x-b)/sigma */
virtual double error(const VectorValues& c) const; /** 0.5*(A*x-b)'*D*(A*x-b) */
double error(const VectorValues& c) const override; /** 0.5*(A*x-b)'*D*(A*x-b) */
/** Return the augmented information matrix represented by this GaussianFactor.
* The augmented information matrix contains the information matrix with an
@ -208,26 +208,26 @@ namespace gtsam {
* augmented information matrix is described in more detail in HessianFactor,
* which in fact stores an augmented information matrix.
*/
virtual Matrix augmentedInformation() const;
Matrix augmentedInformation() const override;
/** Return the non-augmented information matrix represented by this
* GaussianFactor.
*/
virtual Matrix information() const;
Matrix information() const override;
/// Return the diagonal of the Hessian for this factor
virtual VectorValues hessianDiagonal() const;
VectorValues hessianDiagonal() const override;
/// Raw memory access version of hessianDiagonal
virtual void hessianDiagonal(double* d) const;
void hessianDiagonal(double* d) const override;
/// Return the block diagonal of the Hessian for this factor
virtual std::map<Key,Matrix> hessianBlockDiagonal() const;
std::map<Key,Matrix> hessianBlockDiagonal() const override;
/**
* @brief Returns (dense) A,b pair associated with factor, bakes in the weights
*/
virtual std::pair<Matrix, Vector> jacobian() const;
std::pair<Matrix, Vector> jacobian() const override;
/**
* @brief Returns (dense) A,b pair associated with factor, does not bake in weights
@ -237,7 +237,7 @@ namespace gtsam {
/** Return (dense) matrix associated with factor. The returned system is an augmented matrix:
* [A b]
* weights are baked in */
virtual Matrix augmentedJacobian() const;
Matrix augmentedJacobian() const override;
/** Return (dense) matrix associated with factor. The returned system is an augmented matrix:
* [A b]
@ -255,10 +255,10 @@ namespace gtsam {
* stored stored in this factor.
* @return a HessianFactor with negated Hessian matrices
*/
virtual GaussianFactor::shared_ptr negate() const;
GaussianFactor::shared_ptr negate() const override;
/** Check if the factor is empty. TODO: How should this be defined? */
virtual bool empty() const { return size() == 0 /*|| rows() == 0*/; }
bool empty() const override { return size() == 0 /*|| rows() == 0*/; }
/** is noise model constrained ? */
bool isConstrained() const {
@ -268,7 +268,9 @@ namespace gtsam {
/** Return the dimension of the variable pointed to by the given key iterator
* todo: Remove this in favor of keeping track of dimensions with variables?
*/
virtual DenseIndex getDim(const_iterator variable) const { return Ab_(variable - begin()).cols(); }
DenseIndex getDim(const_iterator variable) const override {
return Ab_(variable - begin()).cols();
}
/**
* return the number of rows in the corresponding linear system
@ -309,17 +311,19 @@ namespace gtsam {
* @param scatter A mapping from variable index to slot index in this HessianFactor
* @param info The information matrix to be updated
*/
void updateHessian(const KeyVector& keys, SymmetricBlockMatrix* info) const;
void updateHessian(const KeyVector& keys, SymmetricBlockMatrix* info) const override;
/** Return A*x */
Vector operator*(const VectorValues& x) const;
/** x += A'*e. If x is initially missing any values, they are created and assumed to start as
* zero vectors. */
void transposeMultiplyAdd(double alpha, const Vector& e, VectorValues& x) const;
/** x += alpha * A'*e. If x is initially missing any values, they are
* created and assumed to start as zero vectors. */
void transposeMultiplyAdd(double alpha, const Vector& e,
VectorValues& x) const;
/** y += alpha * A'*A*x */
void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const;
void multiplyHessianAdd(double alpha, const VectorValues& x,
VectorValues& y) const override;
/**
* Raw memory access version of multiplyHessianAdd y += alpha * A'*A*x
@ -333,13 +337,13 @@ namespace gtsam {
const std::vector<size_t>& accumulatedDims) const;
/// A'*b for Jacobian
VectorValues gradientAtZero() const;
VectorValues gradientAtZero() const override;
/// A'*b for Jacobian (raw memory version)
virtual void gradientAtZero(double* d) const;
void gradientAtZero(double* d) const override;
/// Compute the gradient wrt a key at any values
Vector gradient(Key key, const VectorValues& x) const;
Vector gradient(Key key, const VectorValues& x) const override;
/** Return a whitened version of the factor, i.e. with unit diagonal noise model. */
JacobianFactor whiten() const;