Page MenuHomec4science

distrib.h
No OneTemporary

File Metadata

Created
Thu, Aug 8, 13:23

distrib.h

#ifndef __DISTRIB_H__
#define __DISTRIB_H__
#include <complex>
#include "symbasic/svector.h"
namespace dstb
{
class gaussian
{
typedef std::complex<double> cmpx;
public:
gaussian(double _x0 = 0,
double s_norm = 1,
unsigned int n = 1,
const SVector<double, 2>& bounds = {0, 1}) :
x0(_x0),
sigma(s_norm * (bounds[1] - bounds[0])),
k0(2 * M_PI * n / (bounds[1] - bounds[0])),
C(sqrt(sigma * sqrt(M_PI))) {}
cmpx operator()(double x) const
{
using namespace std::complex_literals;
return C * exp(1i * k0 * x - pow((x - x0)/sigma, 2) / 2);
}
private:
double x0, sigma, k0;
const double C;
};
}
#endif

Event Timeline