mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
big reorganisation of asserts, so that:
0) asserts are only done in the public API, except for a few ones explicitly named eigen_internal_assert. 1) internal asserts are disabled unless EIGEN_INTERNAL_DEBUGGING is defined. This limits the impact of debugging on performance. 2) no 'unused argument' warnings anymore when compiling with -DNDEBUG
This commit is contained in:
@@ -32,13 +32,52 @@
|
||||
EIGEN_USING_MATRIX_TYPEDEFS \
|
||||
using Eigen::Matrix;
|
||||
|
||||
#ifdef EIGEN_INTERNAL_DEBUGGING
|
||||
#define eigen_internal_assert(x) assert(x)
|
||||
#else
|
||||
#define eigen_internal_assert(x)
|
||||
#endif
|
||||
|
||||
#define EIGEN_UNUSED(x) (void)x
|
||||
#define EIGEN_CHECK_RANGES(matrix, row, col) \
|
||||
assert(row >= 0 && row < (matrix).rows() && col >= 0 && col < (matrix).cols())
|
||||
#define EIGEN_CHECK_ROW_RANGE(matrix, row) \
|
||||
assert(row >= 0 && row < (matrix).rows())
|
||||
#define EIGEN_CHECK_COL_RANGE(matrix, col) \
|
||||
assert(col >= 0 && col < (matrix).cols())
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED(x)
|
||||
#else
|
||||
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define EIGEN_ALWAYS_INLINE __attribute__((always_inline))
|
||||
# define EIGEN_RESTRICT /*__restrict__*/
|
||||
#else
|
||||
# define EIGEN_ALWAYS_INLINE
|
||||
# define EIGEN_RESTRICT
|
||||
#endif
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename OtherScalar, typename OtherDerived> \
|
||||
Derived& operator Op(const MatrixBase<OtherScalar, OtherDerived>& other) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(other); \
|
||||
} \
|
||||
Derived& operator Op(const Derived& other) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(other); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename Other> \
|
||||
Derived& operator Op(const Other& scalar) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(scalar); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
|
||||
|
||||
//forward declarations
|
||||
template<typename _Scalar, int _Rows, int _Cols> class Matrix;
|
||||
@@ -75,41 +114,4 @@ struct ForwardDecl<Matrix<_Scalar, _Rows, _Cols> >
|
||||
|
||||
const int Dynamic = -1;
|
||||
|
||||
#define EIGEN_LOOP_UNROLLING_LIMIT 25
|
||||
|
||||
#define EIGEN_UNUSED(x) (void)x
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define EIGEN_ALWAYS_INLINE __attribute__((always_inline))
|
||||
# define EIGEN_RESTRICT /*__restrict__*/
|
||||
#else
|
||||
# define EIGEN_ALWAYS_INLINE
|
||||
# define EIGEN_RESTRICT
|
||||
#endif
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename OtherScalar, typename OtherDerived> \
|
||||
Derived& operator Op(const MatrixBase<OtherScalar, OtherDerived>& other) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(other); \
|
||||
} \
|
||||
Derived& operator Op(const Derived& other) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(other); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename Other> \
|
||||
Derived& operator Op(const Other& scalar) \
|
||||
{ \
|
||||
return MatrixBase<Scalar, Derived>::operator Op(scalar); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
|
||||
|
||||
#endif // EIGEN_UTIL_H
|
||||
|
||||
Reference in New Issue
Block a user