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

Diff of /trunk/base/generic/compiler/extfunc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 474 by ben.allan, Mon Apr 17 03:18:06 2006 UTC revision 475 by ben.allan, Mon Apr 17 05:46:47 2006 UTC
# Line 78  enum Calc_status { Line 78  enum Calc_status {
78    calc_error, calc_all_ok    calc_error, calc_all_ok
79  };  };
80    
81    /**
82     * Each blackbox equation may show up more than once in a simulation
83     * if models repeat in the structure. For each occurence of the
84     * blackbox, a unique Slv_Interp object is given when the set of
85     * corresponding relations is created.
86     * It is used for the blackbox to communicate to the rest of the system.
87     * If the blackbox retains internal state between evaluation calls,
88     * it should store this state in the user_data pointer.
89     */
90  struct Slv_Interp {  struct Slv_Interp {
91      /* unique identifier tied to instance tree. */
92    int nodestamp;    int nodestamp;
93      /* status is set by evaluation calls before returning. */
94    enum Calc_status status;    enum Calc_status status;
95      /* user_data is set by the external library if it has any persistent state
96         during calls to ExtBBoxInitFunc initial and final given in
97         CreateUserFunctionBlackBox.
98       */
99    void *user_data;    void *user_data;
100      /* first call will be true when the initial function pointer is called. */
101    unsigned first_call  :1;    unsigned first_call  :1;
102      /* first call will be true when the final function pointer is called. */
103    unsigned last_call   :1;    unsigned last_call   :1;
104      /* If check_args, blackbox should do any argument checking of the variables, data. */
105    unsigned check_args  :1;    unsigned check_args  :1;
106      /* If recalculate, the caller thinks the input may have changed. */
107    unsigned recalculate :1;    unsigned recalculate :1;
108    unsigned deriv_eval  :1;    /* If func_eval, the caller is using the residual function pointer. */
109    unsigned func_eval   :1;    unsigned func_eval   :1;
110      /* If deriv_eval, the caller is using the deriv function pointer. */
111      unsigned deriv_eval  :1;
112      /* If hess_eval, the caller is using the hessian function pointer. */
113      unsigned hess_eval   :1;
114      /* If single_step, the caller would like one step toward the solution;
115         usually this is meaningless and should be answered with calc_diverged. */
116    unsigned single_step  :1;    unsigned single_step  :1;
117  };  };
118    
# Line 95  struct Slv_Interp { Line 120  struct Slv_Interp {
120  We don't actually support this method anywhere right now, as  We don't actually support this method anywhere right now, as
121  we're not sure what it can logically be used for that the  we're not sure what it can logically be used for that the
122  init function in dlopening shouldn't be doing.  init function in dlopening shouldn't be doing.
123    In principal, we could add and cache a client-data pointer
124    in each instance so that the external method may be stateful.
125    Presently, the external methods must be clever to do that
126    on their own or must use ascend instances for state instead.
127  @param context the instance on which the method may be run.  @param context the instance on which the method may be run.
128  */  */
129  typedef int ExtMethodInit( struct Instance *context);  typedef int ExtMethodInit( struct Instance *context);
# Line 112  typedef int ExtBBoxInitFunc(struct Slv_I Line 141  typedef int ExtBBoxInitFunc(struct Slv_I
141                              struct Instance *,                              struct Instance *,
142                              struct gl_list_t *);                              struct gl_list_t *);
143    
144    /* this one may need splitting/rework for hessian */
145  typedef int ExtBBoxFunc(struct Slv_Interp *,  typedef int ExtBBoxFunc(struct Slv_Interp *,
146                          int ninputs,                          int ninputs,
147                          int noutputs,                          int noutputs,
# Line 242  extern int DLEXPORT CreateUserFunctionBl Line 272  extern int DLEXPORT CreateUserFunctionBl
272   *   *
273   *  @param name Name of the function being added (or updated).   *  @param name Name of the function being added (or updated).
274   *  @param init Pointer to initialisation function, or NULL if none.   *  @param init Pointer to initialisation function, or NULL if none.
275   *  @param value array of evaluation function pointers,   *  @param final Pointer to shutdown function. May be same as init.
276   *               or NULL if none.   *  @param value  evaluation function pointers, or NULL if none.
277   *  @param deriv array of first partial   *  @param deriv first partial derivative functions, or NULL if none.
278   *               derivative functions, or NULL if none.   *  @param deriv2 second derivative functions, or NULL if none.
  *  @param deriv2 array of second derivative  
  *                functions, or NULL if none.  
279   *  @return Returns 0 if the function was successfully added,   *  @return Returns 0 if the function was successfully added,
280   *          non-zero otherwise.   *          non-zero otherwise.
281   *   *

Legend:
Removed from v.474  
changed lines
  Added in v.475

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