herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
ftypes.h
1#ifndef FTYPES_H
2#define FTYPES_H
3
4#define FORTRAN(s) s##_
5
6#if QUAD
7
8#define RealType long double
9
10#pragma pack(push, 1)
11typedef struct {
12 unsigned long long frac;
13 unsigned short exp;
14} REAL10;
15typedef struct {
16 char zero[6];
17 unsigned long long frac;
18 unsigned short exp;
19} REAL16;
20#pragma pack(pop)
21
22typedef union {
23 long double r10;
24 REAL10 i10;
25 REAL16 i16;
26 unsigned long long i8[2];
27} REAL;
28
29static inline REAL ToREAL(const RealType r) {
30 REAL n;
31 n.i8[0] = 0;
32 n.i16.frac = ((REAL *)&r)->i10.frac << 1;
33 n.i16.exp = ((REAL *)&r)->i10.exp;
34 return n;
35}
36
37static inline RealType ToReal(const REAL r) {
38 REAL n;
39 const long long z = r.i16.frac | (r.i16.exp & 0x7fff);
40 n.i10.frac = (r.i16.frac >> 1) | ((z | -z) & 0x8000000000000000LL);
41 n.i10.exp = r.i16.exp;
42 return n.r10;
43}
44
45static inline void ToRealArray(RealType *out, const REAL *in, const int n) {
46 int i;
47 for( i = 0; i < n; ++i ) out[i] = ToReal(in[i]);
48}
49
50static inline void ToREALArray(REAL *out, const RealType *in, const int n) {
51 int i;
52 for( i = 0; i < n; ++i ) out[i] = ToREAL(in[i]);
53}
54
55#else
56
57#define RealType double
58typedef double REAL;
59
60#define ToReal(r) (r)
61#define ToREAL(r) (r)
62
63#endif
64
65typedef int INTEGER;
66typedef const INTEGER CINTEGER;
67typedef const REAL CREAL;
68typedef struct { REAL re, im; } COMPLEX;
69typedef const COMPLEX CCOMPLEX;
70typedef char CHARACTER;
71typedef const CHARACTER CCHARACTER;
72
73#include <complex>
74typedef std::complex<RealType> ComplexType;
75#define ToComplex(c) ComplexType(ToReal((c).re), ToReal((c).im))
76#define ToComplex2(r,i) ComplexType(r, i)
77#define Re(x) std::real(x)
78#define Im(x) std::imag(x)
79#define Conjugate(x) std::conj(x)
80
81typedef const RealType cRealType;
82typedef const ComplexType cComplexType;
83
84#endif
85
Generator< Zero > zero(double low, double up)
Construct a zero density.