31 constexpr
double f = 1 / 298.257223563;
32 constexpr
double a = 6378137;
33 constexpr
double k0 = 0.9996;
34 constexpr
double E0 = 500e3;
38 constexpr
double n = f / (2 -
f);
46 a *
shared::horner(n * n, 1, 1. / 4, 1. / 64, 1. / 256, 25. / 16384) / (1 +
n);
51 __device__ __constant__
const
55 std::array<double, 9>
alphas
56 { std::numeric_limits<double>::quiet_NaN()
57 ,
shared::horner(n, 0, 1./2, -2./3, 5./16, 41./180, -127./288, 7891./37800, 72161./387072, -18975107./50803200)
58 ,
shared::horner(n, 0, 0, 13./48, -3./5, 557./1440, 281./630, -1983433./1935360, 13769./28800, 148003883./174182400)
59 ,
shared::horner(n, 0, 0, 0, 61./240, -103./140, 15061./26880, 167603./181440, -67102379./29030400, 79682431./79833600)
60 ,
shared::horner(n, 0, 0, 0, 0, 49561./161280, -179./168, 6601661./7257600, 97445./49896, -40176129013./7664025600)
61 ,
shared::horner(n, 0, 0, 0, 0, 0, 34729./80640, -3418889./1995840, 14644087./9123840, 2605413599./622702080)
62 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 212378941./319334400, -30705481./10378368, 175214326799./58118860800)
63 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 1522256789./1383782400, -16759934899./3113510400)
64 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 0, 1424729850961./743921418240)
67 __device__ __constant__
const
71 std::array<double, 9>
betas
72 { std::numeric_limits<double>::quiet_NaN()
73 ,
shared::horner(n, 0, 1./2, -2./3, 37./96, -1./360, -81./512, 96199./604800, -5406467./38707200, 7944359./67737600)
74 ,
shared::horner(n, 0, 0, 1./48, 1./15, -437./1440, 46./105, -1118711./3870720, 51841./1209600, 24749483./348364800)
75 ,
shared::horner(n, 0, 0, 0, 17./480, -37./840, -209./4480, 5569./90720, 9261899./58060800, -6457463./17740800)
76 ,
shared::horner(n, 0, 0, 0, 0, 4397./161280, -11./504, -830251./7257600, 466511./2494800, 324154477./7664025600)
77 ,
shared::horner(n, 0, 0, 0, 0, 0, 4583./161280, -108847./3991680, -8005831./63866880, 22894433./124540416)
78 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 20648693./638668800, -16363163./518918400, -2204645983./12915302400)
79 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 219941297./5535129600, -497323811./12454041600)
80 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 0, 191773887257./3719607091200)
93 __device__ __constant__
const
97 std::array<double, 9>
deltas
98 { std::numeric_limits<double>::quiet_NaN()
99 ,
shared::horner(n, 0, 2, -2./3, -2, 116./45, 26./45, -2854./675, 16822./4725, 189416./99225)
100 ,
shared::horner(n, 0, 0, 7./3, -8./5, -227./45, 2704./315, 2323./945, -31256./1575, 141514./8505)
101 ,
shared::horner(n, 0, 0, 0, 56./15, -136./35, -1262./105, 73814./2835, 98738./14175, -2363828./31185)
102 ,
shared::horner(n, 0, 0, 0, 0, 4279./630, -332./35, - 399572./14175, 11763988./155925, 14416399./935550)
103 ,
shared::horner(n, 0, 0, 0, 0, 0, 4174./315, -144838./6237, -2046082./31185, 258316372./1216215)
104 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 601676./22275, -115444544./2027025, -2155215124./14189175)
105 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 38341552./675675, -170079376./1216215)
106 ,
shared::horner(n, 0, 0, 0, 0, 0, 0, 0, 0, 1383243703./11351340)
110 constexpr
unsigned N = 6;
114 return (32601 <= srid && srid <= 32660) || (32701 <= srid && srid <= 32760);
138 unsigned const zone =
srid_ % 100u;
139 double const x0 = zone * 6.0 - 183;
143 double const c = 2 * sqrt(
n) / (1 +
n);
146 double const t = sinh(atanh(sin(phi)) - c * atanh(c * sin(phi)));
151 eta_ = atanh(sin(dlambda) / sqrt(1 + t * t));
152 xi_ = atan(t / cos(dlambda));
173 for (
unsigned j =
N; j; --j) {
177 for (
unsigned j =
N; j; --j) {
196 double const N0 = (32700 <
srid_) * 10e6;
199 for (
unsigned j =
N; j; --j) {
203 for (
unsigned j =
N; j; --j) {
207 return N0 +
k0_A * (
xi_ + sum);
228 double const eta = (x -
E0) /
k0_A;
229 small_eta_ = -1.0 / 12 <= eta && eta <= 1.0 / 12;
230 double const N0 = (32700 <
srid_) * 10e6;
231 double const xi = (y - N0) /
k0_A;
236 for (
unsigned j =
N; j; --j) {
239 for (
unsigned j =
N; j; --j) {
243 for (
unsigned j =
N; j; --j) {
244 eta_sum +=
betas[j] * cos(2 * j * xi) * sinh(2 * j * eta);
246 for (
unsigned j =
N; j; --j) {
247 xi_sum +=
betas[j] * sin(2 * j * xi) * cosh(2 * j * eta);
250 eta_ = eta - eta_sum;
256 unsigned const zone =
srid_ % 100u;
257 double const lambda0 = zone * 6.0 - 183;
267 double const chi = asin(sin(
xi_) / cosh_eta);
269 for (
unsigned j =
N; j; --j) {
270 sum +=
deltas[j] * sin(2 * j * chi);
278 double const e = std::sqrt(
f * (2 -
f));
280 std::sin(
xi_) / std::sqrt(sq(std::sinh(
eta_)) + sq(std::cos(
xi_)));
282 double tau[2]{taup, 0.0 / 0.0};
284 for (; tau[0] != tau[1]; ++i) {
285 double const tau_i = tau[i & 1];
286 double const sigma_i =
287 std::sinh(e * std::tanh(e * tau_i / std::sqrt(1 + sq(tau_i))));
288 double const taup_i =
289 tau_i * std::sqrt(1 + sq(sigma_i)) - sigma_i * std::sqrt(1 + sq(tau_i));
290 double const dtau_i = (taup - taup_i) * (1 + (1 - e * e) * sq(tau_i)) /
291 ((1 - e * e) * std::sqrt((1 + sq(taup_i)) * (1 + sq(tau_i))));
292 tau[~i & 1] = tau_i + dtau_i;
DEVICE constexpr double horner(double const x, double const c0, COEFFICIENTS...c)
constexpr std::array< double, 9 > alphas
DEVICE double fastSin(double const x)
constexpr std::array< double, 9 > deltas
DEVICE double fastCos(double const x)
constexpr double deg_div_rad
constexpr double rad_div_deg
constexpr std::array< double, 9 > betas
DEVICE bool is_utm_srid(unsigned const srid)
DEVICE double fastAtanh(double const x)
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
DEVICE double fastCosh(double const x)
DEVICE double fastSinh(double const x)