Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
CladDerivator.h
Go to the documentation of this file.
1/// \file CladDerivator.h
2///
3/// \brief The file is a bridge between ROOT and clad automatic differentiation
4/// plugin.
5///
6/// \author Vassil Vassilev <vvasilev@cern.ch>
7///
8/// \date July, 2018
9
10/*************************************************************************
11 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
12 * All rights reserved. *
13 * *
14 * For the licensing terms see $ROOTSYS/LICENSE. *
15 * For the list of contributors see $ROOTSYS/README/CREDITS. *
16 *************************************************************************/
17
18#ifndef CLAD_DERIVATOR
19#define CLAD_DERIVATOR
20
21#ifndef __CLING__
22#error "This file must not be included by compiled programs."
23#endif //__CLING__
24
25#include <plugins/include/clad/Differentiator/Differentiator.h>
26#include "TMath.h"
27
28// For the digamma function, that is the derivative of lgamma. We get it via
29// mathmore from the GSL, so the pullbacks that use digamma are only available
30// with mathmore=ON.
31#ifdef R__HAS_MATHMORE
33#endif
34
35namespace clad {
36namespace custom_derivatives {
37namespace TMath {
38template <typename T>
39ValueAndPushforward<T, T> Abs_pushforward(T x, T d_x)
40{
41 return {::TMath::Abs(x), ((x < 0) ? -1 : 1) * d_x};
42}
43
44template <typename T>
45ValueAndPushforward<T, T> ACos_pushforward(T x, T d_x)
46{
47 return {::TMath::ACos(x), (-1. / ::TMath::Sqrt(1 - x * x)) * d_x};
48}
49
50template <typename T>
51ValueAndPushforward<T, T> ACosH_pushforward(T x, T d_x)
52{
53 return {::TMath::ACosH(x), (1. / ::TMath::Sqrt(x * x - 1)) * d_x};
54}
55
56template <typename T>
57ValueAndPushforward<T, T> ASin_pushforward(T x, T d_x)
58{
59 return {::TMath::ASin(x), (1. / ::TMath::Sqrt(1 - x * x)) * d_x};
60}
61
62template <typename T>
63ValueAndPushforward<T, T> ASinH_pushforward(T x, T d_x)
64{
65 return {::TMath::ASinH(x), (1. / ::TMath::Sqrt(x * x + 1)) * d_x};
66}
67
68template <typename T>
69ValueAndPushforward<T, T> ATan_pushforward(T x, T d_x)
70{
71 return {::TMath::ATan(x), (1. / (x * x + 1)) * d_x};
72}
73
74template <typename T>
75ValueAndPushforward<T, T> ATanH_pushforward(T x, T d_x)
76{
77 return {::TMath::ATanH(x), (1. / (1 - x * x)) * d_x};
78}
79
80template <typename T>
81ValueAndPushforward<T, T> Cos_pushforward(T x, T d_x)
82{
83 return {::TMath::Cos(x), -::TMath::Sin(x) * d_x};
84}
85
86template <typename T>
87ValueAndPushforward<T, T> CosH_pushforward(T x, T d_x)
88{
89 return {::TMath::CosH(x), ::TMath::SinH(x) * d_x};
90}
91
92template <typename T>
93ValueAndPushforward<T, T> Erf_pushforward(T x, T d_x)
94{
95 return {::TMath::Erf(x), (2 * ::TMath::Exp(-x * x) / ::TMath::Sqrt(::TMath::Pi())) * d_x};
96}
97
98template <typename T>
99ValueAndPushforward<T, T> Erfc_pushforward(T x, T d_x)
100{
101 return {::TMath::Erfc(x), -Erf_pushforward(x, d_x).pushforward};
102}
103
104#ifdef R__HAS_MATHMORE
105
106template <typename T>
107ValueAndPushforward<T, T> LnGamma_pushforward(T z, T d_z)
108{
109 return {::TMath::LnGamma(z), ::ROOT::Math::digamma(z) * d_z};
110}
111
112#endif
113
114template <typename T>
115ValueAndPushforward<T, T> Exp_pushforward(T x, T d_x)
116{
117 return {::TMath::Exp(x), ::TMath::Exp(x) * d_x};
118}
119
120template <typename T>
121ValueAndPushforward<T, T> Hypot_pushforward(T x, T y, T d_x, T d_y)
122{
123 return {::TMath::Hypot(x, y), x / ::TMath::Hypot(x, y) * d_x + y / ::TMath::Hypot(x, y) * d_y};
124}
125
126template <typename T, typename U>
127void Hypot_pullback(T x, T y, U p, clad::array_ref<T> d_x, clad::array_ref<T> d_y)
128{
129 T h = ::TMath::Hypot(x, y);
130 *d_x += x / h * p;
131 *d_y += y / h * p;
132}
133
134template <typename T>
135ValueAndPushforward<T, T> Log_pushforward(T x, T d_x)
136{
137 return {::TMath::Log(x), (1. / x) * d_x};
138}
139
140template <typename T>
141ValueAndPushforward<T, T> Log10_pushforward(T x, T d_x)
142{
143 return {::TMath::Log10(x), (1.0 / (x * ::TMath::Ln10())) * d_x};
144}
145
146template <typename T>
147ValueAndPushforward<T, T> Log2_pushforward(T x, T d_x)
148{
149 return {::TMath::Log2(x), (1.0 / (x * ::TMath::Log(2.0))) * d_x};
150}
151
152template <typename T>
153ValueAndPushforward<T, T> Max_pushforward(T x, T y, T d_x, T d_y)
154{
155 T derivative = 0;
156 if (x >= y)
157 derivative = d_x;
158 else
159 derivative = d_y;
160 return {::TMath::Max(x, y), derivative};
161}
162
163template <typename T, typename U>
164void Max_pullback(T a, T b, U p, clad::array_ref<T> d_a, clad::array_ref<T> d_b)
165{
166 if (a >= b)
167 *d_a += p;
168 else
169 *d_b += p;
170}
171
172template <typename T>
173ValueAndPushforward<T, T> Min_pushforward(T x, T y, T d_x, T d_y)
174{
175 T derivative = 0;
176 if (x <= y)
177 derivative = d_x;
178 else
179 derivative = d_y;
180 return {::TMath::Min(x, y), derivative};
181}
182
183template <typename T, typename U>
184void Min_pullback(T a, T b, U p, clad::array_ref<T> d_a, clad::array_ref<T> d_b)
185{
186 if (a <= b)
187 *d_a += p;
188 else
189 *d_b += p;
190}
191
192template <typename T>
193ValueAndPushforward<T, T> Power_pushforward(T x, T y, T d_x, T d_y)
194{
195 T pushforward = y * ::TMath::Power(x, y - 1) * d_x;
196 if (d_y) {
197 pushforward += (::TMath::Power(x, y) * ::TMath::Log(x)) * d_y;
198 }
199 return {::TMath::Power(x, y), pushforward};
200}
201
202template <typename T, typename U>
203void Power_pullback(T x, T y, U p, clad::array_ref<T> d_x, clad::array_ref<T> d_y)
204{
205 auto t = pow_pushforward(x, y, 1, 0);
206 *d_x += t.pushforward * p;
207 t = pow_pushforward(x, y, 0, 1);
208 *d_y += t.pushforward * p;
209}
210
211template <typename T>
212ValueAndPushforward<T, T> Sin_pushforward(T x, T d_x)
213{
214 return {::TMath::Sin(x), ::TMath::Cos(x) * d_x};
215}
216
217template <typename T>
218ValueAndPushforward<T, T> SinH_pushforward(T x, T d_x)
219{
220 return {::TMath::SinH(x), ::TMath::CosH(x) * d_x};
221}
222
223template <typename T>
224ValueAndPushforward<T, T> Sq_pushforward(T x, T d_x)
225{
226 return {::TMath::Sq(x), 2 * x * d_x};
227}
228
229template <typename T>
230ValueAndPushforward<T, T> Sqrt_pushforward(T x, T d_x)
231{
232 return {::TMath::Sqrt(x), (0.5 / ::TMath::Sqrt(x)) * d_x};
233}
234
235template <typename T>
236ValueAndPushforward<T, T> Tan_pushforward(T x, T d_x)
237{
238 return {::TMath::Tan(x), (1. / ::TMath::Sq(::TMath::Cos(x))) * d_x};
239}
240
241template <typename T>
242ValueAndPushforward<T, T> TanH_pushforward(T x, T d_x)
243{
244 return {::TMath::TanH(x), (1. / ::TMath::Sq(::TMath::CosH(x))) * d_x};
245}
246
247#ifdef WIN32
248// Additional custom derivatives that can be removed
249// after Issue #12108 in ROOT is resolved
250// constexpr is removed
251ValueAndPushforward<Double_t, Double_t> Pi_pushforward()
252{
253 return {3.1415926535897931, 0.};
254}
255// constexpr is removed
256ValueAndPushforward<Double_t, Double_t> Ln10_pushforward()
257{
258 return {2.3025850929940459, 0.};
259}
260#endif
261} // namespace TMath
262
263namespace ROOT {
264namespace Math {
265
266inline void landau_pdf_pullback(double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
267{
268 if (xi <= 0) {
269 return;
270 }
271 // clang-format off
272 static double p1[5] = {0.4259894875,-0.1249762550, 0.03984243700, -0.006298287635, 0.001511162253};
273 static double q1[5] = {1.0 ,-0.3388260629, 0.09594393323, -0.01608042283, 0.003778942063};
274
275 static double p2[5] = {0.1788541609, 0.1173957403, 0.01488850518, -0.001394989411, 0.0001283617211};
276 static double q2[5] = {1.0 , 0.7428795082, 0.3153932961, 0.06694219548, 0.008790609714};
277
278 static double p3[5] = {0.1788544503, 0.09359161662,0.006325387654, 0.00006611667319,-0.000002031049101};
279 static double q3[5] = {1.0 , 0.6097809921, 0.2560616665, 0.04746722384, 0.006957301675};
280
281 static double p4[5] = {0.9874054407, 118.6723273, 849.2794360, -743.7792444, 427.0262186};
282 static double q4[5] = {1.0 , 106.8615961, 337.6496214, 2016.712389, 1597.063511};
283
284 static double p5[5] = {1.003675074, 167.5702434, 4789.711289, 21217.86767, -22324.94910};
285 static double q5[5] = {1.0 , 156.9424537, 3745.310488, 9834.698876, 66924.28357};
286
287 static double p6[5] = {1.000827619, 664.9143136, 62972.92665, 475554.6998, -5743609.109};
288 static double q6[5] = {1.0 , 651.4101098, 56974.73333, 165917.4725, -2815759.939};
289
290 static double a1[3] = {0.04166666667,-0.01996527778, 0.02709538966};
291
292 static double a2[2] = {-1.845568670,-4.284640743};
293 // clang-format on
294 const double _const0 = 0.3989422803;
295 double v = (x - x0) / xi;
296 double _d_v = 0;
297 double _d_denlan = 0;
298 if (v < -5.5) {
299 double u = ::std::exp(v + 1.);
300 double _d_u = 0;
301 if (u >= 1.e-10) {
302 const double ue = ::std::exp(-1 / u);
303 const double us = ::std::sqrt(u);
304 double _t3;
305 double _d_ue = 0;
306 double _d_us = 0;
307 double denlan = _const0 * (ue / us) * (1 + (a1[0] + (a1[1] + a1[2] * u) * u) * u);
308 _d_denlan += d_out / xi;
309 *d_xi += d_out * -(denlan / (xi * xi));
310 denlan = _t3;
311 double _r_d3 = _d_denlan;
312 _d_denlan -= _r_d3;
313 _d_ue += _const0 * _r_d3 * (1 + (a1[0] + (a1[1] + a1[2] * u) * u) * u) / us;
314 double _r5 = _const0 * _r_d3 * (1 + (a1[0] + (a1[1] + a1[2] * u) * u) * u) * -(ue / (us * us));
315 _d_us += _r5;
316 _d_u += a1[2] * _const0 * (ue / us) * _r_d3 * u * u;
317 _d_u += (a1[1] + a1[2] * u) * _const0 * (ue / us) * _r_d3 * u;
318 _d_u += (a1[0] + (a1[1] + a1[2] * u) * u) * _const0 * (ue / us) * _r_d3;
319 double _r_d2 = _d_us;
320 _d_us -= _r_d2;
321 double _r4 = 0;
322 _r4 += _r_d2 * clad::custom_derivatives::sqrt_pushforward(u, 1.).pushforward;
323 _d_u += _r4;
324 double _r_d1 = _d_ue;
325 _d_ue -= _r_d1;
326 double _r2 = 0;
327 _r2 += _r_d1 * ::std::exp(-1 / u);
328 double _r3 = _r2 * -(-1 / (u * u));
329 _d_u += _r3;
330 }
331 double _r_d0 = _d_u;
332 _d_u -= _r_d0;
333 double _r1 = 0;
334 _r1 += _r_d0 * ::std::exp(v + 1.);
335 _d_v += _r1;
336 } else if (v < -1) {
337 double _t4;
338 double u = ::std::exp(-v - 1);
339 double _d_u = 0;
340 double _t5;
341 double _t8 = ::std::exp(-u);
342 double _t7 = ::std::sqrt(u);
343 double _t6 = (q1[0] + (q1[1] + (q1[2] + (q1[3] + q1[4] * v) * v) * v) * v);
344 double denlan = _t8 * _t7 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) / _t6;
345 _d_denlan += d_out / xi;
346 *d_xi += d_out * -(denlan / (xi * xi));
347 denlan = _t5;
348 double _r_d5 = _d_denlan;
349 _d_denlan -= _r_d5;
350 double _r7 = 0;
351 _r7 += _r_d5 / _t6 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) * _t7 * ::std::exp(-u);
352 _d_u += -_r7;
353 double _r8 = 0;
354 _r8 += _t8 * _r_d5 / _t6 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) *
355 clad::custom_derivatives::sqrt_pushforward(u, 1.).pushforward;
356 _d_u += _r8;
357 _d_v += p1[4] * _t8 * _t7 * _r_d5 / _t6 * v * v * v;
358 _d_v += (p1[3] + p1[4] * v) * _t8 * _t7 * _r_d5 / _t6 * v * v;
359 _d_v += (p1[2] + (p1[3] + p1[4] * v) * v) * _t8 * _t7 * _r_d5 / _t6 * v;
360 _d_v += (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * _t8 * _t7 * _r_d5 / _t6;
361 double _r9 = _r_d5 * -(_t8 * _t7 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) / (_t6 * _t6));
362 _d_v += q1[4] * _r9 * v * v * v;
363 _d_v += (q1[3] + q1[4] * v) * _r9 * v * v;
364 _d_v += (q1[2] + (q1[3] + q1[4] * v) * v) * _r9 * v;
365 _d_v += (q1[1] + (q1[2] + (q1[3] + q1[4] * v) * v) * v) * _r9;
366 u = _t4;
367 double _r_d4 = _d_u;
368 _d_u -= _r_d4;
369 double _r6 = 0;
370 _r6 += _r_d4 * ::std::exp(-v - 1);
371 _d_v += -_r6;
372 } else if (v < 1) {
373 double _t9;
374 double _t10 = (q2[0] + (q2[1] + (q2[2] + (q2[3] + q2[4] * v) * v) * v) * v);
375 double denlan = (p2[0] + (p2[1] + (p2[2] + (p2[3] + p2[4] * v) * v) * v) * v) / _t10;
376 _d_denlan += d_out / xi;
377 *d_xi += d_out * -(denlan / (xi * xi));
378 denlan = _t9;
379 double _r_d6 = _d_denlan;
380 _d_denlan -= _r_d6;
381 _d_v += p2[4] * _r_d6 / _t10 * v * v * v;
382 _d_v += (p2[3] + p2[4] * v) * _r_d6 / _t10 * v * v;
383 _d_v += (p2[2] + (p2[3] + p2[4] * v) * v) * _r_d6 / _t10 * v;
384 _d_v += (p2[1] + (p2[2] + (p2[3] + p2[4] * v) * v) * v) * _r_d6 / _t10;
385 double _r10 = _r_d6 * -((p2[0] + (p2[1] + (p2[2] + (p2[3] + p2[4] * v) * v) * v) * v) / (_t10 * _t10));
386 _d_v += q2[4] * _r10 * v * v * v;
387 _d_v += (q2[3] + q2[4] * v) * _r10 * v * v;
388 _d_v += (q2[2] + (q2[3] + q2[4] * v) * v) * _r10 * v;
389 _d_v += (q2[1] + (q2[2] + (q2[3] + q2[4] * v) * v) * v) * _r10;
390 } else if (v < 5) {
391 double _t11;
392 double _t12 = (q3[0] + (q3[1] + (q3[2] + (q3[3] + q3[4] * v) * v) * v) * v);
393 double denlan = (p3[0] + (p3[1] + (p3[2] + (p3[3] + p3[4] * v) * v) * v) * v) / _t12;
394 _d_denlan += d_out / xi;
395 *d_xi += d_out * -(denlan / (xi * xi));
396 denlan = _t11;
397 double _r_d7 = _d_denlan;
398 _d_denlan -= _r_d7;
399 _d_v += p3[4] * _r_d7 / _t12 * v * v * v;
400 _d_v += (p3[3] + p3[4] * v) * _r_d7 / _t12 * v * v;
401 _d_v += (p3[2] + (p3[3] + p3[4] * v) * v) * _r_d7 / _t12 * v;
402 _d_v += (p3[1] + (p3[2] + (p3[3] + p3[4] * v) * v) * v) * _r_d7 / _t12;
403 double _r11 = _r_d7 * -((p3[0] + (p3[1] + (p3[2] + (p3[3] + p3[4] * v) * v) * v) * v) / (_t12 * _t12));
404 _d_v += q3[4] * _r11 * v * v * v;
405 _d_v += (q3[3] + q3[4] * v) * _r11 * v * v;
406 _d_v += (q3[2] + (q3[3] + q3[4] * v) * v) * _r11 * v;
407 _d_v += (q3[1] + (q3[2] + (q3[3] + q3[4] * v) * v) * v) * _r11;
408 } else if (v < 12) {
409 double u = 1 / v;
410 double _d_u = 0;
411 double _t14;
412 double _t15 = (q4[0] + (q4[1] + (q4[2] + (q4[3] + q4[4] * u) * u) * u) * u);
413 double denlan = u * u * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u) / _t15;
414 _d_denlan += d_out / xi;
415 *d_xi += d_out * -(denlan / (xi * xi));
416 denlan = _t14;
417 double _r_d9 = _d_denlan;
418 _d_denlan -= _r_d9;
419 _d_u += _r_d9 / _t15 * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u) * u;
420 _d_u += u * _r_d9 / _t15 * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u);
421 _d_u += p4[4] * u * u * _r_d9 / _t15 * u * u * u;
422 _d_u += (p4[3] + p4[4] * u) * u * u * _r_d9 / _t15 * u * u;
423 _d_u += (p4[2] + (p4[3] + p4[4] * u) * u) * u * u * _r_d9 / _t15 * u;
424 _d_u += (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u * u * _r_d9 / _t15;
425 double _r13 = _r_d9 * -(u * u * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u) * u) * u) * u) / (_t15 * _t15));
426 _d_u += q4[4] * _r13 * u * u * u;
427 _d_u += (q4[3] + q4[4] * u) * _r13 * u * u;
428 _d_u += (q4[2] + (q4[3] + q4[4] * u) * u) * _r13 * u;
429 _d_u += (q4[1] + (q4[2] + (q4[3] + q4[4] * u) * u) * u) * _r13;
430 double _r_d8 = _d_u;
431 _d_u -= _r_d8;
432 double _r12 = _r_d8 * -(1 / (v * v));
433 _d_v += _r12;
434 } else if (v < 50) {
435 double u = 1 / v;
436 double _d_u = 0;
437 double _t17;
438 double _t18 = (q5[0] + (q5[1] + (q5[2] + (q5[3] + q5[4] * u) * u) * u) * u);
439 double denlan = u * u * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u) / _t18;
440 _d_denlan += d_out / xi;
441 *d_xi += d_out * -(denlan / (xi * xi));
442 denlan = _t17;
443 double _r_d11 = _d_denlan;
444 _d_denlan -= _r_d11;
445 _d_u += _r_d11 / _t18 * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u) * u;
446 _d_u += u * _r_d11 / _t18 * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u);
447 _d_u += p5[4] * u * u * _r_d11 / _t18 * u * u * u;
448 _d_u += (p5[3] + p5[4] * u) * u * u * _r_d11 / _t18 * u * u;
449 _d_u += (p5[2] + (p5[3] + p5[4] * u) * u) * u * u * _r_d11 / _t18 * u;
450 _d_u += (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u * u * _r_d11 / _t18;
451 double _r15 = _r_d11 * -(u * u * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u) * u) * u) * u) / (_t18 * _t18));
452 _d_u += q5[4] * _r15 * u * u * u;
453 _d_u += (q5[3] + q5[4] * u) * _r15 * u * u;
454 _d_u += (q5[2] + (q5[3] + q5[4] * u) * u) * _r15 * u;
455 _d_u += (q5[1] + (q5[2] + (q5[3] + q5[4] * u) * u) * u) * _r15;
456 double _r_d10 = _d_u;
457 _d_u -= _r_d10;
458 double _r14 = _r_d10 * -(1 / (v * v));
459 _d_v += _r14;
460 } else if (v < 300) {
461 double _t19;
462 double u = 1 / v;
463 double _d_u = 0;
464 double _t20;
465 double _t21 = (q6[0] + (q6[1] + (q6[2] + (q6[3] + q6[4] * u) * u) * u) * u);
466 double denlan = u * u * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u) / _t21;
467 _d_denlan += d_out / xi;
468 *d_xi += d_out * -(denlan / (xi * xi));
469 denlan = _t20;
470 double _r_d13 = _d_denlan;
471 _d_denlan -= _r_d13;
472 _d_u += _r_d13 / _t21 * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u) * u;
473 _d_u += u * _r_d13 / _t21 * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u);
474 _d_u += p6[4] * u * u * _r_d13 / _t21 * u * u * u;
475 _d_u += (p6[3] + p6[4] * u) * u * u * _r_d13 / _t21 * u * u;
476 _d_u += (p6[2] + (p6[3] + p6[4] * u) * u) * u * u * _r_d13 / _t21 * u;
477 _d_u += (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u * u * _r_d13 / _t21;
478 double _r17 = _r_d13 * -(u * u * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u) * u) * u) * u) / (_t21 * _t21));
479 _d_u += q6[4] * _r17 * u * u * u;
480 _d_u += (q6[3] + q6[4] * u) * _r17 * u * u;
481 _d_u += (q6[2] + (q6[3] + q6[4] * u) * u) * _r17 * u;
482 _d_u += (q6[1] + (q6[2] + (q6[3] + q6[4] * u) * u) * u) * _r17;
483 u = _t19;
484 double _r_d12 = _d_u;
485 _d_u -= _r_d12;
486 double _r16 = _r_d12 * -(1 / (v * v));
487 _d_v += _r16;
488 } else {
489 double _t22;
490 double _t25 = ::std::log(v);
491 double _t24 = (v + 1);
492 double _t23 = (v - v * _t25 / _t24);
493 double u = 1 / _t23;
494 double _d_u = 0;
495 double _t26;
496 double denlan = u * u * (1 + (a2[0] + a2[1] * u) * u);
497 _d_denlan += d_out / xi;
498 *d_xi += d_out * -(denlan / (xi * xi));
499 denlan = _t26;
500 double _r_d15 = _d_denlan;
501 _d_denlan -= _r_d15;
502 _d_u += _r_d15 * (1 + (a2[0] + a2[1] * u) * u) * u;
503 _d_u += u * _r_d15 * (1 + (a2[0] + a2[1] * u) * u);
504 _d_u += a2[1] * u * u * _r_d15 * u;
505 _d_u += (a2[0] + a2[1] * u) * u * u * _r_d15;
506 u = _t22;
507 double _r_d14 = _d_u;
508 _d_u -= _r_d14;
509 double _r18 = _r_d14 * -(1 / (_t23 * _t23));
510 _d_v += _r18;
511 _d_v += -_r18 / _t24 * _t25;
512 double _r19 = 0;
513 _r19 += v * -_r18 / _t24 / v;
514 _d_v += _r19;
515 double _r20 = -_r18 * -(v * _t25 / (_t24 * _t24));
516 _d_v += _r20;
517 }
518 *d_x += _d_v / xi;
519 *d_x0 += -_d_v / xi;
520 double _r0 = _d_v * -((x - x0) / (xi * xi));
521 *d_xi += _r0;
522}
523
524inline void landau_cdf_pullback(double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
525{
526 // clang-format off
527 static double p1[5] = {0.2514091491e+0,-0.6250580444e-1, 0.1458381230e-1,-0.2108817737e-2, 0.7411247290e-3};
528 static double q1[5] = {1.0 ,-0.5571175625e-2, 0.6225310236e-1,-0.3137378427e-2, 0.1931496439e-2};
529
530 static double p2[4] = {0.2868328584e+0, 0.3564363231e+0, 0.1523518695e+0, 0.2251304883e-1};
531 static double q2[4] = {1.0 , 0.6191136137e+0, 0.1720721448e+0, 0.2278594771e-1};
532
533 static double p3[4] = {0.2868329066e+0, 0.3003828436e+0, 0.9950951941e-1, 0.8733827185e-2};
534 static double q3[4] = {1.0 , 0.4237190502e+0, 0.1095631512e+0, 0.8693851567e-2};
535
536 static double p4[4] = {0.1000351630e+1, 0.4503592498e+1, 0.1085883880e+2, 0.7536052269e+1};
537 static double q4[4] = {1.0 , 0.5539969678e+1, 0.1933581111e+2, 0.2721321508e+2};
538
539 static double p5[4] = {0.1000006517e+1, 0.4909414111e+2, 0.8505544753e+2, 0.1532153455e+3};
540 static double q5[4] = {1.0 , 0.5009928881e+2, 0.1399819104e+3, 0.4200002909e+3};
541
542 static double p6[4] = {0.1000000983e+1, 0.1329868456e+3, 0.9162149244e+3,-0.9605054274e+3};
543 static double q6[4] = {1.0 , 0.1339887843e+3, 0.1055990413e+4, 0.5532224619e+3};
544
545 static double a1[4] = {0 ,-0.4583333333e+0, 0.6675347222e+0,-0.1641741416e+1};
546 static double a2[4] = {0 , 1.0 ,-0.4227843351e+0,-0.2043403138e+1};
547 // clang-format on
548
549 const double v = (x - x0) / xi;
550 double _d_v = 0;
551 if (v < -5.5) {
552 double _d_u = 0;
553 const double _const0 = 0.3989422803;
554 double u = ::std::exp(v + 1);
555 double _t3 = ::std::exp(-1. / u);
556 double _t2 = ::std::sqrt(u);
557 double _r2 = 0;
558 _r2 += _const0 * d_out * (1 + (a1[1] + (a1[2] + a1[3] * u) * u) * u) * _t2 * ::std::exp(-1. / u);
559 double _r3 = _r2 * -(-1. / (u * u));
560 _d_u += _r3;
561 double _r4 = 0;
562 _r4 += _const0 * _t3 * d_out * (1 + (a1[1] + (a1[2] + a1[3] * u) * u) * u) *
563 clad::custom_derivatives::sqrt_pushforward(u, 1.).pushforward;
564 _d_u += _r4;
565 _d_u += a1[3] * _const0 * _t3 * _t2 * d_out * u * u;
566 _d_u += (a1[2] + a1[3] * u) * _const0 * _t3 * _t2 * d_out * u;
567 _d_u += (a1[1] + (a1[2] + a1[3] * u) * u) * _const0 * _t3 * _t2 * d_out;
568 _d_v += _d_u * ::std::exp(v + 1);
569 } else if (v < -1) {
570 double _d_u = 0;
571 double u = ::std::exp(-v - 1);
572 double _t8 = ::std::exp(-u);
573 double _t7 = ::std::sqrt(u);
574 double _t6 = (q1[0] + (q1[1] + (q1[2] + (q1[3] + q1[4] * v) * v) * v) * v);
575 double _r6 = 0;
576 _r6 += d_out / _t6 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) / _t7 * ::std::exp(-u);
577 _d_u += -_r6;
578 double _r7 = d_out / _t6 * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) * -(_t8 / (_t7 * _t7));
579 double _r8 = 0;
580 _r8 += _r7 * clad::custom_derivatives::sqrt_pushforward(u, 1.).pushforward;
581 _d_u += _r8;
582 _d_v += p1[4] * (_t8 / _t7) * d_out / _t6 * v * v * v;
583 _d_v += (p1[3] + p1[4] * v) * (_t8 / _t7) * d_out / _t6 * v * v;
584 _d_v += (p1[2] + (p1[3] + p1[4] * v) * v) * (_t8 / _t7) * d_out / _t6 * v;
585 _d_v += (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * (_t8 / _t7) * d_out / _t6;
586 double _r9 = d_out * -((_t8 / _t7) * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[4] * v) * v) * v) * v) / (_t6 * _t6));
587 _d_v += q1[4] * _r9 * v * v * v;
588 _d_v += (q1[3] + q1[4] * v) * _r9 * v * v;
589 _d_v += (q1[2] + (q1[3] + q1[4] * v) * v) * _r9 * v;
590 _d_v += (q1[1] + (q1[2] + (q1[3] + q1[4] * v) * v) * v) * _r9;
591 _d_v += -_d_u * ::std::exp(-v - 1);
592 } else if (v < 1) {
593 double _t10 = (q2[0] + (q2[1] + (q2[2] + q2[3] * v) * v) * v);
594 _d_v += p2[3] * d_out / _t10 * v * v;
595 _d_v += (p2[2] + p2[3] * v) * d_out / _t10 * v;
596 _d_v += (p2[1] + (p2[2] + p2[3] * v) * v) * d_out / _t10;
597 double _r10 = d_out * -((p2[0] + (p2[1] + (p2[2] + p2[3] * v) * v) * v) / (_t10 * _t10));
598 _d_v += q2[3] * _r10 * v * v;
599 _d_v += (q2[2] + q2[3] * v) * _r10 * v;
600 _d_v += (q2[1] + (q2[2] + q2[3] * v) * v) * _r10;
601 } else if (v < 4) {
602 double _t12 = (q3[0] + (q3[1] + (q3[2] + q3[3] * v) * v) * v);
603 _d_v += p3[3] * d_out / _t12 * v * v;
604 _d_v += (p3[2] + p3[3] * v) * d_out / _t12 * v;
605 _d_v += (p3[1] + (p3[2] + p3[3] * v) * v) * d_out / _t12;
606 double _r11 = d_out * -((p3[0] + (p3[1] + (p3[2] + p3[3] * v) * v) * v) / (_t12 * _t12));
607 _d_v += q3[3] * _r11 * v * v;
608 _d_v += (q3[2] + q3[3] * v) * _r11 * v;
609 _d_v += (q3[1] + (q3[2] + q3[3] * v) * v) * _r11;
610 } else if (v < 12) {
611 double _d_u = 0;
612 double u = 1. / v;
613 double _t15 = (q4[0] + (q4[1] + (q4[2] + q4[3] * u) * u) * u);
614 _d_u += p4[3] * d_out / _t15 * u * u;
615 _d_u += (p4[2] + p4[3] * u) * d_out / _t15 * u;
616 _d_u += (p4[1] + (p4[2] + p4[3] * u) * u) * d_out / _t15;
617 double _r13 = d_out * -((p4[0] + (p4[1] + (p4[2] + p4[3] * u) * u) * u) / (_t15 * _t15));
618 _d_u += q4[3] * _r13 * u * u;
619 _d_u += (q4[2] + q4[3] * u) * _r13 * u;
620 _d_u += (q4[1] + (q4[2] + q4[3] * u) * u) * _r13;
621 double _r12 = _d_u * -(1. / (v * v));
622 _d_v += _r12;
623 } else if (v < 50) {
624 double _d_u = 0;
625 double u = 1. / v;
626 double _t18 = (q5[0] + (q5[1] + (q5[2] + q5[3] * u) * u) * u);
627 _d_u += p5[3] * d_out / _t18 * u * u;
628 _d_u += (p5[2] + p5[3] * u) * d_out / _t18 * u;
629 _d_u += (p5[1] + (p5[2] + p5[3] * u) * u) * d_out / _t18;
630 double _r15 = d_out * -((p5[0] + (p5[1] + (p5[2] + p5[3] * u) * u) * u) / (_t18 * _t18));
631 _d_u += q5[3] * _r15 * u * u;
632 _d_u += (q5[2] + q5[3] * u) * _r15 * u;
633 _d_u += (q5[1] + (q5[2] + q5[3] * u) * u) * _r15;
634 double _r14 = _d_u * -(1. / (v * v));
635 _d_v += _r14;
636 } else if (v < 300) {
637 double _d_u = 0;
638 double u = 1. / v;
639 double _t21 = (q6[0] + (q6[1] + (q6[2] + q6[3] * u) * u) * u);
640 _d_u += p6[3] * d_out / _t21 * u * u;
641 _d_u += (p6[2] + p6[3] * u) * d_out / _t21 * u;
642 _d_u += (p6[1] + (p6[2] + p6[3] * u) * u) * d_out / _t21;
643 double _r17 = d_out * -((p6[0] + (p6[1] + (p6[2] + p6[3] * u) * u) * u) / (_t21 * _t21));
644 _d_u += q6[3] * _r17 * u * u;
645 _d_u += (q6[2] + q6[3] * u) * _r17 * u;
646 _d_u += (q6[1] + (q6[2] + q6[3] * u) * u) * _r17;
647 double _r16 = _d_u * -(1. / (v * v));
648 _d_v += _r16;
649 } else {
650 double _d_u = 0;
651 double _t25 = ::std::log(v);
652 double _t24 = (v + 1);
653 double _t23 = (v - v * _t25 / _t24);
654 double u = 1. / _t23;
655 double _t26;
656 _d_u += a2[3] * -d_out * u * u;
657 _d_u += (a2[2] + a2[3] * u) * -d_out * u;
658 _d_u += (a2[1] + (a2[2] + a2[3] * u) * u) * -d_out;
659 double _r18 = _d_u * -(1. / (_t23 * _t23));
660 _d_v += _r18;
661 _d_v += -_r18 / _t24 * _t25;
662 double _r19 = 0;
663 _r19 += v * -_r18 / _t24 / v;
664 _d_v += _r19;
665 double _r20 = -_r18 * -(v * _t25 / (_t24 * _t24));
666 _d_v += _r20;
667 }
668
669 *d_x += _d_v / xi;
670 *d_x0 += -_d_v / xi;
671 *d_xi += _d_v * -((x - x0) / (xi * xi));
672}
673
674#ifdef R__HAS_MATHMORE
675
676inline void inc_gamma_c_pullback(double a, double x, double _d_y, double *_d_a, double *_d_x);
677
678inline void inc_gamma_pullback(double a, double x, double _d_y, double *_d_a, double *_d_x)
679{
680 // Synced with SpecFuncCephes.h
681 constexpr double kMACHEP = 1.11022302462515654042363166809e-16;
682 constexpr double kMAXLOG = 709.782712893383973096206318587;
683 constexpr double kMINLOG = -708.396418532264078748994506896;
684 constexpr double kMAXSTIR = 108.116855767857671821730036754;
685 constexpr double kMAXLGM = 2.556348e305;
686 constexpr double kBig = 4.503599627370496e15;
687 constexpr double kBiginv = 2.22044604925031308085e-16;
688
689 double _d_ans = 0, _d_ax = 0, _d_c = 0, _d_r = 0;
690 double _t1;
691 double _t2;
692 double _t3;
693 double _t4;
694 double _t5;
695 clad::tape<double> _t7 = {};
696 clad::tape<double> _t8 = {};
697 clad::tape<double> _t9 = {};
698 double ans, ax, c, r;
699 if (a <= 0)
700 return;
701 if (x <= 0)
702 return;
703 if ((x > 1.) && (x > a)) {
704 double _r0 = 0;
705 double _r1 = 0;
706 inc_gamma_c_pullback(a, x, -_d_y, &_r0, &_r1);
707 *_d_a += _r0;
708 *_d_x += _r1;
709 return;
710 }
711 _t1 = ::std::log(x);
712 ax = a * _t1 - x - ::std::lgamma(a);
713 if (ax < -kMAXLOG) {
714 *_d_x += (a * _d_ax / x) - _d_ax;
715 *_d_a += _d_ax * (_t1 - ::ROOT::Math::digamma(a)); // numerical_diff::forward_central_difference(::std::lgamma, a, 0, 0, a);
716 _d_ax = 0.;
717 return;
718 }
719 _t2 = ax;
720 ax = ::std::exp(ax);
721 _t3 = r;
722 r = a;
723 _t4 = c;
724 c = 1.;
725 _t5 = ans;
726 ans = 1.;
727 unsigned long _t6 = 0;
728 do {
729 _t6++;
730 clad::push(_t7, r);
731 r += 1.;
732 clad::push(_t8, c);
733 c *= x / r;
734 clad::push(_t9, ans);
735 ans += c;
736 } while (c / ans > kMACHEP);
737 {
738 _d_ans += _d_y / a * ax;
739 _d_ax += ans * _d_y / a;
740 double _r6 = _d_y * -(ans * ax / (a * a));
741 *_d_a += _r6;
742 }
743 do {
744 {
745 {
746 ans = clad::pop(_t9);
747 double _r_d7 = _d_ans;
748 _d_c += _r_d7;
749 }
750 {
751 c = clad::pop(_t8);
752 double _r_d6 = _d_c;
753 _d_c -= _r_d6;
754 _d_c += _r_d6 * x / r;
755 *_d_x += c * _r_d6 / r;
756 double _r5 = c * _r_d6 * -(x / (r * r));
757 _d_r += _r5;
758 }
759 {
760 r = clad::pop(_t7);
761 double _r_d5 = _d_r;
762 }
763 }
764 _t6--;
765 } while (_t6);
766 {
767 ans = _t5;
768 double _r_d4 = _d_ans;
769 _d_ans -= _r_d4;
770 }
771 {
772 c = _t4;
773 double _r_d3 = _d_c;
774 _d_c -= _r_d3;
775 }
776 {
777 r = _t3;
778 double _r_d2 = _d_r;
779 _d_r -= _r_d2;
780 *_d_a += _r_d2;
781 }
782 {
783 ax = _t2;
784 double _r_d1 = _d_ax;
785 _d_ax -= _r_d1;
786 double _r4 = 0;
787 _r4 += _r_d1 * ::std::exp(ax);
788 _d_ax += _r4;
789 }
790 {
791 *_d_x += (a * _d_ax / x) - _d_ax;
792 *_d_a += _d_ax * (_t1 - ::ROOT::Math::digamma(a)); // numerical_diff::forward_central_difference(::std::lgamma, a, 0, 0, a);
793 _d_ax = 0.;
794 }
795}
796
797inline void inc_gamma_c_pullback(double a, double x, double _d_y, double *_d_a, double *_d_x)
798{
799 // Synced with SpecFuncCephes.h
800 constexpr double kMACHEP = 1.11022302462515654042363166809e-16;
801 constexpr double kMAXLOG = 709.782712893383973096206318587;
802 constexpr double kMINLOG = -708.396418532264078748994506896;
803 constexpr double kMAXSTIR = 108.116855767857671821730036754;
804 constexpr double kMAXLGM = 2.556348e305;
805 constexpr double kBig = 4.503599627370496e15;
806 constexpr double kBiginv = 2.22044604925031308085e-16;
807
808 double _d_ans = 0, _d_ax = 0, _d_c = 0, _d_yc = 0, _d_r = 0, _d_t = 0, _d_y0 = 0, _d_z = 0;
809 double _d_pk = 0, _d_pkm1 = 0, _d_pkm2 = 0, _d_qk = 0, _d_qkm1 = 0, _d_qkm2 = 0;
810 double _t1;
811 double _t2;
812 double _t3;
813 double _t4;
814 double _t5;
815 double _t6;
816 double _t7;
817 double _t8;
818 double _t9;
819 double _t10;
820 unsigned long _t11;
821 clad::tape<double> _t12 = {};
822 clad::tape<double> _t13 = {};
823 clad::tape<double> _t14 = {};
824 clad::tape<double> _t15 = {};
825 clad::tape<double> _t16 = {};
826 clad::tape<double> _t17 = {};
827 clad::tape<double> _t19 = {};
828 clad::tape<double> _t20 = {};
829 clad::tape<double> _t21 = {};
830 clad::tape<double> _t22 = {};
831 clad::tape<double> _t23 = {};
832 clad::tape<double> _t24 = {};
833 clad::tape<double> _t25 = {};
834 clad::tape<double> _t26 = {};
835 clad::tape<double> _t27 = {};
836 clad::tape<bool> _t29 = {};
837 clad::tape<double> _t30 = {};
838 clad::tape<double> _t31 = {};
839 clad::tape<double> _t32 = {};
840 clad::tape<double> _t33 = {};
841 double ans, ax, c, yc, r, t, y, z;
842 double pk, pkm1, pkm2, qk, qkm1, qkm2;
843 if (a <= 0)
844 return;
845 if (x <= 0)
846 return;
847 if ((x < 1.) || (x < a)) {
848 double _r0 = 0;
849 double _r1 = 0;
850 inc_gamma_pullback(a, x, -_d_y, &_r0, &_r1);
851 *_d_a += _r0;
852 *_d_x += _r1;
853 return;
854 }
855 _t1 = ::std::log(x);
856 ax = a * _t1 - x - ::std::lgamma(a);
857 if (ax < -kMAXLOG) {
858 *_d_x += a * _d_ax / x - _d_ax;
859 *_d_a += _d_ax * (_t1 -::ROOT::Math::digamma(a)); // numerical_diff::forward_central_difference(::std::lgamma, a, 0, 0, a);
860 _d_ax = 0.;
861 return;
862 }
863 _t2 = ax;
864 ax = ::std::exp(ax);
865 _t3 = y;
866 y = 1. - a;
867 _t4 = z;
868 z = x + y + 1.;
869 _t5 = c;
870 c = 0.;
871 _t6 = pkm2;
872 pkm2 = 1.;
873 _t7 = qkm2;
874 qkm2 = x;
875 _t8 = pkm1;
876 pkm1 = x + 1.;
877 _t9 = qkm1;
878 qkm1 = z * x;
879 _t10 = ans;
880 ans = pkm1 / qkm1;
881 _t11 = 0;
882 do {
883 _t11++;
884 clad::push(_t12, c);
885 c += 1.;
886 clad::push(_t13, y);
887 y += 1.;
888 clad::push(_t14, z);
889 z += 2.;
890 clad::push(_t15, yc);
891 yc = y * c;
892 clad::push(_t16, pk);
893 pk = pkm1 * z - pkm2 * yc;
894 clad::push(_t17, qk);
895 qk = qkm1 * z - qkm2 * yc;
896 double _t18 = qk;
897 {
898 if (_t18) {
899 clad::push(_t20, r);
900 r = pk / qk;
901 clad::push(_t21, t);
902 t = ::std::abs((ans - r) / r);
903 clad::push(_t22, ans);
904 ans = r;
905 } else {
906 clad::push(_t23, t);
907 t = 1.;
908 }
909 clad::push(_t19, _t18);
910 }
911 clad::push(_t24, pkm2);
912 pkm2 = pkm1;
913 clad::push(_t25, pkm1);
914 pkm1 = pk;
915 clad::push(_t26, qkm2);
916 qkm2 = qkm1;
917 clad::push(_t27, qkm1);
918 qkm1 = qk;
919 bool _t28 = ::std::abs(pk) > kBig;
920 {
921 if (_t28) {
922 clad::push(_t30, pkm2);
923 pkm2 *= kBiginv;
924 clad::push(_t31, pkm1);
925 pkm1 *= kBiginv;
926 clad::push(_t32, qkm2);
927 qkm2 *= kBiginv;
928 clad::push(_t33, qkm1);
929 qkm1 *= kBiginv;
930 }
931 clad::push(_t29, _t28);
932 }
933 } while (t > kMACHEP);
934 {
935 _d_ans += _d_y * ax;
936 _d_ax += ans * _d_y;
937 }
938 do {
939 {
940 if (clad::pop(_t29)) {
941 {
942 qkm1 = clad::pop(_t33);
943 double _r_d27 = _d_qkm1;
944 _d_qkm1 -= _r_d27;
945 _d_qkm1 += _r_d27 * kBiginv;
946 }
947 {
948 qkm2 = clad::pop(_t32);
949 double _r_d26 = _d_qkm2;
950 _d_qkm2 -= _r_d26;
951 _d_qkm2 += _r_d26 * kBiginv;
952 }
953 {
954 pkm1 = clad::pop(_t31);
955 double _r_d25 = _d_pkm1;
956 _d_pkm1 -= _r_d25;
957 _d_pkm1 += _r_d25 * kBiginv;
958 }
959 {
960 pkm2 = clad::pop(_t30);
961 double _r_d24 = _d_pkm2;
962 _d_pkm2 -= _r_d24;
963 _d_pkm2 += _r_d24 * kBiginv;
964 }
965 }
966 {
967 qkm1 = clad::pop(_t27);
968 double _r_d23 = _d_qkm1;
969 _d_qkm1 -= _r_d23;
970 _d_qk += _r_d23;
971 }
972 {
973 qkm2 = clad::pop(_t26);
974 double _r_d22 = _d_qkm2;
975 _d_qkm2 -= _r_d22;
976 _d_qkm1 += _r_d22;
977 }
978 {
979 pkm1 = clad::pop(_t25);
980 double _r_d21 = _d_pkm1;
981 _d_pkm1 -= _r_d21;
982 _d_pk += _r_d21;
983 }
984 {
985 pkm2 = clad::pop(_t24);
986 double _r_d20 = _d_pkm2;
987 _d_pkm2 -= _r_d20;
988 _d_pkm1 += _r_d20;
989 }
990 if (clad::pop(_t19)) {
991 {
992 ans = clad::pop(_t22);
993 double _r_d18 = _d_ans;
994 _d_ans -= _r_d18;
995 _d_r += _r_d18;
996 }
997 {
998 t = clad::pop(_t21);
999 double _r_d17 = _d_t;
1000 _d_t -= _r_d17;
1001 double _r7 = 0;
1002 _r7 += _r_d17 * clad::custom_derivatives::std::abs_pushforward((ans - r) / r, 1.).pushforward;
1003 _d_ans += _r7 / r;
1004 _d_r += -_r7 / r;
1005 double _r8 = _r7 * -((ans - r) / (r * r));
1006 _d_r += _r8;
1007 }
1008 {
1009 r = clad::pop(_t20);
1010 double _r_d16 = _d_r;
1011 _d_r -= _r_d16;
1012 _d_pk += _r_d16 / qk;
1013 double _r6 = _r_d16 * -(pk / (qk * qk));
1014 _d_qk += _r6;
1015 }
1016 } else {
1017 t = clad::pop(_t23);
1018 double _r_d19 = _d_t;
1019 _d_t -= _r_d19;
1020 }
1021 {
1022 qk = clad::pop(_t17);
1023 double _r_d15 = _d_qk;
1024 _d_qk -= _r_d15;
1025 _d_qkm1 += _r_d15 * z;
1026 _d_z += qkm1 * _r_d15;
1027 _d_qkm2 += -_r_d15 * yc;
1028 _d_yc += qkm2 * -_r_d15;
1029 }
1030 {
1031 pk = clad::pop(_t16);
1032 double _r_d14 = _d_pk;
1033 _d_pk -= _r_d14;
1034 _d_pkm1 += _r_d14 * z;
1035 _d_z += pkm1 * _r_d14;
1036 _d_pkm2 += -_r_d14 * yc;
1037 _d_yc += pkm2 * -_r_d14;
1038 }
1039 {
1040 yc = clad::pop(_t15);
1041 double _r_d13 = _d_yc;
1042 _d_yc -= _r_d13;
1043 _d_y0 += _r_d13 * c;
1044 _d_c += y * _r_d13;
1045 }
1046 {
1047 z = clad::pop(_t14);
1048 double _r_d12 = _d_z;
1049 }
1050 {
1051 y = clad::pop(_t13);
1052 double _r_d11 = _d_y0;
1053 }
1054 {
1055 c = clad::pop(_t12);
1056 double _r_d10 = _d_c;
1057 }
1058 }
1059 _t11--;
1060 } while (_t11);
1061 {
1062 ans = _t10;
1063 double _r_d9 = _d_ans;
1064 _d_ans -= _r_d9;
1065 _d_pkm1 += _r_d9 / qkm1;
1066 double _r5 = _r_d9 * -(pkm1 / (qkm1 * qkm1));
1067 _d_qkm1 += _r5;
1068 }
1069 {
1070 qkm1 = _t9;
1071 double _r_d8 = _d_qkm1;
1072 _d_qkm1 -= _r_d8;
1073 _d_z += _r_d8 * x;
1074 *_d_x += z * _r_d8;
1075 }
1076 {
1077 pkm1 = _t8;
1078 double _r_d7 = _d_pkm1;
1079 _d_pkm1 -= _r_d7;
1080 *_d_x += _r_d7;
1081 }
1082 {
1083 qkm2 = _t7;
1084 double _r_d6 = _d_qkm2;
1085 _d_qkm2 -= _r_d6;
1086 *_d_x += _r_d6;
1087 }
1088 {
1089 pkm2 = _t6;
1090 double _r_d5 = _d_pkm2;
1091 _d_pkm2 -= _r_d5;
1092 }
1093 {
1094 c = _t5;
1095 double _r_d4 = _d_c;
1096 _d_c -= _r_d4;
1097 }
1098 {
1099 z = _t4;
1100 double _r_d3 = _d_z;
1101 _d_z -= _r_d3;
1102 *_d_x += _r_d3;
1103 _d_y0 += _r_d3;
1104 }
1105 {
1106 y = _t3;
1107 double _r_d2 = _d_y0;
1108 _d_y0 -= _r_d2;
1109 *_d_a += -_r_d2;
1110 }
1111 {
1112 ax = _t2;
1113 double _r_d1 = _d_ax;
1114 _d_ax -= _r_d1;
1115 double _r4 = _r_d1 * ::std::exp(ax);
1116 _d_ax += _r4;
1117 }
1118 {
1119 *_d_x += a * _d_ax / x - _d_ax;
1120 *_d_a += _d_ax * (_t1 -::ROOT::Math::digamma(a)); // numerical_diff::forward_central_difference(::std::lgamma, a, 0, 0, a);
1121 _d_ax = 0.;
1122 }
1123}
1124
1125#endif // R__HAS_MATHMORE
1126
1127} // namespace Math
1128} // namespace ROOT
1129
1130} // namespace custom_derivatives
1131} // namespace clad
1132
1133#endif // CLAD_DERIVATOR
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define kMACHEP
#define kMAXLOG
#define kMAXLGM
#define kMAXSTIR
#define kMINLOG
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
double digamma(double x)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TMath.
Definition TMathBase.h:35
Double_t CosH(Double_t)
Returns the hyperbolic cosine of x.
Definition TMath.h:616
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Definition TMath.h:636
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Double_t ASin(Double_t)
Returns the principal value of the arc sine of x, expressed in radians.
Definition TMath.h:628
Double_t Log2(Double_t x)
Returns the binary (base-2) logarithm of x.
Definition TMath.cxx:107
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Definition TMath.h:713
Double_t Erf(Double_t x)
Computation of the error function erf(x).
Definition TMath.cxx:190
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
Definition TMath.h:644
Double_t ASinH(Double_t)
Returns the area hyperbolic sine of x.
Definition TMath.cxx:67
Double_t TanH(Double_t)
Returns the hyperbolic tangent of x.
Definition TMath.h:622
Double_t ACosH(Double_t)
Returns the nonnegative area hyperbolic cosine of x.
Definition TMath.cxx:81
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Definition TMath.h:760
Double_t Erfc(Double_t x)
Computes the complementary error function erfc(x).
Definition TMath.cxx:199
Double_t Sq(Double_t x)
Returns x*x.
Definition TMath.h:660
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:666
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:725
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
constexpr Double_t Ln10()
Natural log of 10 (to convert log to ln)
Definition TMath.h:100
Double_t Hypot(Double_t x, Double_t y)
Returns sqrt(x*x + y*y)
Definition TMath.cxx:59
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
constexpr Double_t Pi()
Definition TMath.h:37
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Definition TMath.cxx:509
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:604
Double_t ATanH(Double_t)
Returns the area hyperbolic tangent of x.
Definition TMath.cxx:95
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:766
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Double_t SinH(Double_t)
Returns the hyperbolic sine of `x.
Definition TMath.h:610
void landau_pdf_pullback(double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
void landau_cdf_pullback(double x, double xi, double x0, double d_out, double *d_x, double *d_xi, double *d_x0)
ValueAndPushforward< T, T > CosH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Abs_pushforward(T x, T d_x)
void Min_pullback(T a, T b, U p, clad::array_ref< T > d_a, clad::array_ref< T > d_b)
ValueAndPushforward< T, T > Sq_pushforward(T x, T d_x)
void Max_pullback(T a, T b, U p, clad::array_ref< T > d_a, clad::array_ref< T > d_b)
ValueAndPushforward< T, T > Erf_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Erfc_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Sin_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Max_pushforward(T x, T y, T d_x, T d_y)
ValueAndPushforward< T, T > Hypot_pushforward(T x, T y, T d_x, T d_y)
ValueAndPushforward< T, T > ASinH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > ACosH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > ASin_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Cos_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Sqrt_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Tan_pushforward(T x, T d_x)
void Hypot_pullback(T x, T y, U p, clad::array_ref< T > d_x, clad::array_ref< T > d_y)
ValueAndPushforward< T, T > Power_pushforward(T x, T y, T d_x, T d_y)
void Power_pullback(T x, T y, U p, clad::array_ref< T > d_x, clad::array_ref< T > d_y)
ValueAndPushforward< T, T > Min_pushforward(T x, T y, T d_x, T d_y)
ValueAndPushforward< T, T > Log_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Log10_pushforward(T x, T d_x)
ValueAndPushforward< T, T > TanH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > ACos_pushforward(T x, T d_x)
ValueAndPushforward< T, T > SinH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Exp_pushforward(T x, T d_x)
ValueAndPushforward< T, T > Log2_pushforward(T x, T d_x)
ValueAndPushforward< T, T > ATanH_pushforward(T x, T d_x)
ValueAndPushforward< T, T > ATan_pushforward(T x, T d_x)