STIR  6.2.0
common.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000 PARAPET partners
5  Copyright (C) 2000- 2010, Hammersmith Imanet Ltd
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
9 
10  See STIR/LICENSE.txt for details
11 */
12 #ifndef __stir_common_H__
13 #define __stir_common_H__
14 
68 #include "stir/config.h"
69 
70 #include <cstdio>
71 #include <cstdlib>
72 #include <cstring>
73 #include <cmath>
74 #include <cassert>
75 #include <boost/math/constants/constants.hpp>
76 
77 //*************** namespace macros
78 #define START_NAMESPACE_STIR \
79  namespace stir \
80  {
81 #define END_NAMESPACE_STIR }
82 #define USING_NAMESPACE_STIR using namespace stir;
83 
84 //*************** define __OS_xxx__
85 
86 #if !defined(__OS_WIN__) && !defined(__OS_MAC__) && !defined(__OS_VAX__) && !defined(__OS_UNIX__)
87 // if none of these macros is defined externally, we attempt to guess, defaulting to UNIX
88 
89 # ifdef __MSL__
90 // Metrowerks CodeWarrior
91 // first set its own macro
92 # if macintosh && !defined(__dest_os)
93 # define __dest_os __mac_os
94 # endif
95 # if __dest_os == __mac_os
96 # define __OS_MAC__
97 # else
98 # define __OS_WIN__
99 # endif
100 
101 # elif defined(_WIN32) || defined(WIN32) || defined(_WINDOWS) || defined(_DOS)
102 // Visual C++, MSC, cygwin gcc and hopefully some others
103 # define __OS_WIN__
104 
105 # elif defined(VAX)
106 // Just in case anyone is still using VAXes...
107 # define __OS_VAX__
108 
109 # else // default
110 
111 # define __OS_UNIX__
112 // subcases
113 # if defined(_AIX)
114 # define __OS_AIX__
115 # elif defined(__sun)
116 // should really branch on SunOS and Solaris...
117 # define __OS_SUN__
118 # elif defined(__linux__)
119 # define __OS_LINUX__
120 # elif defined(__osf__)
121 # defined __OS_OSF__
122 # endif
123 
124 # endif // __OS_UNIX_ case
125 
126 #endif // !defined(__OS_xxx_)
127 
128 //***************
129 START_NAMESPACE_STIR
130 
132 
133 #ifndef _PI
134 # define _PI boost::math::constants::pi<double>()
135 #endif
136 
138 constexpr double speed_of_light_in_mm_per_ps = 0.299792458;
141 
143 
144 template <class NUMBER>
145 inline NUMBER
146 square(const NUMBER& x)
147 {
148  return x * x;
149 }
150 
151 END_NAMESPACE_STIR
152 
153 #endif
constexpr double speed_of_light_in_mm_per_ps
Define the speed of light in mm / ps.
Definition: common.h:138
constexpr double speed_of_light_in_mm_per_ps_div2
This ratio is used often.
Definition: common.h:140
NUMBER square(const NUMBER &x)
returns the square of a number, templated.
Definition: common.h:146