ADMB Documentation
-a65f1c97
Main Page
Function Reference
Classes
Source Code
Related Pages
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
tools99
tiny_wrap.hpp
Go to the documentation of this file.
1
#ifndef TINY_WRAP_H
2
#define TINY_WRAP_H
3
4
//#include <df1b2fun.h>
5
6
#define TINYFUN3(FUN,par1,par2,par3) \
7
\
8
double FUN(double par1, double par2, double par3){ \
9
return FUN<double>(par1, par2, par3); \
10
} \
11
\
12
dvariable FUN(dvariable par1, dvariable par2, dvariable par3){ \
13
typedef tiny_ad::variable<1, 3> Float; \
14
Float par1##_ (value(par1), 0); \
15
Float par2##_ (value(par2), 1); \
16
Float par3##_ (value(par3), 2); \
17
Float ans=FUN(par1##_,par2##_,par3##_); \
18
dvariable y; \
19
value(y)=ans.value; \
20
tiny_vec<double, 3> der = ans.getDeriv(); \
21
AD_SET_DERIVATIVES3(y,par1,der[0],par2,der[1],par3,der[2]); \
22
return y; \
23
} \
24
\
25
dvariable FUN(prevariable par1, prevariable par2, prevariable par3){ \
26
return FUN((dvariable)par1, (dvariable)par2, (dvariable)par3); \
27
} \
28
\
29
df1b2variable FUN(df1b2variable par1, df1b2variable par2, df1b2variable par3){ \
30
typedef tiny_ad::variable<3, 3> Float; \
31
Float par1##_ (value(par1), 0); \
32
Float par2##_ (value(par2), 1); \
33
Float par3##_ (value(par3), 2); \
34
Float ans=FUN(par1##_,par2##_,par3##_); \
35
double val=ans.value.value.value; \
36
tiny_vec<double, 3> der1 = ans.value.value.getDeriv(); \
37
tiny_vec<double, 9> der2 = ans.value.getDeriv(); \
38
tiny_vec<double, 27> der3 = ans.getDeriv(); \
39
\
40
df1b2variable tmp; \
41
double * xd=par1.get_u_dot(); \
42
double * yd=par2.get_u_dot(); \
43
double * zd=par3.get_u_dot(); \
44
double * tmpd=tmp.get_u_dot(); \
45
*tmp.get_u()=val; \
46
for (unsigned int i=0;i<df1b2variable::nvar;i++){ \
47
*tmpd++ = der1[0] * *xd++ + der1[1] * *yd++ + der1[2] * *zd++; \
48
} \
49
if (!df1b2_gradlist::no_derivatives){ \
50
f1b2gradlist->write_pass1(&par1,&par2,&par3,&tmp, \
51
der1[0],der1[1],der1[2], \
52
der2[0],der2[1],der2[2],der2[4],der2[5],der2[8], \
53
der3[0],der3[1],der3[2],der3[4],der3[5],der3[8],der3[13],der3[14],der3[17],der3[26]); \
54
} \
55
return tmp; \
56
}
57
58
#define TINYFUN2(FUN,par1,par2) \
59
\
60
double FUN(double par1, double par2){ \
61
return FUN<double>(par1, par2); \
62
} \
63
\
64
dvariable FUN(dvariable par1, dvariable par2){ \
65
typedef tiny_ad::variable<1, 2> Float; \
66
Float par1##_ (value(par1), 0); \
67
Float par2##_ (value(par2), 1); \
68
Float ans=FUN(par1##_,par2##_); \
69
dvariable y; \
70
value(y)=ans.value; \
71
tiny_vec<double, 2> der = ans.getDeriv(); \
72
AD_SET_DERIVATIVES2(y,par1,der[0],par2,der[1]); \
73
return y; \
74
} \
75
\
76
dvariable FUN(prevariable par1, prevariable par2){ \
77
return FUN((dvariable)par1, (dvariable)par2); \
78
} \
79
\
80
df1b2variable FUN(df1b2variable par1, df1b2variable par2){ \
81
typedef tiny_ad::variable<3, 2> Float; \
82
Float par1##_ (value(par1), 0); \
83
Float par2##_ (value(par2), 1); \
84
Float ans=FUN(par1##_,par2##_); \
85
double val=ans.value.value.value; \
86
tiny_vec<double, 2> der1 = ans.value.value.getDeriv(); \
87
tiny_vec<double, 4> der2 = ans.value.getDeriv(); \
88
tiny_vec<double, 8> der3 = ans.getDeriv(); \
89
\
90
df1b2variable tmp; \
91
double * xd=par1.get_u_dot(); \
92
double * yd=par2.get_u_dot(); \
93
double * tmpd=tmp.get_u_dot(); \
94
*tmp.get_u()=val; \
95
for (unsigned int i=0;i<df1b2variable::nvar;i++){ \
96
*tmpd++ = der1[0] * *xd++ + der1[1] * *yd++; \
97
} \
98
if (!df1b2_gradlist::no_derivatives){ \
99
f1b2gradlist->write_pass1(&par1,&par2,&tmp, \
100
der1[0],der1[1], \
101
der2[0],der2[1],der2[3], \
102
der3[0],der3[1],der3[3],der3[7]); \
103
} \
104
return tmp; \
105
}
106
107
#define TINYFUN1(FUN,par1) \
108
\
109
double FUN(double par1){ \
110
return FUN<double>(par1); \
111
} \
112
\
113
dvariable FUN(dvariable par1){ \
114
typedef tiny_ad::variable<1,1> Float; \
115
Float par1##_ (value(par1), 0); \
116
Float ans=FUN(par1##_); \
117
dvariable y; \
118
value(y)=ans.value; \
119
tiny_vec<double, 1> der = ans.getDeriv(); \
120
AD_SET_DERIVATIVES1(y,par1,der[0]); \
121
return y; \
122
} \
123
\
124
dvariable FUN(prevariable par1){ \
125
return FUN((dvariable)par1); \
126
} \
127
\
128
df1b2variable FUN(df1b2variable par1){ \
129
typedef tiny_ad::variable<3, 1> Float; \
130
Float par1##_ (value(par1), 0); \
131
Float ans=FUN(par1##_); \
132
double val=ans.value.value.value; \
133
tiny_vec<double, 1> der1 = ans.value.value.getDeriv(); \
134
tiny_vec<double, 1> der2 = ans.value.getDeriv(); \
135
tiny_vec<double, 1> der3 = ans.getDeriv(); \
136
\
137
df1b2variable tmp; \
138
double * xd=par1.get_u_dot(); \
139
double * tmpd=tmp.get_u_dot(); \
140
*tmp.get_u()=val; \
141
for (unsigned int i=0;i<df1b2variable::nvar;i++){ \
142
*tmpd++ = der1[0] * *xd++; \
143
} \
144
if (!df1b2_gradlist::no_derivatives){ \
145
f1b2gradlist->write_pass1(&par1,&tmp,der1[0],der2[0],der3[0]); \
146
} \
147
return tmp; \
148
}
149
150
#endif
Generated on Wed Sep 7 2022 00:01:30 for ADMB Documentation by
1.8.5