1 |
/* |
2 |
* Function module |
3 |
* by Tom Epperly |
4 |
* Version: $Revision: 1.8 $ |
5 |
* Version control file: $RCSfile: functype.h,v $ |
6 |
* Date last modified: $Date: 2001/01/31 22:23:58 $ |
7 |
* Last modified by: $Author: ballan $ |
8 |
* |
9 |
* This file is part of the Ascend Language Interpreter. |
10 |
* |
11 |
* Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
12 |
* |
13 |
* The Ascend Language Interpreter is free software; you can redistribute |
14 |
* it and/or modify it under the terms of the GNU General Public License as |
15 |
* published by the Free Software Foundation; either version 2 of the |
16 |
* License, or (at your option) any later version. |
17 |
* |
18 |
* The Ascend Language Interpreter is distributed in hope that it will be |
19 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 |
* General Public License for more details. |
22 |
* |
23 |
* You should have received a copy of the GNU General Public License |
24 |
* along with the program; if not, write to the Free Software Foundation, |
25 |
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
26 |
* COPYING. Revision notes: |
27 |
* |
28 |
* If CHRIS_FUNC defined, auxillary quantities to func structure. |
29 |
* 2/96 baa Probably somebody should properly set these evaluation |
30 |
* defined below based on math.h when possible. |
31 |
* 10/96 moved safe_err definition into here. |
32 |
*/ |
33 |
|
34 |
/** @file |
35 |
* Function module types and data structures. |
36 |
* <pre> |
37 |
* When #including functype.h, make sure these files are #included first: |
38 |
* #include "compiler.h" |
39 |
* </pre> |
40 |
*/ |
41 |
|
42 |
#ifndef ASC_FUNCTYPE_H |
43 |
#define ASC_FUNCTYPE_H |
44 |
|
45 |
/** |
46 |
* Safe math error codes. |
47 |
* If you add to this enum be sure to add to safe_error_to_stderr |
48 |
*/ |
49 |
enum safe_err { |
50 |
safe_problem = -1, |
51 |
safe_ok = 0, |
52 |
safe_div_by_zero = 1, |
53 |
safe_complex_result = 2, |
54 |
safe_overflow = 3, |
55 |
safe_underflow = 4, |
56 |
safe_range_error = 5 |
57 |
}; |
58 |
|
59 |
/** Function enumeration. */ |
60 |
enum Func_enum { |
61 |
F_LOG, F_LN, F_EXP, |
62 |
F_SIN, F_COS, F_TAN, |
63 |
F_ARCSIN, F_ARCCOS, F_ARCTAN, |
64 |
F_SQR, F_SQRT, F_ERF, F_LNM, |
65 |
F_SINH, F_COSH, F_TANH, |
66 |
F_ARCSINH, F_ARCCOSH, F_ARCTANH, |
67 |
F_CUBE, F_CBRT, F_ABS, F_HOLD |
68 |
}; |
69 |
|
70 |
/** Function data structure. */ |
71 |
struct Func { |
72 |
CONST char *name; /**< ASCEND name of function. not symchar */ |
73 |
CONST char *cname; /**< C name of function. not symchar */ |
74 |
CONST char *deriv1cname; /**< C name of first derivative. not symchar */ |
75 |
CONST char *deriv2cname; /**< C name of second derivative. not symchar */ |
76 |
enum Func_enum id; /**< identification of function */ |
77 |
double (*value)(double); /**< pointer to function evaluation */ |
78 |
double (*deriv)(double); /**< pointer to derivative evaluation */ |
79 |
double (*deriv2)(double); /**< pointer to a second derivative evaluation */ |
80 |
double (*safevalue)(double,enum safe_err *); /**< pointer to function evaluation */ |
81 |
double (*safederiv)(double,enum safe_err *); /**< pointer to derivative evaluation */ |
82 |
double (*safederiv2)(double,enum safe_err *); /**< pointer to a second derivative evaluation */ |
83 |
#ifdef CHRIS_FUNC |
84 |
struct Interval (*ivalue)(); /**< interval evaluation of function */ |
85 |
void (*slope)(unsigned long,struct Interval *,struct Interval *, |
86 |
struct Interval *); /**< pointer to slope evaluation routine */ |
87 |
struct Interval (*ideriv)(struct Interval); |
88 |
/**< interval derivative evaluation routine */ |
89 |
double (*tmin)(double,double); /**< return the point where the func is a min */ |
90 |
double (*tmax)(double,double); /**< return the point where the func is a max */ |
91 |
double (*e)(double,double,double,double (*)(double)); /**< convex envelope */ |
92 |
double (*ed)(double,double,double,double (*)(double)); /**< convex envelope derivative */ |
93 |
double (*E)(double,double,double,double (*)(double)); /**< concave envelope */ |
94 |
double (*Ed)(double,double,double,double (*)(double)); /**< concave envelope derivative */ |
95 |
#endif |
96 |
}; |
97 |
|
98 |
#endif /* ASC_FUNCTYPE_H */ |
99 |
|