MaCh3  2.2.3
Reference Guide
Core.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 // C++ includes
9 #include <sstream>
10 #include <fstream>
11 #include <iostream>
12 #include <vector>
13 #include <iomanip>
14 #include <cmath>
15 #include <limits>
16 
19 namespace M3 {
20  #ifdef _LOW_MEMORY_STRUCTS_
22  using float_t = float;
24  using int_t = short;
26  using uint_t = unsigned short;
28  constexpr static const char* float_t_str_repr = "F";
29  #else
30  using float_t = double;
31  using int_t = int;
32  using uint_t = unsigned;
33  constexpr static const char* float_t_str_repr = "D";
34  #endif
35 
37  template <typename T>
38  constexpr T fmaf_t(T x, T y, T z) {
39  #ifdef _LOW_MEMORY_STRUCTS_
40  return std::fmaf(x, y, z);
41  #else
42  return std::fma(x, y, z);
43  #endif
44  }
46  constexpr static const double _BAD_DOUBLE_ = -999.99;
48  constexpr static const int _BAD_INT_ = -999;
49  constexpr static const double _DEFAULT_RETURN_VAL_ = -999999.123456;
50 
52  constexpr static const double Unity_D = 1.;
53  constexpr static const float Unity_F = 1.;
54  #ifdef _LOW_MEMORY_STRUCTS_
55  constexpr static const float_t Unity = Unity_F;
56  #else
57  constexpr static const float_t Unity = Unity_D;
58  #endif
59  constexpr static const double Zero_D = 0.;
60  constexpr static const float Zero_F = 0.;
61  #ifdef _LOW_MEMORY_STRUCTS_
62  constexpr static const float_t Zero = Zero_F;
63  #else
64  constexpr static const float_t Zero = Zero_D;
65  #endif
66 
68  constexpr static const double KinematicLowBound = std::numeric_limits<double>::lowest();
70  constexpr static const double KinematicUpBound = std::numeric_limits<double>::max();
71 
73  constexpr static const double _LARGE_LOGL_ = 1234567890.0;
74 
76  constexpr static const double _LOW_MC_BOUND_ = .00001;
77 
79  constexpr static const double DefSplineKnotUpBound = 9999;
81  constexpr static const double DefSplineKnotLowBound = -9999;
82 }
83 
85 #ifndef DEBUG
86 #define _noexcept_ noexcept
87 #else
88 #define _noexcept_
89 #endif
90 
92 #ifndef DEBUG
93 #define _restrict_ __restrict__
94 #else
95 #define _restrict_
96 #endif
97 
99 #define _TH2PolyOverflowBins_ 9
100 
101 #ifdef MULTITHREAD
102 #include "omp.h"
103 #endif
104 
109 #define _MaCh3_Safe_Include_Start_ \
110 _Pragma("GCC diagnostic push") \
111 _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") \
112 _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") \
113 _Pragma("GCC diagnostic ignored \"-Wold-style-cast\"") \
114 _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
115 _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"") \
116 _Pragma("GCC diagnostic ignored \"-Wconversion\"") \
117 _Pragma("GCC diagnostic ignored \"-Wshadow\"") \
118 _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"")
120 #define _MaCh3_Safe_Include_End_ \
121 _Pragma("GCC diagnostic pop")
122 
123 // clang and IntelLLVM need slightly different diagnostics
124 #if defined(__clang__) || defined(__INTEL_LLVM_COMPILER)
125  #undef _MaCh3_Safe_Include_Start_
126  #define _MaCh3_Safe_Include_Start_ \
127  _Pragma("clang diagnostic push") \
128  _Pragma("clang diagnostic ignored \"-Wfloat-conversion\"") \
129  _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
130  _Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") \
131  _Pragma("clang diagnostic ignored \"-Wswitch-enum\"") \
132  _Pragma("clang diagnostic ignored \"-Wconversion\"") \
133  _Pragma("clang diagnostic ignored \"-Wshadow\"") \
134  _Pragma("clang diagnostic ignored \"-Wdeprecated-literal-operator\"") \
135  _Pragma("clang diagnostic ignored \"-Wswitch-enum\"")
136  #undef _MaCh3_Safe_Include_End_
137  #define _MaCh3_Safe_Include_End_ \
138  _Pragma("clang diagnostic pop")
139 #endif
Definition: Core.h:19
unsigned uint_t
Definition: Core.h:32
constexpr static const double DefSplineKnotUpBound
Default value for spline knot capping, default mean not capping is being applied.
Definition: Core.h:79
constexpr static const double _LARGE_LOGL_
Large Likelihood is used it parameter go out of physical boundary, this indicates in MCMC that such s...
Definition: Core.h:73
double float_t
Definition: Core.h:30
constexpr static const double _BAD_DOUBLE_
Default value used for double initialisation.
Definition: Core.h:46
constexpr static const double Zero_D
Definition: Core.h:59
constexpr static const double DefSplineKnotLowBound
Default value for spline knot capping, default mean not capping is being applied.
Definition: Core.h:81
constexpr static const float Unity_F
Definition: Core.h:53
constexpr static const double KinematicLowBound
When parameter has no bound this serves as it. Lowest possible value the system.
Definition: Core.h:68
constexpr static const char * float_t_str_repr
Definition: Core.h:33
constexpr static const double KinematicUpBound
When parameter has no bound this serves as it. Highest possible value the system.
Definition: Core.h:70
constexpr static const float_t Unity
Definition: Core.h:57
constexpr static const float_t Zero
Definition: Core.h:64
constexpr static const int _BAD_INT_
Default value used for int initialisation.
Definition: Core.h:48
constexpr static const float Zero_F
Definition: Core.h:60
constexpr T fmaf_t(T x, T y, T z)
Function template for fused multiply-add.
Definition: Core.h:38
constexpr static const double _LOW_MC_BOUND_
MC prediction lower bound in bin to identify problematic binning definitions and handle LogL calculat...
Definition: Core.h:76
int int_t
Definition: Core.h:31
constexpr static const double _DEFAULT_RETURN_VAL_
Definition: Core.h:49
constexpr static const double Unity_D
Some commonly used variables to which we set pointers to.
Definition: Core.h:52