Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

AST Manipulations
[Formula Processing: f(x), df/dx]

Collaboration diagram for AST Manipulations:

Diverse Functions to manipulate libSBML Abstract Syntax Trees. More...

Functions

SBML_ODESOLVER_API int ASTNode_isIndexName (ASTNode_t *node)
 Returns true (1) if the ASTNode is an ASTIndexNameNode.
SBML_ODESOLVER_API unsigned
int 
ASTNode_isSetIndex (ASTNode_t *node)
 Returns true (1) if the an indexed ASTNode (ASTIndexNameNode) has it's index set.
SBML_ODESOLVER_API void AST_replaceNameByName (ASTNode_t *math, const char *name, const char *newname)
 Replaces all AST_NAME types with `name' appearing in the formula 'math' by the `newname'.
SBML_ODESOLVER_API void AST_replaceNameByValue (ASTNode_t *math, const char *name, double x)
 Replaces all AST_NAME types with `name' appearing in the formula 'math' by the value 'x'.
SBML_ODESOLVER_API void AST_replaceNameByParameters (ASTNode_t *math, ListOf_t *lp)
 Replaces all parameters appearing in the formula 'math' by their value defined in the passed parameter list 'lp'.
SBML_ODESOLVER_API void AST_replaceNameByFormula (ASTNode_t *math, const char *name, const ASTNode_t *formula)
 Replaces an assigned variable 'name' in the passed mathematical expression math by the mathemtical expression in `formula'; can be used to replace assignment rules!
SBML_ODESOLVER_API void AST_replaceFunctionDefinition (ASTNode_t *math, const char *name, const ASTNode_t *function)
 Replaces all user defined functions by the full expression of the function in the passed mathematical expression `math'.
SBML_ODESOLVER_API void AST_replaceConstants (Model_t *m, ASTNode_t *math)
 Replace all constants of a model in an AST math.
ASTNode_t * indexAST (const ASTNode_t *f, int nvalues, char **names)
 Takes an AST and a string array `names' and converts AST_NAME to AST_IndexName, which holds the name of the variable and additionally its index in the passed array `names'.
SBML_ODESOLVER_API ASTNode_t * simplifyAST (ASTNode_t *f)
 Takes an AST f, and returns a simplified copy of f.

Detailed Description

Diverse Functions to manipulate libSBML Abstract Syntax Trees.

Replace variable names with values, with other names, with formulae, expand defined functions, simplify formulae etc.


Function Documentation

SBML_ODESOLVER_API int ASTNode_isIndexName ASTNode_t *  node  ) 
 

Returns true (1) if the ASTNode is an ASTIndexNameNode.

SBML_ODESOLVER_API unsigned int ASTNode_isSetIndex ASTNode_t *  node  ) 
 

Returns true (1) if the an indexed ASTNode (ASTIndexNameNode) has it's index set.

SBML_ODESOLVER_API void AST_replaceNameByName ASTNode_t *  math,
const char *  name,
const char *  newname
 

Replaces all AST_NAME types with `name' appearing in the formula 'math' by the `newname'.

SBML_ODESOLVER_API void AST_replaceNameByValue ASTNode_t *  math,
const char *  name,
double  x
 

Replaces all AST_NAME types with `name' appearing in the formula 'math' by the value 'x'.

SBML_ODESOLVER_API void AST_replaceNameByParameters ASTNode_t *  math,
ListOf_t *  lp
 

Replaces all parameters appearing in the formula 'math' by their value defined in the passed parameter list 'lp'.

SBML_ODESOLVER_API void AST_replaceNameByFormula ASTNode_t *  math,
const char *  name,
const ASTNode_t *  formula
 

Replaces an assigned variable 'name' in the passed mathematical expression math by the mathemtical expression in `formula'; can be used to replace assignment rules!

SBML_ODESOLVER_API void AST_replaceFunctionDefinition ASTNode_t *  math,
const char *  name,
const ASTNode_t *  function
 

Replaces all user defined functions by the full expression of the function in the passed mathematical expression `math'.

This is quite a dirty solution and might be dangerous. See comments in function.

SBML_ODESOLVER_API void AST_replaceConstants Model_t *  m,
ASTNode_t *  math
 

Replace all constants of a model in an AST math.

Step R.1: replace Assignment Rules Parameters, compartments or species defined by assignment rules in the model will be replaced by the assignment expression in the AST formula

Starting from the back, because variables defined by assignment rules can be used is subsequent assignments. Thus this direction should catch all assignments.

Step R.2: replace Function Definitions All Function Definitions will be replaced by the full expression

Steps R.3: replacing all constant global parameters in rate rules, algebraic rules and events by their value.

Steps R.4: replacing all constant compartments in rate rules, algebraic rules and events by their size

Steps R.5: replacing all species that are defined as either constant or boundary but not defined by a rate rule (i.e. also constant) by their initial concentration. Species that are set by an assignment rules have already been replaced above in Step R.1

ASTNode_t* indexAST const ASTNode_t *  f,
int  nvalues,
char **  names
 

Takes an AST and a string array `names' and converts AST_NAME to AST_IndexName, which holds the name of the variable and additionally its index in the passed array `names'.

memory leak in sensitivity.c!

SBML_ODESOLVER_API ASTNode_t* simplifyAST ASTNode_t *  f  ) 
 

Takes an AST f, and returns a simplified copy of f.

decomposes n-ary `times' and `plus' nodes into an AST of binary AST.

simplifies (arithmetic) operations involving 0 and 1:
-0 -> 0;
x+0 -> x, 0+x -> x;
x-0 -> x, 0-x -> -x;
x*0 -> 0, 0*x -> 0, x*1 -> x, 1*x -> x;
0/x -> 0, x/1 -> x;
x^0 -> 1, x^1 -> x, 0^x -> 0, 1^x -> 1;

propagates unary minuses
--x -> x;
-x + -y -> -(x+y), -x + y -> y-x, x + -y -> x-y;
-x - -y -> y-x, -x - y -> -(x+y), x - -y -> x+y;
-x * -y -> x*y, -x * y -> -(x*y), x * -y -> -(x*y);
-x / -y -> x/y, -x / y -> -(x/y), x / -y -> -(x/y);

calls evaluateAST(subtree), if no variables or user-defined functions occur in the AST subtree,

calls itself recursively for childnodes,


Generated on Wed Dec 21 18:10:37 2005 for SBML ODE Solver Library API by  doxygen 1.4.4