41template <
typename SAD>
43 for (
int i = 0; i < dim; ++i) {
44 a[i].setDiffVariable(i);
50 for (
unsigned i = 0; i < a.size(); ++i) {
51 a[i].setDiffVariable(i);
60template <
typename T,
typename TAD>
62 for (
int j = 0; j < length; ++j) {
63 for (
unsigned i = 0; i < TAD::dim; ++i) {
64 target[j*(TAD::dim)+i] = source[j].d(i);
71template<
typename T,
typename S,
template<
typename>
typename C>
75 for(std::size_t it = 0; it < input.size(); ++it) {
76 result[it] = T(input[it]);
91template<
unsigned n,
typename S>
100template<
unsigned n,
typename S,
template<
typename>
typename C>
101C<ADf<S,n>>
iniAD(
const C<S>& source) {
102 auto result = copyAs<ADf<S,n>,S,C> (source);
114template <
typename S,
typename F>
119 return f(inputAD).d(0);
127template <
unsigned sourceDIM,
typename S,
typename F>
130 using T =
decltype(f(input));
133 SAD inputAD[sourceDIM];
137 TAD resultAD = f(inputAD);
138 T* result =
new T[sourceDIM];
149template <
unsigned sourceDIM,
typename T,
typename S,
typename F>
154 SAD inputAD[sourceDIM];
157 TAD outputAD[targetDIM];
159 f(outputAD, inputAD);
The description of a algoritmic differentiation data type using the forward method – header file.
Definition of a description of a algoritmic differentiation data type using the forward method.
constexpr void setDiffVariable(unsigned iD)
void copyDerivatives(T *target, const TAD *source, int length)
Copy the derivatives from an ADf array into an array.
C< T > copyAs(const C< S > &input)
copy vector with specified typecast
void copyN(T c[], const T a[], const unsigned dim) any_platform
auto derivativeFAD(F f, const S input)
Compute derivatives of a function f: S -> T via forward AD Signature is "V f(U)" so f is expected to ...
void iniDiagonal(SAD *a, int dim)
The variables of an array are set to be the differential variables.
ADf< S, 1 > iniAD(const S source)
copy value and initialize derivative
Top level namespace for all of OpenLB.
Creates a container of type C.