Home | History | Annotate | Download | only in doc
      1 namespace Eigen {
      2 
      3 /** \page TopicPreprocessorDirectives Preprocessor directives
      4 
      5 You can control some aspects of %Eigen by defining the preprocessor tokens using \c \#define. These macros
      6 should be defined before any %Eigen headers are included. Often they are best set in the project options.
      7 
      8 This page lists the preprocesor tokens recognised by %Eigen.
      9 
     10 <b>Table of contents</b>
     11   - \ref TopicPreprocessorDirectivesMajor
     12   - \ref TopicPreprocessorDirectivesAssertions
     13   - \ref TopicPreprocessorDirectivesPerformance
     14   - \ref TopicPreprocessorDirectivesPlugins
     15   - \ref TopicPreprocessorDirectivesDevelopers
     16 
     17 
     18 \section TopicPreprocessorDirectivesMajor Macros with major effects
     19 
     20 These macros have a major effect and typically break the API (Application Programming Interface) and/or the
     21 ABI (Application Binary Interface). This can be rather dangerous: if parts of your program are compiled with
     22 one option, and other parts (or libraries that you use) are compiled with another option, your program may
     23 fail to link or exhibit subtle bugs. Nevertheless, these options can be useful for people who know what they
     24 are doing.
     25 
     26  - \b EIGEN2_SUPPORT - if defined, enables the Eigen2 compatibility mode. This is meant to ease the transition
     27    of Eigen2 to Eigen3 (see \ref Eigen2ToEigen3). Not defined by default.
     28  - \b EIGEN2_SUPPORT_STAGEnn_xxx (for various values of nn and xxx) - staged migration path from Eigen2 to
     29    Eigen3; see \ref Eigen2SupportModes.
     30  - \b EIGEN_DEFAULT_DENSE_INDEX_TYPE - the type for column and row indices in matrices, vectors and array
     31    (DenseBase::Index). Set to \c std::ptrdiff_t by default.
     32  - \b EIGEN_DEFAULT_IO_FORMAT - the IOFormat to use when printing a matrix if no #IOFormat is specified.
     33    Defaults to the #IOFormat constructed by the default constructor IOFormat().
     34  - \b EIGEN_INITIALIZE_MATRICES_BY_ZERO - if defined, all entries of newly constructed matrices and arrays are
     35    initializes to zero, as are new entries in matrices and arrays after resizing. Not defined by default.
     36  - \b EIGEN_NO_AUTOMATIC_RESIZING - if defined, the matrices (or arrays) on both sides of an assignment 
     37    <tt>a = b</tt> have to be of the same size; otherwise, %Eigen automatically resizes \c a so that it is of
     38    the correct size. Not defined by default.
     39 
     40 
     41 \section TopicPreprocessorDirectivesAssertions Assertions
     42 
     43 The %Eigen library contains many assertions to guard against programming errors, both at compile time and at
     44 run time. However, these assertions do cost time and can thus be turned off.
     45 
     46  - \b EIGEN_NO_DEBUG - disables %Eigen's assertions if defined. Not defined by default, unless the
     47    \c NDEBUG macro is defined (this is a standard C++ macro which disables all asserts). 
     48  - \b EIGEN_NO_STATIC_ASSERT - if defined, compile-time static assertions are replaced by runtime assertions; 
     49    this saves compilation time. Not defined by default.
     50  - \b eigen_assert - macro with one argument that is used inside %Eigen for assertions. By default, it is
     51    basically defined to be \c assert, which aborts the program if the assertion is violated. Redefine this
     52    macro if you want to do something else, like throwing an exception.
     53  - \b EIGEN_MPL2_ONLY - disable non MPL2 compatible features, or in other words disable the features which
     54    are still under the LGPL.
     55 
     56 
     57 \section TopicPreprocessorDirectivesPerformance Alignment, vectorization and performance tweaking
     58 
     59  - \b EIGEN_DONT_ALIGN - disables alignment completely. %Eigen will not try to align its objects and does not
     60    expect that any objects passed to it are aligned. This will turn off vectorization. Not defined by default.
     61  - \b EIGEN_DONT_ALIGN_STATICALLY - disables alignment of arrays on the stack. Not defined by default, unless
     62    \c EIGEN_DONT_ALIGN is defined.
     63  - \b EIGEN_DONT_VECTORIZE - disables explicit vectorization when defined. Not defined by default, unless 
     64    alignment is disabled by %Eigen's platform test or the user defining \c EIGEN_DONT_ALIGN.
     65  - \b EIGEN_FAST_MATH - enables some optimizations which might affect the accuracy of the result. The only
     66    optimization this currently includes is single precision sin() and cos() in the present of SSE
     67    vectorization. Defined by default. 
     68  - \b EIGEN_UNROLLING_LIMIT - defines the size of a loop to enable meta unrolling. Set it to zero to disable
     69    unrolling. The size of a loop here is expressed in %Eigen's own notion of "number of FLOPS", it does not
     70    correspond to the number of iterations or the number of instructions. The default is value 100. 
     71 
     72 
     73 \section TopicPreprocessorDirectivesPlugins Plugins
     74 
     75 It is possible to add new methods to many fundamental classes in %Eigen by writing a plugin. As explained in
     76 the section \ref ExtendingMatrixBase, the plugin is specified by defining a \c EIGEN_xxx_PLUGIN macro. The
     77 following macros are supported; none of them are defined by default.
     78 
     79  - \b EIGEN_ARRAY_PLUGIN - filename of plugin for extending the Array class.
     80  - \b EIGEN_ARRAYBASE_PLUGIN - filename of plugin for extending the ArrayBase class.
     81  - \b EIGEN_CWISE_PLUGIN - filename of plugin for extending the Cwise class.
     82  - \b EIGEN_DENSEBASE_PLUGIN - filename of plugin for extending the DenseBase class.
     83  - \b EIGEN_DYNAMICSPARSEMATRIX_PLUGIN - filename of plugin for extending the DynamicSparseMatrix class.
     84  - \b EIGEN_MATRIX_PLUGIN - filename of plugin for extending the Matrix class.
     85  - \b EIGEN_MATRIXBASE_PLUGIN - filename of plugin for extending the MatrixBase class.
     86  - \b EIGEN_PLAINOBJECTBASE_PLUGIN - filename of plugin for extending the PlainObjectBase class.
     87  - \b EIGEN_QUATERNIONBASE_PLUGIN - filename of plugin for extending the QuaternionBase class.
     88  - \b EIGEN_SPARSEMATRIX_PLUGIN - filename of plugin for extending the SparseMatrix class.
     89  - \b EIGEN_SPARSEMATRIXBASE_PLUGIN - filename of plugin for extending the SparseMatrixBase class.
     90  - \b EIGEN_SPARSEVECTOR_PLUGIN - filename of plugin for extending the SparseVector class.
     91  - \b EIGEN_TRANSFORM_PLUGIN - filename of plugin for extending the Transform class.
     92  - \b EIGEN_FUNCTORS_PLUGIN - filename of plugin for adding new functors and specializations of functor_traits.
     93 
     94 
     95 \section TopicPreprocessorDirectivesDevelopers Macros for Eigen developers
     96 
     97 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.
     98 
     99  - \b EIGEN_DEFAULT_TO_ROW_MAJOR - when defined, the default storage order for matrices becomes row-major
    100    instead of column-major. Not defined by default.
    101  - \b EIGEN_INTERNAL_DEBUGGING - if defined, enables assertions in %Eigen's internal routines. This is useful
    102    for debugging %Eigen itself. Not defined by default.
    103  - \b EIGEN_NO_MALLOC - if defined, any request from inside the %Eigen to allocate memory from the heap
    104    results in an assertion failure. This is useful to check that some routine does not allocate memory
    105    dynamically. Not defined by default.
    106  - \b EIGEN_RUNTIME_NO_MALLOC - if defined, a new switch is introduced which can be turned on and off by
    107    calling <tt>set_is_malloc_allowed(bool)</tt>. If malloc is not allowed and %Eigen tries to allocate memory
    108    dynamically anyway, an assertion failure results. Not defined by default.
    109 
    110 */
    111 
    112 }
    113