-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathATL.hpp
133 lines (94 loc) · 2.59 KB
/
ATL.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: ATL.hpp
* Author: matthewsupernaw
*
* Created on November 3, 2016, 2:01 PM
*/
#ifndef ATL_HPP
#define ATL_HPP
//#include "lib/MinMax.hpp"
#include "lib/ThreadPool.hpp"
#include "lib/ACos.hpp"
//#include "lib/ad_cmath.hpp"
#include "lib/Add.hpp"
#include "lib/ASin.hpp"
#include "lib/ATan.hpp"
#include "lib/Ceil.hpp"
#include "lib/CLFAllocator.hpp"
#include "lib/Cos.hpp"
#include "lib/Cosh.hpp"
#include "lib/Divide.hpp"
#include "lib/Exp.hpp"
#include "lib/Expression.hpp"
#include "lib/Fabs.hpp"
#include "lib/Floor.hpp"
//#include "lib/FunctionMinimizer.hpp"
#include "lib/Helpers.hpp"
#include "lib/Log.hpp"
#include "lib/Log10.hpp"
//#include "lib/Matrix.hpp"
#include "lib/MinMax.hpp"
#include "lib/Multiply.hpp"
#include "lib/Platform.hpp"
#include "lib/Pow.hpp"
#include "lib/Real.hpp"
#include "lib/Serialize.hpp"
#ifdef ATL_USE_SSE
#include "lib/SIMD.hpp"
#endif
#include "lib/Sin.hpp"
#include "lib/Sinh.hpp"
#include "lib/Sqrt.hpp"
#include "lib/Subtract.hpp"
#include "lib/Tan.hpp"
#include "lib/Tanh.hpp"
#include "lib/Tape.hpp"
//#include "lib/ThreadPool.hpp"
#include "lib/Variable.hpp"
//#include "lib/Vector.hpp"
#include "lib/Optimization.hpp"
//#include "lib/Utilities/IO/StreamedDataFile.hpp"
namespace atl {
/***********************************
* Miscellaneous Functions Below *
***********************************/
/**
* Introduction
*/
/**
* Automatic Differentiation
*/
/**
* Optimization
*/
/**
* Concurrency
*/
/**
* function used to protect overflow in exp calculations.
*
* Author: Dave Fournier.
* Original implementation in ADMB.
*
* Source: http://admb-project.org/documentation/api/mfexp_8cpp_source.html
*
* @param expr
*/
template<class REAL_T, class EXPR>
inline const atl::Variable<REAL_T> mfexp(const atl::ExpressionBase<REAL_T, EXPR>& expr) {
REAL_T b = REAL_T(60.0);
if (expr.GetValue() <= b && expr.GetValue() >= REAL_T(-1) * b) {
return atl::exp(expr);
} else if (expr.GetValue() > b) {
return /*std::exp(b)*/EXP_OF_B * (REAL_T(1.) + REAL_T(2.) * (expr - b)) / (REAL_T(1.) + expr - b);
} else {
return std::exp(REAL_T(-1) * b)*(REAL_T(1.) - expr - b) / (REAL_T(1.) + REAL_T(2.) * (REAL_T(-1) * expr - b));
}
}
}
#endif /* ATL_HPP */