1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 1998 Carnegie Mellon University |
3 |
Copyright (C) 2006 Carnegie Mellon University |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2, or (at your option) |
8 |
any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//** |
20 |
@file |
21 |
Prolog for C to be compiled and dynamically loaded to provide |
22 |
residuals and gradients to token relations. This defines the |
23 |
math functions ascend will provide after loading the |
24 |
necessary system headers. |
25 |
|
26 |
Don't put anything in this prolog which requires access to |
27 |
other ASCEND sources. This header must be shipped with the |
28 |
binary distribution in some lib directory. |
29 |
|
30 |
bintoken.c also includes this so we maintain 1 definition |
31 |
of our structs. bintoken.h must include it AFTER func.h |
32 |
in bintoken.c. |
33 |
|
34 |
@TODO Complete documentation of btprolog.h. |
35 |
|
36 |
Requires: |
37 |
#include "utilities/ascConfig.h" |
38 |
#include "instance_enum.h" |
39 |
*//* |
40 |
By Benjamin A. Allan |
41 |
Jan 7, 1998. |
42 |
Part of ASCEND |
43 |
Version: $Revision: 1.3 $ |
44 |
Version control file: $RCSfile: btprolog.h,v $ |
45 |
Date last modified: $Date: 1998/06/16 16:38:40 $ |
46 |
Last modified by: $Author: mthomas $ |
47 |
*/ |
48 |
|
49 |
#ifndef ASC_BTPROLOG_H |
50 |
#define ASC_BTPROLOG_H |
51 |
|
52 |
/** addtogroup compiler Compiler |
53 |
@{ |
54 |
*/ |
55 |
|
56 |
#ifdef ASC_BINTOKEN_H |
57 |
# include <utilities/ascConfig.h> |
58 |
# include <compiler/instance_enum.h> |
59 |
#else |
60 |
# define IS_BINTOKEN_COMPILE |
61 |
# include <ascConfig.h> |
62 |
# include <instance_enum.h> |
63 |
#endif |
64 |
|
65 |
#include <math.h> |
66 |
|
67 |
#ifndef NULL |
68 |
#ifdef __alpha |
69 |
#define NULL 0L |
70 |
#else |
71 |
#define NULL 0 |
72 |
#endif |
73 |
#endif |
74 |
|
75 |
#define BinTokenGRADIENT 0 |
76 |
#define BinTokenRESIDUAL 1 |
77 |
|
78 |
#ifdef __STDC__ |
79 |
/** Residual evaluation function pointer. F(vars,resid); */ |
80 |
typedef void (*BinTokenFPtr)(double *, double *); |
81 |
/** Gradient evaluation function pointer. G(vars,grad,resid); */ |
82 |
typedef void (*BinTokenGPtr)(double *, double *, double *); |
83 |
/** |
84 |
* F77 style interface code (if and big goto required inside). |
85 |
* S(vars,grad,resid,ForG,bindex,status); |
86 |
*/ |
87 |
typedef void (*BinTokenSPtr)(double *, double *, double *, int *, int *, int *); |
88 |
#else |
89 |
/** Residual evaluation function pointer. F(vars,resid); */ |
90 |
typedef void (*BinTokenFPtr)(); |
91 |
/** Gradient evaluation function pointer. G(vars,grad,resid); */ |
92 |
typedef void (*BinTokenGPtr)(); |
93 |
/** |
94 |
* F77 style interface code (if and big goto required inside). |
95 |
* S(vars,grad,resid,ForG,bindex,status); |
96 |
*/ |
97 |
typedef void (*BinTokenSPtr)(); |
98 |
#endif /* __STDC__ */ |
99 |
|
100 |
struct TableC { |
101 |
BinTokenFPtr F; |
102 |
BinTokenGPtr G; |
103 |
}; |
104 |
|
105 |
struct TableF { |
106 |
BinTokenSPtr S; |
107 |
}; |
108 |
|
109 |
union TableUnion { |
110 |
struct TableC c; |
111 |
struct TableF f; |
112 |
}; |
113 |
|
114 |
#ifdef __STDC__ |
115 |
ASC_DLLSPEC int ExportBinTokenCTable(struct TableC *t, int size); |
116 |
#else |
117 |
ASC_DLLSPEC int ExportBinTokenCTable(); |
118 |
#endif /* __STDC__ */ |
119 |
|
120 |
/*------------------------------ |
121 |
The following is stripped from compiler func.h. |
122 |
If a new function is introduced into ASCEND and func.h, fix this. |
123 |
*/ |
124 |
#ifndef ASC_FUNC_H |
125 |
|
126 |
# ifdef __STDC__ |
127 |
# if __STDC__ |
128 |
/* |
129 |
* stdc==1 --> erf, cbrt not defined in headers. user should link |
130 |
* against a library that does provide them. ASCEND is research |
131 |
* code: we aren't going to waste time reimplementing these basic |
132 |
* functions. |
133 |
*/ |
134 |
|
135 |
ASC_DLLSPEC double cbrt(double x); |
136 |
# ifdef HAVE_ERF |
137 |
ASC_DLLSPEC double erf(double x); |
138 |
# endif /* HAVE_ERF */ |
139 |
# endif /* __STDC__ == 1 */ |
140 |
/* |
141 |
* in the case where __STDC__ is defined but == 0, system headers |
142 |
* should provide cbrt, erf. |
143 |
*/ |
144 |
ASC_DLLSPEC int ascnintF(double x); |
145 |
ASC_DLLSPEC double dln(double x); |
146 |
ASC_DLLSPEC double dln2(double x); |
147 |
ASC_DLLSPEC double dlog10(double x); |
148 |
ASC_DLLSPEC double dlog102(double x); |
149 |
ASC_DLLSPEC double lnm(double x); |
150 |
ASC_DLLSPEC double dlnm(double x); |
151 |
ASC_DLLSPEC double dlnm2(double x); |
152 |
ASC_DLLSPEC double dtanh(double x); |
153 |
ASC_DLLSPEC double dtanh2(double x); |
154 |
ASC_DLLSPEC double arcsinh(double x); |
155 |
ASC_DLLSPEC double arccosh(double x); |
156 |
ASC_DLLSPEC double arctanh(double x); |
157 |
ASC_DLLSPEC double darcsinh(double x); |
158 |
ASC_DLLSPEC double darcsinh2(double x); |
159 |
ASC_DLLSPEC double darccosh(double x); |
160 |
ASC_DLLSPEC double darccosh2(double x); |
161 |
ASC_DLLSPEC double darctanh(double x); |
162 |
ASC_DLLSPEC double darctanh2(double x); |
163 |
ASC_DLLSPEC double sqr(double x); |
164 |
ASC_DLLSPEC double dsqr(double x); |
165 |
ASC_DLLSPEC double dsqr2(double x); |
166 |
ASC_DLLSPEC double cube(double x); |
167 |
ASC_DLLSPEC double dcube(double x); |
168 |
ASC_DLLSPEC double dcube2(double x); |
169 |
ASC_DLLSPEC double asc_ipow(double x, int y); |
170 |
ASC_DLLSPEC double asc_d1ipow(double x, int y); |
171 |
ASC_DLLSPEC double asc_d2ipow(double x, int y); |
172 |
ASC_DLLSPEC double hold(double x); |
173 |
ASC_DLLSPEC double dsqrt(double x); |
174 |
ASC_DLLSPEC double dsqrt2(double x); |
175 |
ASC_DLLSPEC double dcbrt(double x); |
176 |
ASC_DLLSPEC double dcbrt2(double x); |
177 |
ASC_DLLSPEC double dfabs(double x); |
178 |
ASC_DLLSPEC double dfabs2(double x); |
179 |
ASC_DLLSPEC double dhold(double x); |
180 |
ASC_DLLSPEC double dasin(double x); |
181 |
ASC_DLLSPEC double dasin2(double x); |
182 |
ASC_DLLSPEC double dcos(double x); |
183 |
ASC_DLLSPEC double dcos2(double x); |
184 |
ASC_DLLSPEC double dacos(double x); |
185 |
ASC_DLLSPEC double dacos2(double x); |
186 |
ASC_DLLSPEC double dtan(double x); |
187 |
ASC_DLLSPEC double dtan2(double x); |
188 |
ASC_DLLSPEC double datan(double x); |
189 |
ASC_DLLSPEC double datan2(double x); |
190 |
ASC_DLLSPEC double derf(double x); |
191 |
ASC_DLLSPEC double derf2(double x); |
192 |
|
193 |
# else /* no stdc */ |
194 |
|
195 |
ASC_DLLSPEC double cbrt(); |
196 |
# ifdef HAVE_ERF |
197 |
ASC_DLLSPEC double erf(); |
198 |
# endif /* HAVE_ERF */ |
199 |
ASC_DLLSPEC int ascnintF(); |
200 |
ASC_DLLSPEC double dln(); |
201 |
ASC_DLLSPEC double dln2(); |
202 |
ASC_DLLSPEC double dlog(); |
203 |
ASC_DLLSPEC double dlog2(); |
204 |
ASC_DLLSPEC double lnm(); |
205 |
ASC_DLLSPEC double dlnm(); |
206 |
ASC_DLLSPEC double dlnm2(); |
207 |
ASC_DLLSPEC double dtanh(); |
208 |
ASC_DLLSPEC double dtanh2(); |
209 |
ASC_DLLSPEC double arcsinh(); |
210 |
ASC_DLLSPEC double arccosh(); |
211 |
ASC_DLLSPEC double arctanh(); |
212 |
ASC_DLLSPEC double darcsinh(); |
213 |
ASC_DLLSPEC double darcsinh2(); |
214 |
ASC_DLLSPEC double darccosh(); |
215 |
ASC_DLLSPEC double darccosh2(); |
216 |
ASC_DLLSPEC double darctanh(); |
217 |
ASC_DLLSPEC double darctanh2(); |
218 |
ASC_DLLSPEC double sqr(); |
219 |
ASC_DLLSPEC double dsqr(); |
220 |
ASC_DLLSPEC double dsqr2(); |
221 |
ASC_DLLSPEC double cube(); |
222 |
ASC_DLLSPEC double dcube(); |
223 |
ASC_DLLSPEC double dcube2(); |
224 |
ASC_DLLSPEC double asc_ipow(); |
225 |
ASC_DLLSPEC double asc_d1ipow(); |
226 |
ASC_DLLSPEC double asc_d2ipow(); |
227 |
ASC_DLLSPEC double hold(); |
228 |
ASC_DLLSPEC double dsqrt(); |
229 |
ASC_DLLSPEC double dsqrt2(); |
230 |
ASC_DLLSPEC double dcbrt(); |
231 |
ASC_DLLSPEC double dcbrt2(); |
232 |
ASC_DLLSPEC double dfabs(); |
233 |
ASC_DLLSPEC double dfabs2(); |
234 |
ASC_DLLSPEC double dhold(); |
235 |
ASC_DLLSPEC double dasin(); |
236 |
ASC_DLLSPEC double dasin2(); |
237 |
ASC_DLLSPEC double dcos(); |
238 |
ASC_DLLSPEC double dcos2(); |
239 |
ASC_DLLSPEC double dacos(); |
240 |
ASC_DLLSPEC double dacos2(); |
241 |
ASC_DLLSPEC double dtan(); |
242 |
ASC_DLLSPEC double dtan2(); |
243 |
ASC_DLLSPEC double datan(); |
244 |
ASC_DLLSPEC double datan2(); |
245 |
ASC_DLLSPEC double derf(); |
246 |
ASC_DLLSPEC double derf2(); |
247 |
|
248 |
# endif /* no stdc */ |
249 |
# endif /* fake ASC_FUNC_H */ |
250 |
|
251 |
/* @} */ |
252 |
|
253 |
#endif /* ASC_BT_PROLOG */ |
254 |
|