2010-12-27 23:07:07 +08:00
namespace Eigen {
/** \page TopicPreprocessorDirectives Preprocessor directives
2011-05-04 21:13:20 +08:00
You can control some aspects of %Eigen by defining the preprocessor tokens using \c \#define. These macros
should be defined before any %Eigen headers are included. Often they are best set in the project options.
2010-12-28 00:34:58 +08:00
2014-07-01 22:58:11 +08:00
This page lists the preprocessor tokens recognized by %Eigen.
2010-12-28 00:34:58 +08:00
Big changes in Eigen documentation:
- Organize the documentation into "chapters".
- Each chapter include many documentation pages, reference pages organized as modules, and a quick reference page.
- The "Chapters" tree is created using the defgroup/ingroup mechanism, even for the documentation pages (i.e., .dox files for which I added an \eigenManualPage macro that we can switch between \page or \defgroup ).
- Add a "General topics" entry for all pages that do not fit well in the previous "chapters".
- The highlevel struture is managed by a new eigendoxy_layout.xml file.
- remove the "index" and quite useless pages (namespace list, class hierarchy, member list, file list, etc.)
- add the javascript search-engine.
- add the "treeview" panel.
- remove \tableofcontents (replace them by a custom \eigenAutoToc macro to be able to easily re-enable if needed).
- add javascript to automatically generate a TOC from the h1/h2 tags of the current page, and put the TOC in the left side panel.
- overload various javascript function generated by doxygen to:
- remove the root of the treeview
- remove links to section/subsection from the treeview
- automatically expand the "Chapters" section
- automatically expand the current section
- adjust the height of the treeview to take into account the TOC
- always use the default .css file, eigendoxy.css now only includes our modifications
- use Doxyfile to specify our logo
- remove cross references to unsupported modules (temporarily)
2013-01-05 23:37:11 +08:00
\eigenAutoToc
2010-12-28 00:34:58 +08:00
\section TopicPreprocessorDirectivesMajor Macros with major effects
2012-05-14 04:42:45 +08:00
These macros have a major effect and typically break the API (Application Programming Interface) and/or the
ABI (Application Binary Interface). This can be rather dangerous: if parts of your program are compiled with
one option, and other parts (or libraries that you use) are compiled with another option, your program may
fail to link or exhibit subtle bugs. Nevertheless, these options can be useful for people who know what they
are doing.
2014-07-01 22:58:11 +08:00
- \b EIGEN2_SUPPORT and \b EIGEN2_SUPPORT_STAGEnn_xxx are disabled starting from the 3.3 release.
Defining one of these will raise a compile-error. If you need to compile Eigen2 code,
<a href="http://eigen.tuxfamily.org/index.php?title=Eigen2">check this site</a>.
2011-03-11 19:15:44 +08:00
- \b EIGEN_DEFAULT_DENSE_INDEX_TYPE - the type for column and row indices in matrices, vectors and array
(DenseBase::Index). Set to \c std::ptrdiff_t by default.
2012-12-24 20:33:22 +08:00
- \b 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::IOFormat().
2010-12-28 00:34:58 +08:00
- \b EIGEN_INITIALIZE_MATRICES_BY_ZERO - if defined, all entries of newly constructed matrices and arrays are
2013-02-08 01:07:07 +08:00
initialized to zero, as are new entries in matrices and arrays after resizing. Not defined by default.
2014-07-21 19:43:48 +08:00
\warning The unary (resp. binary) constructor of \c 1x1 (resp. \c 2x1 or \c 1x2) fixed size matrices is
always interpreted as an initialization constructor where the argument(s) are the coefficient values
and not the sizes. For instance, \code Vector2d v(2,1); \endcode will create a vector with coeficients [2,1],
and \b not a \c 2x1 vector initialized with zeros (i.e., [0,0]). If such cases might occur, then it is
recommended to use the default constructor with a explicit call to resize:
\code
Matrix<?,SizeAtCompileTime,1> v;
v.resize(size);
Matrix<?,RowsAtCompileTime,ColsAtCompileTime> m;
m.resize(rows,cols);
\endcode
2013-02-08 01:07:07 +08:00
- \b EIGEN_INITIALIZE_MATRICES_BY_NAN - if defined, all entries of newly constructed matrices and arrays are
initialized to NaN, as are new entries in matrices and arrays after resizing. This option is especially
2013-02-26 02:17:13 +08:00
useful for debugging purpose, though a memory tool like <a href="http://valgrind.org/">valgrind</a> is
2013-02-08 01:07:07 +08:00
preferable. Not defined by default.
2014-07-21 19:43:48 +08:00
\warning See the documentation of \c EIGEN_INITIALIZE_MATRICES_BY_ZERO for a discussion on a limitations
of these macros when applied to \c 1x1, \c 1x2, and \c 2x1 fixed-size matrices.
2011-12-08 22:22:06 +08:00
- \b EIGEN_NO_AUTOMATIC_RESIZING - if defined, the matrices (or arrays) on both sides of an assignment
<tt>a = b</tt> have to be of the same size; otherwise, %Eigen automatically resizes \c a so that it is of
the correct size. Not defined by default.
2010-12-28 00:34:58 +08:00
2016-05-20 21:26:09 +08:00
\section TopicPreprocessorDirectivesCppVersion C++ standard features
2018-03-11 22:01:44 +08:00
By default, %Eigen strive to automatically detect and enable language features at compile-time based on
2016-05-20 21:26:09 +08:00
the information provided by the compiler.
- \b EIGEN_MAX_CPP_VER - disables usage of C++ features requiring a version greater than EIGEN_MAX_CPP_VER.
Possible values are: 03, 11, 14, 17, etc. If not defined (the default), %Eigen enables all features supported
by the compiler.
Individual features can be explicitly enabled or disabled by defining the following token to 0 or 1 respectively.
For instance, one might limit the C++ version to C++03 by defining EIGEN_MAX_CPP_VER=03, but still enable C99 math
functions by defining EIGEN_HAS_C99_MATH=1.
- \b EIGEN_HAS_C99_MATH - controls the usage of C99 math functions such as erf, erfc, lgamma, etc.
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_CXX11_MATH - controls the implementation of some functions such as round, logp1, isinf, isnan, etc.
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_RVALUE_REFERENCES - defines whetehr rvalue references are supported
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_STD_RESULT_OF - defines whether std::result_of is supported
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_VARIADIC_TEMPLATES - defines whether variadic templates are supported
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_CONSTEXPR - defines whether relaxed const expression are supported
Automatic detection disabled if EIGEN_MAX_CPP_VER<14.
- \b EIGEN_HAS_CXX11_CONTAINERS - defines whether STL's containers follows C++11 specifications
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
- \b EIGEN_HAS_CXX11_NOEXCEPT - defines whether noexcept is supported
Automatic detection disabled if EIGEN_MAX_CPP_VER<11.
2010-12-28 00:34:58 +08:00
\section TopicPreprocessorDirectivesAssertions Assertions
2011-05-04 21:13:20 +08:00
The %Eigen library contains many assertions to guard against programming errors, both at compile time and at
2010-12-28 00:34:58 +08:00
run time. However, these assertions do cost time and can thus be turned off.
2011-05-04 21:13:20 +08:00
- \b EIGEN_NO_DEBUG - disables %Eigen's assertions if defined. Not defined by default, unless the
2010-12-28 00:34:58 +08:00
\c NDEBUG macro is defined (this is a standard C++ macro which disables all asserts).
- \b EIGEN_NO_STATIC_ASSERT - if defined, compile-time static assertions are replaced by runtime assertions;
this saves compilation time. Not defined by default.
2011-05-04 21:13:20 +08:00
- \b eigen_assert - macro with one argument that is used inside %Eigen for assertions. By default, it is
basically defined to be \c assert, which aborts the program if the assertion is violated. Redefine this
macro if you want to do something else, like throwing an exception.
2012-07-14 15:56:03 +08:00
- \b EIGEN_MPL2_ONLY - disable non MPL2 compatible features, or in other words disable the features which
are still under the LGPL.
2010-12-28 00:34:58 +08:00
\section TopicPreprocessorDirectivesPerformance Alignment, vectorization and performance tweaking
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_MALLOC_ALREADY_ALIGNED - Can be set to 0 or 1 to tell whether default system \c malloc already
2013-02-26 02:17:13 +08:00
returns aligned buffers. In not defined, then this information is automatically deduced from the compiler
and system preprocessor tokens.
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_MAX_ALIGN_BYTES - Must be a power of two, or 0. Defines an upper bound on the memory boundary in bytes on which dynamically and statically allocated data may be aligned by %Eigen. If not defined, a default value is automatically computed based on architecture, compiler, and OS.
This option is typically used to enforce binary compatibility between code/libraries compiled with different SIMD options. For instance, one may compile AVX code and enforce ABI compatibility with existing SSE code by defining \c EIGEN_MAX_ALIGN_BYTES=16. In the other way round, since by default AVX implies 32 bytes alignment for best performance, one can compile SSE code to be ABI compatible with AVX code by defining \c EIGEN_MAX_ALIGN_BYTES=32.
- \b \c EIGEN_MAX_STATIC_ALIGN_BYTES - Same as \c EIGEN_MAX_ALIGN_BYTES but for statically allocated data only. By default, if only \c EIGEN_MAX_ALIGN_BYTES is defined, then \c EIGEN_MAX_STATIC_ALIGN_BYTES == \c EIGEN_MAX_ALIGN_BYTES, otherwise a default value is automatically computed based on architecture, compiler, and OS (can be smaller than the default value of EIGEN_MAX_ALIGN_BYTES on architectures that do not support stack alignment).
Let us emphasize that \c EIGEN_MAX_*_ALIGN_BYTES define only a diserable upper bound. In practice data is aligned to largest power-of-two common divisor of \c EIGEN_MAX_STATIC_ALIGN_BYTES and the size of the data, such that memory is not wasted.
- \b \c EIGEN_DONT_PARALLELIZE - if defined, this disables multi-threading. This is only relevant if you enabled OpenMP.
2014-07-18 21:42:12 +08:00
See \ref TopicMultiThreading for details.
2010-12-28 00:34:58 +08:00
- \b EIGEN_DONT_VECTORIZE - disables explicit vectorization when defined. Not defined by default, unless
2011-05-04 21:13:20 +08:00
alignment is disabled by %Eigen's platform test or the user defining \c EIGEN_DONT_ALIGN.
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_UNALIGNED_VECTORIZE - disables/enables vectorization with unaligned stores. Default is 1 (enabled).
2016-05-25 04:14:34 +08:00
If set to 0 (disabled), then expression for which the destination cannot be aligned are not vectorized (e.g., unaligned
small fixed size vectors or matrices)
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_FAST_MATH - enables some optimizations which might affect the accuracy of the result. This currently
2013-08-19 22:02:27 +08:00
enables the SSE vectorization of sin() and cos(), and speedups sqrt() for single precision. Defined to 1 by default.
Define it to 0 to disable.
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_UNROLLING_LIMIT - defines the size of a loop to enable meta unrolling. Set it to zero to disable
2011-05-04 21:13:20 +08:00
unrolling. The size of a loop here is expressed in %Eigen's own notion of "number of FLOPS", it does not
2013-08-20 19:59:33 +08:00
correspond to the number of iterations or the number of instructions. The default is value 100.
2016-11-24 05:15:03 +08:00
- \b \c EIGEN_STACK_ALLOCATION_LIMIT - defines the maximum bytes for a buffer to be allocated on the stack. For internal
2013-08-20 19:59:33 +08:00
temporary buffers, dynamic memory allocation is employed as a fall back. For fixed-size matrices or arrays, exceeding
2013-08-21 20:29:00 +08:00
this threshold raises a compile time assertion. Use 0 to set no limit. Default is 128 KB.
2017-07-17 17:05:26 +08:00
- \b \c EIGEN_NO_CUDA - disables CUDA support when defined. Might be useful in .cu files for which Eigen is used on the host only,
and never called from device code.
2017-12-14 21:47:38 +08:00
- \b \c EIGEN_STRONG_INLINE - This macro is used to qualify critical functions and methods that we expect the compiler to inline.
By default it is defined to \c __forceinline for MSVC and ICC, and to \c inline for other compilers. A tipical usage is to
define it to \c inline for MSVC users wanting faster compilation times, at the risk of performance degradations in some rare
cases for which MSVC inliner fails to do a good job.
2010-12-28 00:34:58 +08:00
2016-11-24 05:15:03 +08:00
- \c EIGEN_DONT_ALIGN - Deprecated, it is a synonym for \c EIGEN_MAX_ALIGN_BYTES=0. It 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 if \b EIGEN_UNALIGNED_VECTORIZE=1. Not defined by default.
- \c EIGEN_DONT_ALIGN_STATICALLY - Deprecated, it is a synonym for \c EIGEN_MAX_STATIC_ALIGN_BYTES=0. It disables alignment of arrays on the stack. Not defined by default, unless \c EIGEN_DONT_ALIGN is defined.
2010-12-28 00:34:58 +08:00
\section TopicPreprocessorDirectivesPlugins Plugins
2011-05-04 21:13:20 +08:00
It is possible to add new methods to many fundamental classes in %Eigen by writing a plugin. As explained in
2017-01-05 06:27:33 +08:00
the section \ref TopicCustomizing_Plugins, the plugin is specified by defining a \c EIGEN_xxx_PLUGIN macro. The
2010-12-28 00:34:58 +08:00
following macros are supported; none of them are defined by default.
- \b EIGEN_ARRAY_PLUGIN - filename of plugin for extending the Array class.
2011-02-14 06:50:57 +08:00
- \b EIGEN_ARRAYBASE_PLUGIN - filename of plugin for extending the ArrayBase class.
2010-12-28 00:34:58 +08:00
- \b EIGEN_CWISE_PLUGIN - filename of plugin for extending the Cwise class.
- \b EIGEN_DENSEBASE_PLUGIN - filename of plugin for extending the DenseBase class.
2011-02-14 06:50:57 +08:00
- \b EIGEN_DYNAMICSPARSEMATRIX_PLUGIN - filename of plugin for extending the DynamicSparseMatrix class.
2010-12-28 00:34:58 +08:00
- \b EIGEN_MATRIX_PLUGIN - filename of plugin for extending the Matrix class.
2011-02-14 06:50:57 +08:00
- \b EIGEN_MATRIXBASE_PLUGIN - filename of plugin for extending the MatrixBase class.
2010-12-30 03:12:39 +08:00
- \b EIGEN_PLAINOBJECTBASE_PLUGIN - filename of plugin for extending the PlainObjectBase class.
2015-12-11 18:43:49 +08:00
- \b EIGEN_MAPBASE_PLUGIN - filename of plugin for extending the MapBase class.
2015-09-07 17:12:30 +08:00
- \b EIGEN_QUATERNION_PLUGIN - filename of plugin for extending the Quaternion class.
2010-12-28 00:34:58 +08:00
- \b EIGEN_QUATERNIONBASE_PLUGIN - filename of plugin for extending the QuaternionBase class.
2011-02-14 06:50:57 +08:00
- \b EIGEN_SPARSEMATRIX_PLUGIN - filename of plugin for extending the SparseMatrix class.
- \b EIGEN_SPARSEMATRIXBASE_PLUGIN - filename of plugin for extending the SparseMatrixBase class.
- \b EIGEN_SPARSEVECTOR_PLUGIN - filename of plugin for extending the SparseVector class.
2010-12-28 00:34:58 +08:00
- \b EIGEN_TRANSFORM_PLUGIN - filename of plugin for extending the Transform class.
- \b EIGEN_FUNCTORS_PLUGIN - filename of plugin for adding new functors and specializations of functor_traits.
2010-12-27 23:07:07 +08:00
2011-02-14 06:50:57 +08:00
2011-05-04 21:13:20 +08:00
\section TopicPreprocessorDirectivesDevelopers Macros for Eigen developers
2012-06-06 21:36:08 +08:00
These macros are mainly meant for people developing %Eigen and for testing purposes. Even though, they might be useful for power users and the curious for debugging and testing purpose, they \b should \b not \b be \b used by real-word code.
2011-05-04 21:13:20 +08:00
2012-05-14 04:42:45 +08:00
- \b EIGEN_DEFAULT_TO_ROW_MAJOR - when defined, the default storage order for matrices becomes row-major
instead of column-major. Not defined by default.
2011-05-04 21:13:20 +08:00
- \b EIGEN_INTERNAL_DEBUGGING - if defined, enables assertions in %Eigen's internal routines. This is useful
for debugging %Eigen itself. Not defined by default.
- \b EIGEN_NO_MALLOC - if defined, any request from inside the %Eigen to allocate memory from the heap
results in an assertion failure. This is useful to check that some routine does not allocate memory
dynamically. Not defined by default.
- \b EIGEN_RUNTIME_NO_MALLOC - if defined, a new switch is introduced which can be turned on and off by
calling <tt>set_is_malloc_allowed(bool)</tt>. If malloc is not allowed and %Eigen tries to allocate memory
dynamically anyway, an assertion failure results. Not defined by default.
2010-12-27 23:07:07 +08:00
*/
2011-02-14 06:50:57 +08:00
}