diff --git a/cmake/HandleEigen.cmake b/cmake/HandleEigen.cmake index b3b4f66b6..651cd1009 100644 --- a/cmake/HandleEigen.cmake +++ b/cmake/HandleEigen.cmake @@ -59,7 +59,12 @@ else() endif() # Detect Eigen version: -set(EIGEN_VER_H "${GTSAM_EIGEN_INCLUDE_FOR_BUILD}/Eigen/src/Core/util/Macros.h") +# Since Eigen 5.0.0 the version macros moved from Eigen/src/Core/util/Macros.h +# to a dedicated Eigen/Version header, so check the new location first. +set(EIGEN_VER_H "${GTSAM_EIGEN_INCLUDE_FOR_BUILD}/Eigen/Version") +if (NOT EXISTS ${EIGEN_VER_H}) + set(EIGEN_VER_H "${GTSAM_EIGEN_INCLUDE_FOR_BUILD}/Eigen/src/Core/util/Macros.h") +endif() if (EXISTS ${EIGEN_VER_H}) file(READ "${EIGEN_VER_H}" STR_EIGEN_VERSION) diff --git a/gtsam/base/Matrix.h b/gtsam/base/Matrix.h index cfedf6d8c..9c9771407 100644 --- a/gtsam/base/Matrix.h +++ b/gtsam/base/Matrix.h @@ -54,7 +54,7 @@ using Matrix7##N = Eigen::Matrix; \ using Matrix8##N = Eigen::Matrix; \ using Matrix9##N = Eigen::Matrix; \ static const Eigen::MatrixBase::IdentityReturnType I_##N##x##N = Matrix##N::Identity(); \ -static const Eigen::MatrixBase::ConstantReturnType Z_##N##x##N = Matrix##N::Zero(); +static const decltype(Matrix##N::Zero()) Z_##N##x##N = Matrix##N::Zero(); GTSAM_MAKE_MATRIX_DEFS(1) GTSAM_MAKE_MATRIX_DEFS(2) diff --git a/gtsam/base/Vector.h b/gtsam/base/Vector.h index f7923ff88..5410393f6 100644 --- a/gtsam/base/Vector.h +++ b/gtsam/base/Vector.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -42,14 +43,14 @@ typedef Eigen::Matrix Vector1; typedef Eigen::Vector2d Vector2; typedef Eigen::Vector3d Vector3; -static const Eigen::MatrixBase::ConstantReturnType Z_2x1 = Vector2::Zero(); -static const Eigen::MatrixBase::ConstantReturnType Z_3x1 = Vector3::Zero(); +static const decltype(Vector2::Zero()) Z_2x1 = Vector2::Zero(); +static const decltype(Vector3::Zero()) Z_3x1 = Vector3::Zero(); // Create handy typedefs and constants for vectors with N>3 // VectorN and Z_Nx1, for N=1..9 #define GTSAM_MAKE_VECTOR_DEFS(N) \ using Vector##N = Eigen::Matrix; \ - static const Eigen::MatrixBase::ConstantReturnType Z_##N##x1 = Vector##N::Zero(); + static const decltype(Vector##N::Zero()) Z_##N##x1 = Vector##N::Zero(); GTSAM_MAKE_VECTOR_DEFS(4) GTSAM_MAKE_VECTOR_DEFS(5) diff --git a/gtsam/linear/iterative.h b/gtsam/linear/iterative.h index 22f65b8de..20a0c936e 100644 --- a/gtsam/linear/iterative.h +++ b/gtsam/linear/iterative.h @@ -61,7 +61,7 @@ namespace gtsam { /** Apply operator A'*e */ Vector operator^(const Vector& e) const { - return A_ ^ e; + return gtsam::operator^(A_, e); } /** @@ -71,7 +71,7 @@ namespace gtsam { /** gradient of objective function 0.5*|Ax-b_|^2 at x = A_'*(Ax-b_) */ Vector gradient(const Vector& x) const { - return A() ^ (A() * x - b()); + return gtsam::operator^(A(), Vector(A() * x - b())); } /** Apply operator A */