21 , _fft(make_shared<fft_t>(fft_t(2 * _N, false)))
28 _fft->assign(2 * _N,
false);
31 void DST::fft_transform(
real data[],
real F[],
bool centerp)
const {
39 for (
int i = 0; i < _N; ++i) {
40 data[_N+i] = data[_N-1-i];
41 data[2*_N+i] = -data[i];
42 data[3*_N+i] = -data[_N-1-i];
46 for (
int i = 1; i < _N; ++i) data[_N+i] = data[_N-i];
47 for (
int i = 0; i < 2*_N; ++i) data[2*_N+i] = -data[i];
49 vector<complex<real>> ctemp(2*_N);
50 _fft->transform_real(data, ctemp.data());
53 for (
int i = 0, j = 1; i < _N; ++i, j+=2)
54 ctemp[j] *= exp(complex<real>(0, j*d));
56 for (
int i = 0, j = 1; i < _N; ++i, j+=2) {
57 F[i] = -ctemp[j].imag() / (2*_N);
61 void DST::fft_transform2(
real data[],
real F[])
const {
66 fft_transform(data, F+_N,
true);
68 for (
int i = 0; i < _N; ++i) data[i] = F[i+_N];
69 for (
int i = _N; i < 2*_N; ++i)
71 F[i] = (data[2*_N-1-i] - F[2*_N-1-i])/2;
72 for (
int i = 0; i < _N; ++i)
74 F[i] = (data[i] + F[i])/2;
78 vector<real> data(4 * _N);
80 for (
int i = 1; i <= _N; ++i)
82 fft_transform(data.data(), F,
false);
86 vector<real> data(4 * _N);
88 for (
int i = 0; i < _N; ++i)
89 data[i] = f( (2*i + 1) * d );
90 fft_transform2(data.data(), F);
99 ar = 2 * (cosx - sinx) * (cosx + sinx),
100 y0 =
N & 1 ? F[--
N] : 0, y1 = 0;
104 y1 = ar * y0 - y1 + F[--
N];
105 y0 = ar * y1 - y0 + F[--
N];
107 return sinx * (y0 + y1);
116 ar = 2 * (cosx - sinx) * (cosx + sinx),
118 for (--
N;
N >= 0; --
N) {
119 real t = ar * y0 - y1 + F[
N]/(2*
N+1);
122 return cosx * (y1 - y0);
126 const real F[],
int N) {
130 ac = +2 * (cosy * cosx + siny * sinx) * (cosy * cosx - siny * sinx),
132 as = -2 * (siny * cosx - cosy * sinx) * (siny * cosx + cosy * sinx),
133 y0 = 0, y1 = 0, z0 = 0, z1 = 0;
134 for (--
N;
N >= 0; --
N) {
136 ty = ac * y0 + as * z0 - y1 + F[
N]/(2*
N+1),
137 tz = as * y0 + ac * z0 - z1;
147 return (y1 - y0) * (cosy - cosx) + (z1 - z0) * (cosy + cosx);
Header for GeographicLib::DST class.
GeographicLib::Math::real real
void transform(std::function< real(real)> f, real F[]) const
static real eval(real sinx, real cosx, const real F[], int N)
void refine(std::function< real(real)> f, real F[]) const
static real integral(real sinx, real cosx, const real F[], int N)
Namespace for GeographicLib.