You can control some aspects of Eigen by defining the preprocessor tokens using #define
. These macros should be defined before any Eigen headers are included. Often they are best set in the project options.
This page lists the preprocesor tokens recognised by Eigen.
Table of contents
Macros with major effects
- EIGEN2_SUPPORT - if defined, enables the Eigen2 compatibility mode. This is meant to ease the transition of Eigen2 to Eigen3 (see Porting from Eigen2 to Eigen3). Not defined by default.
- EIGEN2_SUPPORT_STAGEnn_xxx (for various values of nn and xxx) - staged migration path from Eigen2 to Eigen3; see Eigen 2 support modes.
- EIGEN_DEFAULT_TO_ROW_MAJOR - when defined, the default storage order for matrices becomes row-major instead of column-major. Not defined by default.
- EIGEN_DEFAULT_DENSE_INDEX_TYPE - the type for column and row indices in matrices, vectors and array (DenseBase::Index). Set to
std::ptrdiff_t
by default.
- EIGEN_DEFAULT_IO_FORMAT - the IOFormat to use when printing a matrix if no IOFormat is specified. Defaults to the IOFormat constructed by the default constructor IOFormat().
- EIGEN_INITIALIZE_MATRICES_BY_ZERO - if defined, all entries of newly constructed matrices and arrays are initializes to zero, as are new entries in matrices and arrays after resizing. Not defined by default.
Assertions
The Eigen library contains many assertions to guard against programming errors, both at compile time and at run time. However, these assertions do cost time and can thus be turned off.
- EIGEN_NO_DEBUG - disables Eigen's assertions if defined. Not defined by default, unless the
NDEBUG
macro is defined (this is a standard C++ macro which disables all asserts).
- EIGEN_NO_STATIC_ASSERT - if defined, compile-time static assertions are replaced by runtime assertions; this saves compilation time. Not defined by default.
- EIGEN_INTERNAL_DEBUGGING - if defined, enables assertions in Eigen's internal routines. This is useful for debugging Eigen itself. Not defined by default.
Alignment, vectorization and performance tweaking
- EIGEN_DONT_ALIGN - disables alignment completely. Eigen will not try to align its objects and does not expect that any objects passed to it are aligned. This will turn off vectorization. Not defined by default.
- EIGEN_DONT_ALIGN_STATICALLY - disables alignment of arrays on the stack. Not defined by default, unless
EIGEN_DONT_ALIGN
is defined.
- EIGEN_DONT_VECTORIZE - disables explicit vectorization when defined. Not defined by default, unless alignment is disabled by Eigen's platform test or the user defining
EIGEN_DONT_ALIGN
.
- EIGEN_FAST_MATH - enables some optimizations which might affect the accuracy of the result. The only optimization this currently includes is single precision sin() and cos() in the present of SSE vectorization. Defined by default.
- EIGEN_UNROLLING_LIMIT - defines the size of a loop to enable meta unrolling. Set it to zero to disable unrolling. The size of a loop here is expressed in Eigen's own notion of "number of FLOPS", it does not correspond to the number of iterations or the number of instructions. The default is value 100.
Plugins
It is possible to add new methods to many fundamental classes in Eigen by writing a plugin. As explained in the section Extending MatrixBase (and other classes), the plugin is specified by defining a EIGEN_xxx_PLUGIN
macro. The following macros are supported; none of them are defined by default.
- EIGEN_ARRAY_PLUGIN - filename of plugin for extending the Array class.
- EIGEN_ARRAYBASE_PLUGIN - filename of plugin for extending the ArrayBase class.
- EIGEN_CWISE_PLUGIN - filename of plugin for extending the Cwise class.
- EIGEN_DENSEBASE_PLUGIN - filename of plugin for extending the DenseBase class.
- EIGEN_DYNAMICSPARSEMATRIX_PLUGIN - filename of plugin for extending the DynamicSparseMatrix class.
- EIGEN_MATRIX_PLUGIN - filename of plugin for extending the Matrix class.
- EIGEN_MATRIXBASE_PLUGIN - filename of plugin for extending the MatrixBase class.
- EIGEN_PLAINOBJECTBASE_PLUGIN - filename of plugin for extending the PlainObjectBase class.
- EIGEN_QUATERNIONBASE_PLUGIN - filename of plugin for extending the QuaternionBase class.
- EIGEN_SPARSEMATRIX_PLUGIN - filename of plugin for extending the SparseMatrix class.
- EIGEN_SPARSEMATRIXBASE_PLUGIN - filename of plugin for extending the SparseMatrixBase class.
- EIGEN_SPARSEVECTOR_PLUGIN - filename of plugin for extending the SparseVector class.
- EIGEN_TRANSFORM_PLUGIN - filename of plugin for extending the Transform class.
- EIGEN_FUNCTORS_PLUGIN - filename of plugin for adding new functors and specializations of functor_traits.