GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
NestedAutoDiff.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
#ifndef GPR_DERIVATIVES_NESTEDAUTODIFF_H_
6
#define GPR_DERIVATIVES_NESTEDAUTODIFF_H_
7
8
#include <cmath>
9
#include <unsupported/Eigen/AutoDiff>
10
11
namespace
gpr::derivatives
{
12
13
template
<
typename
T>
14
struct
Lift
{
15
template
<
typename
Value>
16
static
T
from
(
const
Value& value)
17
{
18
return
T(value);
19
}
20
};
21
24
template
<
typename
Derivatives>
25
struct
Lift
<
Eigen
::AutoDiffScalar<Derivatives>> {
26
using
Type
= Eigen::AutoDiffScalar<Derivatives>;
27
template
<
typename
Value>
28
static
Type
from
(
const
Value& value)
29
{
30
return
Type
(
Lift<typename Type::Scalar>::from
(value));
31
}
32
};
33
34
template
<
typename
T,
typename
Value>
35
T
lift
(
const
Value& value)
36
{
37
return
Lift<T>::from
(value);
38
}
39
40
inline
double
nestedAtan2
(
double
y
,
double
x
)
41
{
42
return
std::atan2(
y
,
x
);
43
}
44
47
template
<
typename
Derivatives>
48
Eigen::AutoDiffScalar<Derivatives>
nestedAtan2
(
49
const
Eigen::AutoDiffScalar<Derivatives>&
y
,
50
const
Eigen::AutoDiffScalar<Derivatives>&
x
)
51
{
52
using
Type = Eigen::AutoDiffScalar<Derivatives>;
53
const
auto
squared =
x
.value() *
x
.value() +
y
.value() *
y
.value();
54
return
Type(
55
nestedAtan2
(
y
.value(),
x
.value()),
56
(
y
.derivatives() *
x
.value() -
x
.derivatives() *
y
.value()) / squared);
57
}
58
59
}
// namespace gpr::derivatives
60
61
#endif
// GPR_DERIVATIVES_NESTEDAUTODIFF_H_
x
@ x
Definition
Enums.h:28
y
@ y
Definition
Enums.h:28
Eigen
Definition
CountedReal.h:166
gpr::derivatives
Definition
CountedReal.h:11
gpr::derivatives::nestedAtan2
double nestedAtan2(double y, double x)
Definition
NestedAutoDiff.h:40
gpr::derivatives::lift
T lift(const Value &value)
Definition
NestedAutoDiff.h:35
gpr::derivatives::Lift< Eigen::AutoDiffScalar< Derivatives > >::from
static Type from(const Value &value)
Definition
NestedAutoDiff.h:28
gpr::derivatives::Lift< Eigen::AutoDiffScalar< Derivatives > >::Type
Eigen::AutoDiffScalar< Derivatives > Type
Definition
NestedAutoDiff.h:26
gpr::derivatives::Lift
Definition
NestedAutoDiff.h:14
gpr::derivatives::Lift::from
static T from(const Value &value)
Definition
NestedAutoDiff.h:16
gpr
derivatives
NestedAutoDiff.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf