/[ascend]/trunk/base/generic/compiler/btprolog.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/btprolog.h

Parent Directory Parent Directory | Revision Log Revision Log


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

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22