Logo ROOT  
Reference Guide
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
29 template <typename T>
31 return (d < 0) ? -1 : 1;
32 }
33
34 template <typename T>
36 return -1./TMath::Sqrt(1 - d * d);
37 }
38
39 template <typename T>
41 return 1. / TMath::Sqrt(d * d - 1);
42 }
43
44 template <typename T>
46 return 1. / TMath::Sqrt(1 - d * d);
47 }
48
49 template <typename T>
51 return 1. / TMath::Sqrt(d * d + 1);
52 }
53
54 template <typename T>
56 return 1. / (d * d + 1);
57 }
58
59 template <typename T>
61 return 1. / (1 - d * d);
62 }
63
64 template <typename T>
66 return -TMath::Sin(d);
67 }
68
69 template <typename T>
71 return TMath::SinH(d);
72 }
73
74 template <typename T>
76 return 2 * TMath::Exp(-d * d) / TMath::Sqrt(TMath::Pi());
77 }
78
79 template <typename T>
81 return -Erf_darg(d);
82 }
83
84 template <typename T>
86 return TMath::Exp(d);
87 }
88
89 template <typename T>
91 return x / TMath::Hypot(x, y);
92 }
93
94 template <typename T>
96 return y / TMath::Hypot(x, y);
97 }
98
99 template <typename T>
100 void Hypot_grad(T x, T y, T* result) {
101 T h = TMath::Hypot(x, y);
102 result[0] += x / h;
103 result[1] += y / h;
104 }
105
106 template <typename T>
108 return 1. / d;
109 }
110
111 template <typename T>
113 return Log_darg0(d) / TMath::Ln10();
114 }
115
116 template <typename T>
118 return Log_darg0(d) / TMath::Log(2);
119 }
120
121 template <typename T>
123 return (a >= b) ? 1 : 0;
124 }
125
126 template <typename T>
128 return (a >= b) ? 0 : 1;
129 }
130
131 template <typename T>
132 void Max_grad(T a, T b, T* result) {
133 if (a >= b)
134 result[0] += 1;
135 else
136 result[1] += 1;
137 }
138
139 template <typename T>
141 return (a <= b) ? 1 : 0;
142 }
143
144 template <typename T>
146 return (a <= b) ? 0 : 1;
147 }
148
149 template <typename T>
150 void Min_grad(T a, T b, T* result) {
151 if (a <= b)
152 result[0] += 1;
153 else
154 result[1] += 1;
155 }
156
157 template <typename T>
159 return y * TMath::Power(x, y - 1);
160 }
161
162 template <typename T>
164 return TMath::Power(x, y) * TMath::Log(x);
165 }
166
167 template <typename T>
169 T t = TMath::Power(x, y - 1);
170 result[0] += y * t;
171 result[1] += x * t * TMath::Log(x);
172 }
173
174 template <typename T>
176 return TMath::Cos(d);
177 }
178
179 template <typename T>
181 return TMath::CosH(d);
182 }
183
184 template <typename T>
186 return 2 * d;
187 }
188
189 template <typename T>
191 return 0.5 / TMath::Sqrt(d);
192 }
193
194 template <typename T>
196 return 1./ TMath::Sq(TMath::Cos(d));
197 }
198
199 template <typename T>
201 return 1./ TMath::Sq(TMath::CosH(d));
202 }
203}
204#endif // CLAD_DERIVATOR
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define h(i)
Definition: RSha256.hxx:106
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
double T(double x)
Definition: ChebyshevPol.h:34
Double_t CosH(Double_t)
Definition: TMath.h:643
Double_t Exp(Double_t x)
Definition: TMath.h:717
Double_t Log(Double_t x)
Definition: TMath.h:750
Double_t Sq(Double_t x)
Definition: TMath.h:677
Double_t Sqrt(Double_t x)
Definition: TMath.h:681
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:725
constexpr Double_t Ln10()
Natural log of 10 (to convert log to ln)
Definition: TMath.h:104
Double_t Hypot(Double_t x, Double_t y)
Definition: TMath.cxx:57
Double_t Cos(Double_t)
Definition: TMath.h:631
constexpr Double_t Pi()
Definition: TMath.h:38
Double_t Sin(Double_t)
Definition: TMath.h:627
Double_t SinH(Double_t)
Definition: TMath.h:639
Double_t ATan_darg0(T d)
Definition: CladDerivator.h:55
Double_t Erfc_darg0(T d)
Definition: CladDerivator.h:80
T Min_darg0(T a, T b)
Double_t ACosH_darg0(T d)
Definition: CladDerivator.h:40
Double_t Log10_darg0(T d)
Double_t Sqrt_darg0(T d)
void Min_grad(T a, T b, T *result)
T Power_darg0(T x, T y)
Double_t Power_grad(T x, T y, Double_t *result)
Double_t Log_darg0(T d)
Double_t SinH_darg0(T d)
Double_t Erf_darg0(T d)
Definition: CladDerivator.h:75
void Hypot_grad(T x, T y, T *result)
T Hypot_darg1(T x, T y)
Definition: CladDerivator.h:95
Double_t Tan_darg0(T d)
Double_t Exp_darg0(T d)
Definition: CladDerivator.h:85
void Max_grad(T a, T b, T *result)
Double_t ACos_darg0(T d)
Definition: CladDerivator.h:35
Double_t ASinH_darg0(T d)
Definition: CladDerivator.h:50
Double_t Log2_darg0(T d)
T Max_darg0(T a, T b)
T Min_darg1(T a, T b)
Double_t ASin_darg0(T d)
Definition: CladDerivator.h:45
Double_t ATanH_darg0(T d)
Definition: CladDerivator.h:60
Double_t Power_darg1(T x, T y)
Double_t TanH_darg0(T d)
T Max_darg1(T a, T b)
Double_t Sin_darg0(T d)
T Hypot_darg0(T x, T y)
Definition: CladDerivator.h:90
auto * a
Definition: textangle.C:12