STIR  6.3.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 #if __cplusplus >= 202002L
76 # include <numbers>
77 #endif
78 
79 //*************** namespace macros
80 #define START_NAMESPACE_STIR \
81  namespace stir \
82  {
83 #define END_NAMESPACE_STIR }
84 #define USING_NAMESPACE_STIR using namespace stir;
85 
86 //*************** define __OS_xxx__
87 
88 #if !defined(__OS_WIN__) && !defined(__OS_MAC__) && !defined(__OS_VAX__) && !defined(__OS_UNIX__)
89 // if none of these macros is defined externally, we attempt to guess, defaulting to UNIX
90 
91 # ifdef __MSL__
92 // Metrowerks CodeWarrior
93 // first set its own macro
94 # if macintosh && !defined(__dest_os)
95 # define __dest_os __mac_os
96 # endif
97 # if __dest_os == __mac_os
98 # define __OS_MAC__
99 # else
100 # define __OS_WIN__
101 # endif
102 
103 # elif defined(_WIN32) || defined(WIN32) || defined(_WINDOWS) || defined(_DOS)
104 // Visual C++, MSC, cygwin gcc and hopefully some others
105 # define __OS_WIN__
106 
107 # elif defined(VAX)
108 // Just in case anyone is still using VAXes...
109 # define __OS_VAX__
110 
111 # else // default
112 
113 # define __OS_UNIX__
114 // subcases
115 # if defined(_AIX)
116 # define __OS_AIX__
117 # elif defined(__sun)
118 // should really branch on SunOS and Solaris...
119 # define __OS_SUN__
120 # elif defined(__linux__)
121 # define __OS_LINUX__
122 # elif defined(__osf__)
123 # defined __OS_OSF__
124 # endif
125 
126 # endif // __OS_UNIX_ case
127 
128 #endif // !defined(__OS_xxx_)
129 
130 //***************
131 START_NAMESPACE_STIR
132 
133 #ifndef _PI
134 # if __cplusplus >= 202002L
135 
137 # define _PI std::numbers::pi
138 # else
139 
141 # define _PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
142 # endif
143 #endif
144 
146 constexpr double speed_of_light_in_mm_per_ps = 0.299792458;
149 
151 
152 template <class NUMBER>
153 inline NUMBER
154 square(const NUMBER& x)
155 {
156  return x * x;
157 }
158 
159 END_NAMESPACE_STIR
160 
161 #endif
constexpr double speed_of_light_in_mm_per_ps
Define the speed of light in mm / ps.
Definition: common.h:146
constexpr double speed_of_light_in_mm_per_ps_div2
This ratio is used often.
Definition: common.h:148
NUMBER square(const NUMBER &x)
returns the square of a number, templated.
Definition: common.h:154