Theoretica
A C++ numerical and automatic mathematical library
Loading...
Searching...
No Matches
autodiff_types.h
Go to the documentation of this file.
1
5
6#ifndef THEORETICA_AUTODIFF_TYPES_H
7#define THEORETICA_AUTODIFF_TYPES_H
8
9
10namespace theoretica {
11
12 namespace autodiff {
13
14
15 // Type traits for automatic differentiation
16
17
19 template<typename Type>
20 struct is_dual_type : std::false_type {};
21
23 template<>
24 struct is_dual_type<dual> : std::true_type {};
25
26
29 template<typename Function>
31 std::conditional_t <
33 typename _internal::return_type_or_void<Function, dual>::type
34 >::value,
35 std::true_type, std::false_type
36 >;
37
38
41 template<typename Function, typename T = bool>
43 typename std::enable_if<is_dual_func<Function>::value, T>::type;
44
45
47 template<typename Type>
48 struct is_dual2_type : std::false_type {};
49
51 template<>
52 struct is_dual2_type<dual2> : std::true_type {};
53
54
57 template<typename Function>
59 std::conditional_t <
61 typename _internal::return_type_or_void<Function, dual2>::type
62 >::value,
63 std::true_type, std::false_type
64 >;
65
66
69 template<typename Function, typename T = bool>
71 typename std::enable_if<is_dual2_func<Function>::value, T>::type;
72
73
75 template<typename Type>
76 struct is_multidual_type : std::false_type {};
77
79 template<unsigned int N>
80 struct is_multidual_type<multidual<N>> : std::true_type {};
81
84 template<typename Type, typename T = bool>
86 typename std::enable_if<is_multidual_type<Type>::value, T>::type;
87
88
93 template<typename Function, typename T = bool>
94 using enable_scalar_field = typename std::enable_if <
96 >::type;
97
98
103 template<typename Function, typename T = bool>
104 using enable_vector_field = typename std::enable_if <
107 >::value, T
108 >::type;
109
110
111 // Alias types for multivariate automatic differentiation
112
113
116 template<unsigned int N = 0>
118
121 template<unsigned int N = 0>
123
124
128
132
133
137
141
142
146
150
151
155
159 }
160}
161
162#endif
Second order dual number class.
Definition dual2.h:29
Dual number class.
Definition dual.h:28
Multidual number algebra for functions of the form .
Definition multidual.h:26
multidual< N > dreal_t
Real type for multivariate automatic differentiation (read "differential real").
Definition autodiff_types.h:117
typename std::enable_if< is_dual_func< Function >::value, T >::type enable_dual_func
Enable a certain function overload if the given type is a function taking as first argument a dual nu...
Definition autodiff_types.h:43
dvec_t< 2 > dvec2
Vector type for multivariate automatic differentiation with two-dimensional statically allocated vect...
Definition autodiff_types.h:140
dvec_t< 0 > dvec
Vector type for multivariate automatic differentiation with dynamically allocated vectors.
Definition autodiff_types.h:131
dreal_t< 4 > dreal4
Real type for multivariate automatic differentiation with four-dimensional statically allocated vecto...
Definition autodiff_types.h:154
typename std::enable_if< is_dual2_func< Function >::value, T >::type enable_dual2_func
Enable a certain function overload if the given type is a function taking as first argument a dual2 n...
Definition autodiff_types.h:71
typename std::enable_if< is_multidual_type< return_type_t< Function > >::value, T >::type enable_scalar_field
Enable a certain function overload if the given type is a Callable object corresponding to a multidua...
Definition autodiff_types.h:96
dreal_t< 0 > dreal
Real type for multivariate automatic differentiation with dynamically allocated vectors.
Definition autodiff_types.h:127
std::conditional_t< is_dual_type< typename _internal::return_type_or_void< Function, dual >::type >::value, std::true_type, std::false_type > is_dual_func
Type trait to check whether the given function takes a dual number as its first argument.
Definition autodiff_types.h:36
dreal_t< 2 > dreal2
Real type for multivariate automatic differentiation with two-dimensional statically allocated vector...
Definition autodiff_types.h:136
vec< dreal_t< N >, N > dvec_t
Vector type for multivariate automatic differentiation (read "differential vector").
Definition autodiff_types.h:122
typename std::enable_if< is_multidual_type< vector_element_t< return_type_t< Function > > >::value, T >::type enable_vector_field
Enable a certain function overload if the given type is a Callable object corresponding to a multidua...
Definition autodiff_types.h:108
typename std::enable_if< is_multidual_type< Type >::value, T >::type enable_multidual
Enable a certain function overload if the given type is an instantiation of the multidual template cl...
Definition autodiff_types.h:86
dvec_t< 3 > dvec3
Vector type for multivariate automatic differentiation with three-dimensional statically allocated ve...
Definition autodiff_types.h:149
std::conditional_t< is_dual2_type< typename _internal::return_type_or_void< Function, dual2 >::type >::value, std::true_type, std::false_type > is_dual2_func
Type trait to check whether the given function takes a dual2 number as its first argument.
Definition autodiff_types.h:64
dvec_t< 4 > dvec4
Vector type for multivariate automatic differentiation with four-dimensional statically allocated vec...
Definition autodiff_types.h:158
dreal_t< 3 > dreal3
Real type for multivariate automatic differentiation with three-dimensional statically allocated vect...
Definition autodiff_types.h:145
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
Type trait to check whether the given type is a multidual number.
Definition autodiff_types.h:48
Type trait to check whether the given type is a multidual number.
Definition autodiff_types.h:20
Type trait to check whether the given type is a multidual number.
Definition autodiff_types.h:76