BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MathFunctions.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Base/Utils/MathFunctions.h
6 //! @brief Defines namespace MathFunctions.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_BASE_UTILS_MATHFUNCTIONS_H
16 #define BORNAGAIN_BASE_UTILS_MATHFUNCTIONS_H
17 
18 #include "Base/Types/Complex.h"
19 #include <vector>
20 
21 //! Various mathematical functions.
22 
23 namespace MathFunctions
24 {
25 
26 // ************************************************************************** //
27 // Various functions
28 // ************************************************************************** //
29 
30 double StandardNormal(double x);
31 double Gaussian(double x, double average, double std_dev);
32 double IntegratedGaussian(double x, double average, double std_dev);
33 
34 //! cotangent function: \f$cot(x)\equiv1/tan(x)\f$
35 double cot(double x);
36 
37 //! Sine integral function: \f$Si(x)\equiv\int_0^x du \sin(u)/u\f$
38 double Si(double x);
39 
40 //! sinc function: \f$sinc(x)\equiv\sin(x)/x\f$
41 double sinc(double x);
42 
43 //! Complex sinc function: \f$sinc(x)\equiv\sin(x)/x\f$
44 complex_t sinc(const complex_t z);
45 
46 //! Complex tanhc function: \f$tanhc(x)\equiv\tanh(x)/x\f$
47 complex_t tanhc(const complex_t z);
48 
49 //! Real Laue function: \f$Laue(x,N)\equiv\sin(Nx)/sin(x)\f$
50 double Laue(const double x, size_t N);
51 
52 //! Error function of real-valued argument
53 double erf(double arg);
54 
55 // ************************************************************************** //
56 // Bessel functions
57 // ************************************************************************** //
58 
59 //! Bessel function of the first kind and order 0
60 double Bessel_J0(double x);
61 
62 //! Bessel function of the first kind and order 1
63 double Bessel_J1(double x);
64 
65 //! Bessel function Bessel_J1(x)/x
66 double Bessel_J1c(double x);
67 
68 //! Modified Bessel function of the first kind and order 0
69 double Bessel_I0(double x);
70 
71 //! Complex Bessel function of the first kind and order 0
73 
74 //! Complex Bessel function of the first kind and order 1
76 
77 //! Complex Bessel function Bessel_J1(x)/x
79 
80 // ************************************************************************** //
81 // Fourier transform and convolution
82 // ************************************************************************** //
83 
84 // TODO move elsewhere, and rm #include <vector>
85 
87 
88 // TODO: name these two functions differently (SWIG warning 509)
89 std::vector<complex_t> FastFourierTransform(const std::vector<complex_t>& data,
90  EFFTDirection tcase);
91 std::vector<complex_t> FastFourierTransform(const std::vector<double>& data, EFFTDirection tcase);
92 
93 std::vector<complex_t> ConvolveFFT(const std::vector<double>& signal,
94  const std::vector<double>& resfunc);
95 
96 // ************************************************************************** //
97 // Random number generators
98 // ************************************************************************** //
99 
100 double GenerateUniformRandom();
102 double GenerateNormalRandom(double average, double std_dev);
103 double GeneratePoissonRandom(double average);
104 
105 } // Namespace MathFunctions
106 
107 #endif // BORNAGAIN_BASE_UTILS_MATHFUNCTIONS_H
Defines complex_t, and a few elementary functions.
std::complex< double > complex_t
Definition: Complex.h:20
Various mathematical functions.
double GenerateUniformRandom()
double IntegratedGaussian(double x, double average, double std_dev)
double GenerateNormalRandom(double average, double std_dev)
double cot(double x)
cotangent function:
std::vector< complex_t > FastFourierTransform(const std::vector< complex_t > &data, EFFTDirection tcase)
simple (and unoptimized) wrapper function for the discrete fast Fourier transformation library (fftw3...
double Laue(const double x, size_t N)
Real Laue function: .
std::vector< complex_t > ConvolveFFT(const std::vector< double > &signal, const std::vector< double > &resfunc)
convolution of two real vectors of equal size
double sinc(double x)
sinc function:
double StandardNormal(double x)
complex_t tanhc(const complex_t z)
Complex tanhc function: .
double Bessel_J0(double x)
Bessel function of the first kind and order 0.
double Bessel_J1(double x)
Bessel function of the first kind and order 1.
double Bessel_J1c(double x)
Bessel function Bessel_J1(x)/x.
double Gaussian(double x, double average, double std_dev)
double erf(double arg)
Error function of real-valued argument.
double Si(double x)
Sine integral function: .
double GeneratePoissonRandom(double average)
double Bessel_I0(double x)
Modified Bessel function of the first kind and order 0.
double GenerateStandardNormalRandom()