Loading...
Searching...
No Matches
RadialKernelJets.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5// Generated by scripts/codegen/radial_kernel_jets.py; do not edit.
6// The generator proves the identities below with sympy before printing.
7
8#ifndef GPR_DERIVATIVES_GENERATED_RADIALKERNELJETS_H_
9#define GPR_DERIVATIVES_GENERATED_RADIALKERNELJETS_H_
10
11#include <cmath>
12
14
15// clang-format off
16
17inline constexpr double kSqrt3 = 1.7320508075688772935274463415059;
18inline constexpr double kSqrt5 = 2.2360679774997896964091736687313;
19
24template <typename Real>
32
33inline constexpr int kSquaredExponentialCountOps = 11;
34inline constexpr int kMatern32CountOps = 26;
35inline constexpr int kMatern52CountOps = 32;
36
39template <typename Real>
41 const Real& s, const Real& energy_weight,
42 const Real& gradient_residual_dot)
43{
44 using std::exp;
45 using std::sqrt;
47 const Real t0 = exp(-s);
48 const Real t1 = t0*(energy_weight + 2.0*gradient_residual_dot);
49 out.value = t1;
50 out.gradient_residual = -2.0*t1;
51 out.gradient_weight = 2.0*t0;
52 out.hessian_residual = 4.0*t1;
53 out.hessian_cross = -4.0*t0;
54 return out;
55}
56
59template <typename Real>
61 const Real& s, const Real& energy_weight,
62 const Real& gradient_residual_dot)
63{
64 using std::exp;
65 using std::sqrt;
67 const Real rho = sqrt(s);
68 const Real t0 = kSqrt3*rho;
69 const Real t1 = exp(-t0);
70 const Real t2 = 3.0*gradient_residual_dot;
71 const Real t3 = (1.0/(rho));
72 const Real t4 = gradient_residual_dot*kSqrt3;
73 const Real t5 = 3.0*t1;
74 const Real t6 = t3*t5;
75 out.value = t1*(energy_weight*t0 + energy_weight + t2);
76 out.gradient_residual = -t5*(energy_weight + t3*t4);
77 out.gradient_weight = t5;
78 out.hessian_residual = t6*(energy_weight*kSqrt3 + t2*t3 + t4/(rho*rho));
79 out.hessian_cross = -kSqrt3*t6;
80 return out;
81}
82
85template <typename Real>
87 const Real& s, const Real& energy_weight,
88 const Real& gradient_residual_dot)
89{
90 using std::exp;
91 using std::sqrt;
93 const Real rho = sqrt(s);
94 const Real t0 = kSqrt5*rho;
95 const Real t1 = exp(-t0);
96 const Real t2 = ((5.0/3.0))*gradient_residual_dot;
97 const Real t3 = energy_weight*t0 + energy_weight;
98 const Real t4 = ((5.0/3.0))*t1;
99 const Real t5 = ((25.0/3.0))*t1;
100 out.value = t1*(((5.0/3.0))*energy_weight*(rho*rho) + t0*t2 + t2 + t3);
101 out.gradient_residual = -t4*(5.0*gradient_residual_dot + t3);
102 out.gradient_weight = t4*(t0 + 1.0);
103 out.hessian_residual = t5*(energy_weight + gradient_residual_dot*kSqrt5/rho);
104 out.hessian_cross = -t5;
105 return out;
106}
107// clang-format on
108
109} // namespace gpr::derivatives::generated
110
111#endif // GPR_DERIVATIVES_GENERATED_RADIALKERNELJETS_H_
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
RadialTerms< Real > matern32Terms(const Real &s, const Real &energy_weight, const Real &gradient_residual_dot)
RadialTerms< Real > matern52Terms(const Real &s, const Real &energy_weight, const Real &gradient_residual_dot)
RadialTerms< Real > squaredExponentialTerms(const Real &s, const Real &energy_weight, const Real &gradient_residual_dot)
constexpr int kSquaredExponentialCountOps