Mantid
Loading...
Searching...
No Matches
Fast_Exponential.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9namespace Mantid {
10namespace Kernel {
11
26#define EXP_A (1048576 / M_LN2)
27#define EXP_C 60801
28
29inline double fast_exp(double y) {
30 static union {
31 double d;
32#ifdef LITTLE_ENDIAN
33 struct {
34 int j, i;
35 } n;
36#else
37 struct {
38 int i, j;
39 } n;
40#endif
41 } _eco;
42
43 _eco.n.i = (int)(EXP_A * (y)) + (1072693248 - EXP_C);
44 _eco.n.j = 0;
45
46 return _eco.d;
47}
48
49} // Namespace Kernel
50} // Namespace Mantid
#define EXP_A
Based on the article: A Fast, Compact Approximation of the Exponential Function by Nicol N.
#define EXP_C
double fast_exp(double y)
Helper class which provides the Collimation Length for SANS instruments.