Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GTSAM-Concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In GTSAM, all properties and operations needed to use a type must be defined thr
In detail, we ask that the following items are defined in the traits object (although, not all are needed for optimization):

* values:
* `enum { dimension = D};`, an enum that indicates the dimensionality *n* of the manifold. In Eigen-fashion, we also support manifolds whose dimensionality is only defined at runtime, by specifying the value -1.
* `inline constexpr static auto dimension = D;`, a constexpr that indicates the dimensionality *n* of the manifold. In Eigen-fashion, we also support manifolds whose dimensionality is only defined at runtime, by specifying the value -1.
* types:
* `TangentVector`, type that lives in tangent space. This will almost always be an `Eigen::Matrix<double,n,1>`.
* `ChartJacobian`, a typedef for `OptionalJacobian<dimension, dimension>`.
Expand Down
3 changes: 1 addition & 2 deletions gtsam/base/GenericValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,8 @@ class GenericValue: public Value {
}
#endif


// Alignment, see https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html
enum { NeedsToAlign = (sizeof(T) % 16) == 0 };
constexpr static const bool NeedsToAlign = (sizeof(T) % 16) == 0;
public:
GTSAM_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
};
Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/Lie.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace gtsam {
template <class Class, int N>
struct LieGroup {

enum { dimension = N };
inline constexpr static auto dimension = N;
typedef OptionalJacobian<N, N> ChartJacobian;
typedef Eigen::Matrix<double, N, N> Jacobian;
typedef Eigen::Matrix<double, N, 1> TangentVector;
Expand Down Expand Up @@ -183,7 +183,7 @@ struct LieGroupTraits: GetDimensionImpl<Class, Class::dimension> {
/// @name Manifold
/// @{
typedef Class ManifoldType;
enum { dimension = Class::dimension };
inline constexpr static auto dimension = Class::dimension;
typedef Eigen::Matrix<double, dimension, 1> TangentVector;
typedef OptionalJacobian<dimension, dimension> ChartJacobian;

Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/Manifold.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace internal {
template<class Class>
struct HasManifoldPrereqs {

enum { dim = Class::dimension };
inline constexpr static auto dim = Class::dimension;

Class p, q;
Eigen::Matrix<double, dim, 1> v;
Expand Down Expand Up @@ -95,7 +95,7 @@ struct ManifoldTraits: GetDimensionImpl<Class, Class::dimension> {
GTSAM_CONCEPT_ASSERT(HasManifoldPrereqs<Class>);

// Dimension of the manifold
enum { dimension = Class::dimension };
inline constexpr static auto dimension = Class::dimension;

// Typedefs required by all manifold types.
typedef Class ManifoldType;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/base/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ struct MultiplyWithInverse {
*/
template <typename T, int N>
struct MultiplyWithInverseFunction {
enum { M = traits<T>::dimension };
inline constexpr static auto M = traits<T>::dimension;
typedef Eigen::Matrix<double, N, 1> VectorN;
typedef Eigen::Matrix<double, N, N> MatrixN;

Expand Down
10 changes: 5 additions & 5 deletions gtsam/base/ProductLieGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ProductLieGroup: public std::pair<G, H> {
typedef std::pair<G, H> Base;

protected:
enum {dimension1 = traits<G>::dimension};
enum {dimension2 = traits<H>::dimension};
constexpr static const size_t dimension1 = traits<G>::dimension;
constexpr static const size_t dimension2 = traits<H>::dimension;

public:
/// Default constructor yields identity
Expand Down Expand Up @@ -67,9 +67,9 @@ class ProductLieGroup: public std::pair<G, H> {

/// @name Manifold
/// @{
enum {dimension = dimension1 + dimension2};
inline static size_t Dim() {return dimension;}
inline size_t dim() const {return dimension;}
inline constexpr static auto dimension = dimension1 + dimension2;
inline static size_t Dim() { return dimension; }
inline size_t dim() const { return dimension; }

typedef Eigen::Matrix<double, dimension, 1> TangentVector;
typedef OptionalJacobian<dimension, dimension> ChartJacobian;
Expand Down
10 changes: 5 additions & 5 deletions gtsam/base/VectorSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct VectorSpaceImpl<Class,Eigen::Dynamic> {
template<class Class>
struct HasVectorSpacePrereqs {

enum { dim = Class::dimension };
inline constexpr static auto dim = Class::dimension;

Class p, q;
Vector v;
Expand Down Expand Up @@ -197,7 +197,7 @@ GTSAM_CONCEPT_ASSERT(HasVectorSpacePrereqs<Class>);

/// @name Manifold
/// @{
enum { dimension = Class::dimension};
inline constexpr static auto dimension = Class::dimension;
typedef Class ManifoldType;
/// @}
};
Expand Down Expand Up @@ -232,7 +232,7 @@ struct ScalarTraits : VectorSpaceImpl<Scalar, 1> {
/// @name Manifold
/// @{
typedef Scalar ManifoldType;
enum { dimension = 1 };
inline constexpr static auto dimension = 1;
typedef Eigen::Matrix<double, 1, 1> TangentVector;
typedef OptionalJacobian<1, 1> ChartJacobian;

Expand Down Expand Up @@ -305,7 +305,7 @@ struct traits<Eigen::Matrix<double, M, N, Options, MaxRows, MaxCols> > :

/// @name Manifold
/// @{
enum { dimension = M*N};
inline constexpr static auto dimension = M * N;
typedef Fixed ManifoldType;
typedef Eigen::Matrix<double, dimension, 1> TangentVector;
typedef Eigen::Matrix<double, dimension, dimension> Jacobian;
Expand Down Expand Up @@ -377,7 +377,7 @@ struct DynamicTraits {

/// @name Manifold
/// @{
enum { dimension = Eigen::Dynamic };
inline constexpr static auto dimension = Eigen::Dynamic;
typedef Eigen::VectorXd TangentVector;
typedef Eigen::MatrixXd Jacobian;
typedef OptionalJacobian<dimension, dimension> ChartJacobian;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/basis/Basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class Basis {
*/
template <class T>
class ManifoldEvaluationFunctor : public VectorEvaluationFunctor {
enum { M = traits<T>::dimension };
inline constexpr static auto M = traits<T>::dimension;
using Base = VectorEvaluationFunctor;

public:
Expand Down
10 changes: 4 additions & 6 deletions gtsam/geometry/BearingRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ struct BearingRange {
R range_;

public:
enum { dimB = traits<B>::dimension };
enum { dimR = traits<R>::dimension };
enum { dimension = dimB + dimR };
constexpr static const size_t dimB = traits<B>::dimension;
constexpr static const size_t dimR = traits<R>::dimension;
constexpr static const size_t dimension = dimB + dimR;

/// @name Standard Constructors
/// @{
Expand Down Expand Up @@ -162,9 +162,7 @@ struct BearingRange {
/// @}

// Alignment, see https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html
enum {
NeedsToAlign = (sizeof(B) % 16) == 0 || (sizeof(R) % 16) == 0
};
inline constexpr static auto NeedsToAlign = (sizeof(B) % 16) == 0 || (sizeof(R) % 16) == 0;
public:
GTSAM_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
};
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GTSAM_EXPORT Cal3 {
double u0_ = 0.0f, v0_ = 0.0f; ///< principal point

public:
enum { dimension = 5 };
inline constexpr static auto dimension = 5;
///< shared pointer to calibration object
using shared_ptr = std::shared_ptr<Cal3>;

Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3Bundler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GTSAM_EXPORT Cal3Bundler : public Cal3f {
// Note: u0 and v0 are constants and not optimized.

public:
enum { dimension = 3 };
inline constexpr static auto dimension = 3;
using shared_ptr = std::shared_ptr<Cal3Bundler>;

/// @name Constructors
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3DS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GTSAM_EXPORT Cal3DS2 : public Cal3DS2_Base {
using Base = Cal3DS2_Base;

public:
enum { dimension = 9 };
inline constexpr static auto dimension = 9;

///< shared pointer to stereo calibration object
using shared_ptr = std::shared_ptr<Cal3DS2>;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3DS2_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GTSAM_EXPORT Cal3DS2_Base : public Cal3 {
double tol_ = 1e-5; ///< tolerance value when calibrating

public:
enum { dimension = 9 };
inline constexpr static auto dimension = 9;

///< shared pointer to stereo calibration object
using shared_ptr = std::shared_ptr<Cal3DS2_Base>;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3Fisheye.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GTSAM_EXPORT Cal3Fisheye : public Cal3 {
double tol_ = 1e-5; ///< tolerance value when calibrating

public:
enum { dimension = 9 };
inline constexpr static auto dimension = 9;
///< shared pointer to fisheye calibration object
using shared_ptr = std::shared_ptr<Cal3Fisheye>;

Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3Unified.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GTSAM_EXPORT Cal3Unified : public Cal3DS2_Base {
double xi_ = 0.0f; ///< mirror parameter

public:
enum { dimension = 10 };
inline constexpr static auto dimension = 10;

///< shared pointer to stereo calibration object
using shared_ptr = std::shared_ptr<Cal3Unified>;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3_S2.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace gtsam {
*/
class GTSAM_EXPORT Cal3_S2 : public Cal3 {
public:
enum { dimension = 5 };
inline constexpr static auto dimension = 5;

///< shared pointer to calibration object
using shared_ptr = std::shared_ptr<Cal3_S2>;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3_S2Stereo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GTSAM_EXPORT Cal3_S2Stereo : public Cal3_S2 {
double b_ = 1.0f; ///< Stereo baseline.

public:
enum { dimension = 6 };
inline constexpr static auto dimension = 6;

///< shared pointer to stereo calibration object
using shared_ptr = std::shared_ptr<Cal3_S2Stereo>;
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Cal3f.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace gtsam {
*/
class GTSAM_EXPORT Cal3f : public Cal3 {
public:
enum { dimension = 1 };
inline constexpr static auto dimension = 1;
using shared_ptr = std::shared_ptr<Cal3f>;

/// @name Constructors
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/CalibratedCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ class GTSAM_EXPORT CalibratedCamera: public PinholeBase {

public:

enum {
dimension = 6
};
inline constexpr static auto dimension = 6;

/// @name Standard Constructors
/// @{
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/EssentialMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EssentialMatrix {

/// @name Manifold
/// @{
enum { dimension = 5 };
inline constexpr static auto dimension = 5;
inline static size_t Dim() { return dimension;}
inline size_t dim() const { return dimension;}

Expand Down
4 changes: 2 additions & 2 deletions gtsam/geometry/FundamentalMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GTSAM_EXPORT FundamentalMatrix {

/// @name Manifold
/// @{
enum { dimension = 7 }; // 3 for U, 1 for s, 3 for V
inline constexpr static auto dimension = 7; // 3 for U, 1 for s, 3 for V
inline static size_t Dim() { return dimension; }
inline size_t dim() const { return dimension; }

Expand Down Expand Up @@ -179,7 +179,7 @@ class GTSAM_EXPORT SimpleFundamentalMatrix {

/// @name Manifold
/// @{
enum { dimension = 7 }; // 5 for E, 1 for fa, 1 for fb
inline constexpr static auto dimension = 7; // 5 for E, 1 for fa, 1 for fb
inline static size_t Dim() { return dimension; }
inline size_t dim() const { return dimension; }

Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/Line3.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GTSAM_EXPORT Line3 {
double a_, b_; // Intersection of line with the world x-y plane rotated by R_
// Also the closest point on line to origin
public:
enum { dimension = 4 };
inline constexpr static auto dimension = 4;

/** Default constructor is the Z axis **/
Line3() :
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/OrientedPlane3.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class GTSAM_EXPORT OrientedPlane3 {
double d_; ///< The perpendicular distance to this plane

public:
enum {
dimension = 3
};
inline constexpr static auto dimension = 3;

/// @name Constructors
/// @{
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/PinholeCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class PinholeCamera: public PinholeBaseK<Calibration> {

public:

enum {
dimension = 6 + DimK
}; ///< Dimension depends on calibration
inline constexpr static auto dimension = 6 + DimK; ///< Dimension depends on calibration

/// @name Standard Constructors
/// @{
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/PinholePose.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ class PinholePose: public PinholeBaseK<CALIBRATION> {

public:

enum {
dimension = 6
}; ///< There are 6 DOF to optimize for
inline constexpr static auto dimension = 6; ///< There are 6 DOF to optimize for

/// @name Standard Constructors
/// @{
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ struct traits<QUATERNION_TYPE> {
/// @}
/// @name Basic manifold traits
/// @{
enum {
dimension = 3
};
inline constexpr static auto dimension = 3;
typedef OptionalJacobian<3, 3> ChartJacobian;
typedef Eigen::Matrix<_Scalar, 3, 1, _Options, 3, 1> TangentVector;

Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/SOn.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ constexpr int NSquaredSO(int N) { return (N < 0) ? Eigen::Dynamic : N * N; }
template <int N>
class SO : public LieGroup<SO<N>, internal::DimensionSO(N)> {
public:
enum { dimension = internal::DimensionSO(N) };
inline constexpr static auto dimension = internal::DimensionSO(N);
using MatrixNN = Eigen::Matrix<double, N, N>;
using VectorN2 = Eigen::Matrix<double, internal::NSquaredSO(N), 1>;
using MatrixDD = Eigen::Matrix<double, dimension, dimension>;
Expand Down
4 changes: 2 additions & 2 deletions gtsam/geometry/SphericalCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace gtsam {
*/
class GTSAM_EXPORT EmptyCal {
public:
enum { dimension = 0 };
inline constexpr static auto dimension = 0;
EmptyCal() {}
virtual ~EmptyCal() = default;
using shared_ptr = std::shared_ptr<EmptyCal>;
Expand Down Expand Up @@ -73,7 +73,7 @@ class GTSAM_EXPORT EmptyCal {
*/
class GTSAM_EXPORT SphericalCamera {
public:
enum { dimension = 6 };
inline constexpr static auto dimension = 6;

using Measurement = Unit3;
using MeasurementVector = std::vector<Unit3>;
Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/StereoCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class GTSAM_EXPORT StereoCamera {

public:

enum {
dimension = 6
};
inline constexpr static auto dimension = 6;

/// @name Standard Constructors
/// @{
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/StereoPoint2.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GTSAM_EXPORT StereoPoint2 {
double uL_, uR_, v_;

public:
enum { dimension = 3 };
inline constexpr static auto dimension = 3;
/// @name Standard Constructors
/// @{

Expand Down
4 changes: 1 addition & 3 deletions gtsam/geometry/Unit3.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class GTSAM_EXPORT Unit3 {

public:

enum {
dimension = 2
};
inline constexpr static auto dimension = 2;

/// @name Constructors
/// @{
Expand Down
Loading
Loading