mlpack  2.0.1
prereqs.hpp
Go to the documentation of this file.
1 
13 #ifndef __MLPACK_PREREQS_HPP
14 #define __MLPACK_PREREQS_HPP
15 
16 // First, check if Armadillo was included before, warning if so.
17 #ifdef ARMA_INCLUDES
18 #pragma message "Armadillo was included before mlpack; this can sometimes cause\
19  problems. It should only be necessary to include <mlpack/core.hpp> and not \
20 <armadillo>."
21 #endif
22 
23 // Next, standard includes.
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <ctype.h>
28 #include <limits.h>
29 #include <float.h>
30 #include <stdint.h>
31 #include <iostream>
32 #include <stdexcept>
33 
34 // Defining _USE_MATH_DEFINES should set M_PI.
35 #define _USE_MATH_DEFINES
36 #include <math.h>
37 
38 // For tgamma().
39 #include <boost/math/special_functions/gamma.hpp>
40 
41 // But if it's not defined, we'll do it.
42 #ifndef M_PI
43  #define M_PI 3.141592653589793238462643383279
44 #endif
45 
46 // Give ourselves a nice way to force functions to be inline if we need.
47 #define force_inline
48 #if defined(__GNUG__) && !defined(DEBUG)
49  #undef force_inline
50  #define force_inline __attribute__((always_inline))
51 #elif defined(_MSC_VER) && !defined(DEBUG)
52  #undef force_inline
53  #define force_inline __forceinline
54 #endif
55 
56 // We'll need the necessary boost::serialization features, as well as what we
57 // use with mlpack. In Boost 1.59 and newer, the BOOST_PFTO code is no longer
58 // defined, but we still need to define it (as nothing) so that the mlpack
59 // serialization shim compiles.
60 #include <boost/serialization/serialization.hpp>
61 #include <boost/serialization/vector.hpp>
62 #include <boost/serialization/map.hpp>
63 #if BOOST_VERSION < 105500 // Old versions don't have unordered_map support.
65 #else
66  #include <boost/serialization/unordered_map.hpp>
67 #endif
68 // Boost 1.59 and newer don't use BOOST_PFTO, but our shims do. We can resolve
69 // any issue by setting BOOST_PFTO to nothing.
70 #ifndef BOOST_PFTO
71  #define BOOST_PFTO
72 #endif
74 
75 // Now include Armadillo through the special mlpack extensions.
76 #include <mlpack/core/arma_extend/arma_extend.hpp>
77 
78 // Ensure that the user isn't doing something stupid with their Armadillo
79 // defines.
81 
82 // On Visual Studio, disable C4519 (default arguments for function templates)
83 // since it's by default an error, which doesn't even make any sense because
84 // it's part of the C++11 standard.
85 #ifdef _MSC_VER
86  #pragma warning(disable : 4519)
87 #endif
88 
89 #endif