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

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

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

revision 479 by ben.allan, Tue Apr 4 07:20:49 2006 UTC revision 480 by johnpye, Mon Apr 17 10:45:23 2006 UTC
# Line 51  Line 51 
51  #define ASC_RELATION_UTIL_H  #define ASC_RELATION_UTIL_H
52    
53  extern int g_check_dimensions_noisy;  extern int g_check_dimensions_noisy;
54  /**<  /**<
55   *  If 0, warnings are suppressed.  If 1, warnings are given   *  If 0, warnings are suppressed.  If 1, warnings are given
56   *  from RelationCheckDimensions();   *  from RelationCheckDimensions();
57   */   */
# Line 81  extern int RelationCheckDimensions(struc Line 81  extern int RelationCheckDimensions(struc
81   */   */
82    
83  extern enum Expr_enum RelationRelop(CONST struct relation *rel);  extern enum Expr_enum RelationRelop(CONST struct relation *rel);
84  /**<  /**<
85   *  <!--  enum Expr_enum RelationRelop(rel)                            -->   *  <!--  enum Expr_enum RelationRelop(rel)                            -->
86   *  <!--  CONST struct relation *rel;                                  -->   *  <!--  CONST struct relation *rel;                                  -->
87   *  Return the type of the relation operator of the relation.   *  Return the type of the relation operator of the relation.
# Line 235  extern enum Expr_enum RelationTermTypeF( Line 235  extern enum Expr_enum RelationTermTypeF(
235   */   */
236    
237  extern unsigned long TermVarNumber(CONST struct relation_term *term);  extern unsigned long TermVarNumber(CONST struct relation_term *term);
238  /**<  /**<
239   *  <!--  unsigned long TermVarNumber(term)                            -->   *  <!--  unsigned long TermVarNumber(term)                            -->
240   *  <!--  const struct relation_term *term;                            -->   *  <!--  const struct relation_term *term;                            -->
241   *  Return the index into the relations variable list.   *  Return the index into the relations variable list.
242   */   */
243    
244  extern long TermInteger(CONST struct relation_term *term);  extern long TermInteger(CONST struct relation_term *term);
245  /**<  /**<
246   *  <!--  long TermInteger(term)                                       -->   *  <!--  long TermInteger(term)                                       -->
247   *  <!--  const struct relation_term *term;                            -->   *  <!--  const struct relation_term *term;                            -->
248   *  Return the integer value from a e_int type relation term.   *  Return the integer value from a e_int type relation term.
249   */   */
250    
251  extern double TermReal(CONST struct relation_term *term);  extern double TermReal(CONST struct relation_term *term);
252  /**<  /**<
253   *  <!--  double TermReal(term)                                        -->   *  <!--  double TermReal(term)                                        -->
254   *  <!--  const struct relation_term *term;                            -->   *  <!--  const struct relation_term *term;                            -->
255   *  Return the double value from a e_real type relation term.   *  Return the double value from a e_real type relation term.
# Line 280  extern CONST struct Func *TermFunc(CONST Line 280  extern CONST struct Func *TermFunc(CONST
280   */   */
281    
282  extern unsigned long RelationDepth(CONST struct relation *rel);  extern unsigned long RelationDepth(CONST struct relation *rel);
283  /**<  /**<
284   *  <!--  unsigned long RelationDepth(rel)                             -->   *  <!--  unsigned long RelationDepth(rel)                             -->
285   *  <!--  struct relation *rel;                                        -->   *  <!--  struct relation *rel;                                        -->
286   *  Return the depth of stack required to evaluate this relation.   *  Return the depth of stack required to evaluate this relation.
# Line 305  extern unsigned long RelationDepth(CONST Line 305  extern unsigned long RelationDepth(CONST
305  #define TermBinRight(t) ( ((struct RelationBinary *)t) -> right)  #define TermBinRight(t) ( ((struct RelationBinary *)t) -> right)
306    
307  extern struct relation_term *RelationINF_Lhs(CONST struct relation *rel);  extern struct relation_term *RelationINF_Lhs(CONST struct relation *rel);
308  /**<  /**<
309   *  Returns the lhs of an infix relation. This may be NULL,   *  Returns the lhs of an infix relation. This may be NULL,
310   *  if the relation has not been set for infix scanning.   *  if the relation has not been set for infix scanning.
311   */   */
312    
313  extern struct relation_term *RelationINF_Rhs(CONST struct relation *rel);  extern struct relation_term *RelationINF_Rhs(CONST struct relation *rel);
314  /**<  /**<
315   *  Return the rhs of an infix relation. This may be NULL   *  Return the rhs of an infix relation. This may be NULL
316   *  if the relation has not been set up for infix scanning, or if   *  if the relation has not been set up for infix scanning, or if
317   *  the relation is an objective relation.   *  the relation is an objective relation.
# Line 366  extern CONST struct gl_list_t *RelationV Line 366  extern CONST struct gl_list_t *RelationV
366   */   */
367    
368  extern dim_type *RelationDim(CONST struct relation *rel);  extern dim_type *RelationDim(CONST struct relation *rel);
369  /**<  /**<
370   *  <!--  dim_type *RelationDim(rel)                                   -->   *  <!--  dim_type *RelationDim(rel)                                   -->
371   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
372   *  Return the derived dimensionality of the relation.   *  Return the derived dimensionality of the relation.
# Line 374  extern dim_type *RelationDim(CONST struc Line 374  extern dim_type *RelationDim(CONST struc
374   */   */
375    
376  extern int SetRelationDim(struct relation *rel, dim_type *d);  extern int SetRelationDim(struct relation *rel, dim_type *d);
377  /**<  /**<
378   *  <!--  int SetRelationDim(rel,d)                                    -->   *  <!--  int SetRelationDim(rel,d)                                    -->
379   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
380   *  Set the  dimensionality of the relation. return 0 unless there is a   *  Set the  dimensionality of the relation. return 0 unless there is a
381   *  problem (rel was null, for instance.)   *  problem (rel was null, for instance.)
382   */   */
383    
384  extern double RelationResidual(CONST struct relation *rel);  extern double ASC_DLLSPEC RelationResidual(CONST struct relation *rel);
385  /**<  /**<
386   *  <!--  double RelationResidual(rel)                                 -->   *  <!--  double RelationResidual(rel)                                 -->
387   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
388   *  Return the residual of the relation.   *  Return the residual of the relation.
389   */   */
390    
391  extern void SetRelationResidual(struct relation *rel, double value);  extern void SetRelationResidual(struct relation *rel, double value);
392  /**<  /**<
393   *  <!--  void SetRelationResidual(rel,value)                          -->   *  <!--  void SetRelationResidual(rel,value)                          -->
394   *  <!--  struct relation *rel;                                        -->   *  <!--  struct relation *rel;                                        -->
395   *  <!--  double value;                                                -->   *  <!--  double value;                                                -->
# Line 397  extern void SetRelationResidual(struct r Line 397  extern void SetRelationResidual(struct r
397   */   */
398    
399  extern double RelationMultiplier(CONST struct relation *rel);  extern double RelationMultiplier(CONST struct relation *rel);
400  /**<  /**<
401   *  <!--  double RelationMultiplier(rel)                               -->   *  <!--  double RelationMultiplier(rel)                               -->
402   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
403   *  Return the langrage multiplier of the relation. This will have some   *  Return the langrage multiplier of the relation. This will have some
# Line 406  extern double RelationMultiplier(CONST s Line 406  extern double RelationMultiplier(CONST s
406   */   */
407    
408  extern void SetRelationMultiplier(struct relation *rel, double value);  extern void SetRelationMultiplier(struct relation *rel, double value);
409  /**<  /**<
410   *  <!--  void SetRelationMultiplier(rel,value)                        -->   *  <!--  void SetRelationMultiplier(rel,value)                        -->
411   *  <!--  struct relation *rel;                                        -->   *  <!--  struct relation *rel;                                        -->
412   *  <!--  double value;                                                -->   *  <!--  double value;                                                -->
# Line 415  extern void SetRelationMultiplier(struct Line 415  extern void SetRelationMultiplier(struct
415   */   */
416    
417  extern int RelationIsCond(CONST struct relation *rel);  extern int RelationIsCond(CONST struct relation *rel);
418  /**<  /**<
419   *  <!--  int RelationIsCond(rel)                                      -->   *  <!--  int RelationIsCond(rel)                                      -->
420   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
421   *  Return the value of the iscond flag of the relation.   *  Return the value of the iscond flag of the relation.
# Line 423  extern int RelationIsCond(CONST struct r Line 423  extern int RelationIsCond(CONST struct r
423   */   */
424    
425  extern void SetRelationIsCond(struct relation *rel);  extern void SetRelationIsCond(struct relation *rel);
426  /**<  /**<
427   *  <!--  void SetRelationIsCond(rel)                                  -->   *  <!--  void SetRelationIsCond(rel)                                  -->
428   *  <!--  struct relation *rel;                                        -->   *  <!--  struct relation *rel;                                        -->
429   *  Sets the value of the iscond field of the relation to 1   *  Sets the value of the iscond field of the relation to 1
# Line 431  extern void SetRelationIsCond(struct rel Line 431  extern void SetRelationIsCond(struct rel
431   */   */
432    
433  extern double RelationNominal(CONST struct relation *rel);  extern double RelationNominal(CONST struct relation *rel);
434  /**<  /**<
435   *  <!--  double RelationNominal(rel)                                  -->   *  <!--  double RelationNominal(rel)                                  -->
436   *  <!--  const struct relation *rel;                                  -->   *  <!--  const struct relation *rel;                                  -->
437   *  Return the nominal of the relation.   *  Return the nominal of the relation.
# Line 447  extern void SetRelationNominal(struct re Line 447  extern void SetRelationNominal(struct re
447   */   */
448    
449  extern double CalcRelationNominal(struct Instance *i);  extern double CalcRelationNominal(struct Instance *i);
450  /**<  /**<
451   *    <!--  d = CalcRelationNominal(i);                                -->   *    <!--  d = CalcRelationNominal(i);                                -->
452   *    <!--  struct Instance *i;                                        -->   *    <!--  struct Instance *i;                                        -->
453   *    <!--  double d;                                                  -->   *    <!--  double d;                                                  -->
# Line 475  extern double CalcRelationNominal(struct Line 475  extern double CalcRelationNominal(struct
475   */   */
476    
477  extern void PrintRelationNominals(struct Instance *i);  extern void PrintRelationNominals(struct Instance *i);
478  /**<  /**<
479   *   Perform a visit instance tree starting at i and calc/print consts.   *   Perform a visit instance tree starting at i and calc/print consts.
480   *   This function doesn't belong here.   *   This function doesn't belong here.
481   */   */
482    
483  extern char *tmpalloc(int nbytes);  extern char *tmpalloc(int nbytes);
484  /**<  /**<
485   *   Temporarily allocates a given number of bytes.  The memory need   *   Temporarily allocates a given number of bytes.  The memory need
486   *   not be freed, but the next call to this function will reuse the   *   not be freed, but the next call to this function will reuse the
487   *   previous allocation. Memory returned will NOT be zeroed.   *   previous allocation. Memory returned will NOT be zeroed.
# Line 489  extern char *tmpalloc(int nbytes); Line 489  extern char *tmpalloc(int nbytes);
489   */   */
490    
491  #define tmpalloc_array(nelts,type)  ((type *)tmpalloc((nelts)*sizeof(type)))  #define tmpalloc_array(nelts,type)  ((type *)tmpalloc((nelts)*sizeof(type)))
492  /**<  /**<
493   *  Creates an array of "nelts" objects, each with type "type".   *  Creates an array of "nelts" objects, each with type "type".
494   */   */
495    
496  /*  /*
497   *   The following mess of functions   *   The following mess of functions
498   *   migrated out of the solver directory into this file. Who   *   migrated out of the solver directory into this file. Who
499   *   ever heard of a math modeling language that doesn't supply   *   ever heard of a math modeling language that doesn't supply
500   *   evaluation functions for its equations?   *   evaluation functions for its equations?
# Line 507  extern char *tmpalloc(int nbytes); Line 507  extern char *tmpalloc(int nbytes);
507   */   */
508    
509  extern int RelationCalcResidualBinary(CONST struct relation *rel, double *res);  extern int RelationCalcResidualBinary(CONST struct relation *rel, double *res);
510  /**<  /**<
511   * <!--  err = RelationCalcResidualBinary(rel,res);                    -->   * <!--  err = RelationCalcResidualBinary(rel,res);                    -->
512   * Returns 0 if it calculates a valid residual, 1 if   * Returns 0 if it calculates a valid residual, 1 if
513   * for any reason it cannot. Reasons include:   * for any reason it cannot. Reasons include:
# Line 533  RelationCalcResidualPostfixSafe(struct I Line 533  RelationCalcResidualPostfixSafe(struct I
533   */   */
534    
535  extern int RelationCalcResidualPostfix(struct Instance *i, double *res);  extern int RelationCalcResidualPostfix(struct Instance *i, double *res);
536  /**<  /**<
537   *  <!--  status = RelationCalcResidualPostfix(i,res);                 -->   *  <!--  status = RelationCalcResidualPostfix(i,res);                 -->
538   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
539   *  <!--  double *res;                                                 -->   *  <!--  double *res;                                                 -->
# Line 563  extern int RelationCalcResidualPostfix(s Line 563  extern int RelationCalcResidualPostfix(s
563  #define RCE_ERR_RHSNAN  0x80  /**< right side returns NaN */  #define RCE_ERR_RHSNAN  0x80  /**< right side returns NaN */
564    
565  extern int RelationCalcExceptionsInfix(struct Instance *i);  extern int RelationCalcExceptionsInfix(struct Instance *i);
566  /**<  /**<
567   *  <!--  status = RelationCalcExceptionsInfix(i);                     -->   *  <!--  status = RelationCalcExceptionsInfix(i);                     -->
568   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
569   *  <!--  int status;                                                  -->   *  <!--  int status;                                                  -->
# Line 585  extern int RelationCalcExceptionsInfix(s Line 585  extern int RelationCalcExceptionsInfix(s
585   */   */
586    
587  extern int RelationCalcResidualInfix(struct Instance *i, double *res);  extern int RelationCalcResidualInfix(struct Instance *i, double *res);
588  /**<  /**<
589   *  <!--  status = RelationCalcResidualInfix(i,res);                   -->   *  <!--  status = RelationCalcResidualInfix(i,res);                   -->
590   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
591   *  <!--  double *res;                                                 -->   *  <!--  double *res;                                                 -->
# Line 622  extern int RelationCalcGradient(struct I Line 622  extern int RelationCalcGradient(struct I
622   */   */
623    
624  extern enum safe_err RelationCalcGradientSafe(struct Instance *i, double *grad);  extern enum safe_err RelationCalcGradientSafe(struct Instance *i, double *grad);
625  /**<  /**<
626   *  <!--  status = RelationCalcGradientSafe(i,grad);                   -->   *  <!--  status = RelationCalcGradientSafe(i,grad);                   -->
627   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
628   *  <!--  double grad[];                                               -->   *  <!--  double grad[];                                               -->
# Line 636  extern enum safe_err RelationCalcGradien Line 636  extern enum safe_err RelationCalcGradien
636   */   */
637    
638  extern int RelationCalcResidGrad(struct Instance *i, double *res, double *grad);  extern int RelationCalcResidGrad(struct Instance *i, double *res, double *grad);
639  /**<  /**<
640   *  <!--  status = RelationCalcResidGrad(i,res,grad);                  -->   *  <!--  status = RelationCalcResidGrad(i,res,grad);                  -->
641   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
642   *  <!--  double *res;                                                 -->   *  <!--  double *res;                                                 -->
# Line 652  extern int RelationCalcResidGrad(struct Line 652  extern int RelationCalcResidGrad(struct
652    
653  extern enum safe_err  extern enum safe_err
654  RelationCalcResidGradSafe(struct Instance *i, double *res, double *grad);  RelationCalcResidGradSafe(struct Instance *i, double *res, double *grad);
655  /**<  /**<
656   *  <!--  status = RelationCalcResidGradSafe(i,res,grad);              -->   *  <!--  status = RelationCalcResidGradSafe(i,res,grad);              -->
657   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
658   *  <!--  double *res;                                                 -->   *  <!--  double *res;                                                 -->
# Line 704  extern double *RelationFindRoots(struct Line 704  extern double *RelationFindRoots(struct
704   */   */
705    
706  extern int RelationCalcDerivative(struct Instance *i, unsigned long index, double *grad);  extern int RelationCalcDerivative(struct Instance *i, unsigned long index, double *grad);
707  /**<  /**<
708   *  <!--  status = RelationCalcDerivative(i,index,grad);               -->   *  <!--  status = RelationCalcDerivative(i,index,grad);               -->
709   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
710   *  <!--  unsigned long index;                                         -->   *  <!--  unsigned long index;                                         -->
# Line 722  extern int RelationCalcDerivative(struct Line 722  extern int RelationCalcDerivative(struct
722    
723  extern enum safe_err  extern enum safe_err
724  RelationCalcDerivativeSafe(struct Instance *i, unsigned long index, double *grad);  RelationCalcDerivativeSafe(struct Instance *i, unsigned long index, double *grad);
725  /**<  /**<
726   *  <!--  status = RelationCalcDerivativeSafe(i,index,grad);           -->   *  <!--  status = RelationCalcDerivativeSafe(i,index,grad);           -->
727   *  <!--  struct RelationInstance *i;                                  -->   *  <!--  struct RelationInstance *i;                                  -->
728   *  <!--  unsigned long index;                                         -->   *  <!--  unsigned long index;                                         -->
# Line 736  RelationCalcDerivativeSafe(struct Instan Line 736  RelationCalcDerivativeSafe(struct Instan
736    
737  extern struct gl_list_t  extern struct gl_list_t
738  *CollectTokenRelationsWithUniqueBINlessShares(struct Instance *i, unsigned long maxlen);  *CollectTokenRelationsWithUniqueBINlessShares(struct Instance *i, unsigned long maxlen);
739  /**<  /**<
740   * <!--  rlist = CollectTokenRelationsWithUniqueBINlessShares(i,maxlen); -->   * <!--  rlist = CollectTokenRelationsWithUniqueBINlessShares(i,maxlen); -->
741   * Collect the token relation 'shares' in i which have not been compiled   * Collect the token relation 'shares' in i which have not been compiled
742   * (or at least attempted so) to binary form yet.   * (or at least attempted so) to binary form yet.

Legend:
Removed from v.479  
changed lines
  Added in v.480

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