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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 203 - (show annotations) (download) (as text)
Mon Jan 23 04:13:17 2006 UTC (18 years, 4 months ago) by johnpye
File MIME type: text/x-chdr
File size: 6430 byte(s)
Documentation changes; making 'FIX' statement less verbose;
Commenting out ununsed 'CreateExternalFunction' function
1 /*
2 * Symbolic Expression Manipulation
3 * by Kirk Abbott
4 * Created: Novermber 21, 1994
5 * Version: $Revision: 1.5 $
6 * Version control file: $RCSfile: exprsym.h,v $
7 * Date last modified: $Date: 1997/07/18 12:29:23 $
8 * Last modified by: $Author: mthomas $
9 *
10 * This file is part of the ASCEND compiler.
11 *
12 * Copyright (C) 1994,1995 Kirk Andre Abbott.
13 * Copyright (C) 2006 Carnegie Mellon University
14 *
15 * The Ascend Language Interpreter is free software; you can redistribute
16 * it and/or modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of the
18 * License, or (at your option) any later version.
19 *
20 * The Ascend Language Interpreter is distributed in hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with the program; if not, write to the Free Software Foundation,
27 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
28 * COPYING.
29 */
30
31 /** @file
32 * Symbolic Expression Manipulation
33 * <pre>
34 * When #including .h, make sure these files are #included first:
35 * #utilities/ascConfig.h"
36 * #include "instance_enum.h"
37 * </pre>
38 *
39 * The user is reminded that the author of these routines
40 * could not be bothered with dimensionality, so don't expect
41 * much in the way of output that dimensionally checks or
42 * can be converted to real values in non-SI units unless the
43 * input was correct.
44 *
45 * The user is also reminded that this code does not deal well
46 * with e_zero. e_zero should not exist in good models in any
47 * case.
48 */
49
50 #ifndef ASC_EXPRSYM_H
51 #define ASC_EXPRSYM_H
52
53 /**
54 * Until we decide whether to let the postfix and
55 * infix data structures be shared. we will use these
56 * typedefs.
57 */
58 typedef struct Func Func;
59
60 typedef struct relation_term Term;
61 /**< note, so now Term has to be treated like A_TERM. */
62
63 typedef struct relation RelationINF; /**< infix relation */
64
65 #define K_TERM(i) ((Term *)(i))
66 /**< Cast the i back to Term */
67
68 extern Term *TermSimplify(Term *term);
69 /**<
70 * Attempts term simplification. Later different levels of simplification
71 * will be made a feature.
72 */
73
74 extern Term *Derivative(Term *term, unsigned long wrt,
75 int (*filter)(struct Instance *));
76 /**<
77 * The low level routine which actually does the symbolic differentiation
78 * with sub epxression simplification/elimination. In general not a safe
79 * place to start as use is made of a free store which has to be set up
80 * before this funcion may be called.
81 */
82
83 extern void PrepareDerivatives(int setup, int n_buffers, int buffer_length);
84 /**<
85 * Call this function before and after doing symbolic derivatives.
86 * If setup is true, a free store of terms will be set up, with the
87 * specified number of buffers and buffer length. I am now using 2
88 * buffers of length 5000.
89 * If set up is false the memory allocated in the previous call to set up
90 * will be deallocated.
91 */
92
93 #define ShutDownDerivatives() PrepareDerivatives(0,0,0)
94 /**<
95 * Deallocate memory allocated in the previous call to PrepareDerivatives().
96 */
97
98 extern Term *TermDerivative(Term *term, unsigned long wrt,
99 int (*filter)(struct Instance *) );
100 /**<
101 * TermDerivative is the function that is used by RelationDerivative
102 * to generate the derivatives. Again it is perhaps more efficient
103 * to call RelationDerivative.
104 */
105
106 extern RelationINF *RelDerivative(RelationINF *rel, unsigned long wrt,
107 int (*filter)(struct Instance *));
108 /**<
109 * Given a infix relation, a index into its variable list and a function
110 * filter used to classify REAL_ATOM_INSTANCES as variables,parmaters or
111 * constants (or for that matter whatever the user pleases), this function
112 * will return a relation which is the symbolic derivative of the relation,
113 * with respect to the given variable. The relation *belongs* to the caller.
114 * The variale list will be updated to represent the new incidence after
115 * differentiation.
116 */
117
118 extern void RelDestroySloppy(RelationINF *rel);
119 /**<
120 * This function is to be used to deallocate a relation that was returned
121 * as a result of a call to RelDeriveSloppy.
122 * <pre>
123 * Example usage:
124 * ( .... )
125 * RelationINF *rel,*deriv;
126 * unsigned long wrt = 3;
127 * rel = (...)
128 * PrepareDerivates(1,3,500);
129 * deriv = RelDeriveSloppy(rel,wrt,NULL);
130 * WriteRelationInfix(stderr,deriv);
131 * RelDestroySloppy(deriv);
132 * ShutDownDerivatives();
133 * ( .... )
134 * return;
135 * </pre>
136 */
137
138 extern RelationINF *RelDeriveSloppy(RelationINF *rel, unsigned long wrt,
139 int (*filter)(struct Instance *));
140 /**<
141 * Given a infix relation, a index into its variable list and a function
142 * filter used to classify REAL_ATOM_INSTANCES as variables,parmaters or
143 * constants (or for that matter whatever the user pleases), this function
144 * will return a relation which is the symbolic derivative of the relation,
145 * with respect to the given variable.<br><br>
146 *
147 * NOTE 1:<br>
148 * This function is provided for the benefit of users, who would like
149 * access to symbolic derivatives of a TRANSIENT nature. By this
150 * I mean that the derivative is going to be evaluated, written out etc,
151 * and then discarded. It makes certain shortcuts in the interest of speed
152 * For example, the returned variable list does not relect the fact
153 * that incidence may have been lost due to the process of doing the
154 * derivatives; but is still a valid list as differentiation can reduce
155 * incidence but not increase it.<br><br>
156 *
157 * NOTE 2:<br>
158 * The relation structure that is returned *belongs* to the user.
159 * The variable list associated with the relation *belongs* to the user.
160 * The terms that make up the relation *do not belong* to the user.
161 * In fact *DO NOT deallocate any of these structures yourself. Use the
162 * above function RelDestroySloppy. This will deallocate the necessary
163 * structures. The term lists are the property of the freestore that was
164 * set up in PrepareDerivatives and will be handled by that store on
165 * Shutdown.
166 */
167
168 #endif /* ASC_EXPRSYM_H */
169

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