本文整理汇总了C++中ASTNode_free函数的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode_free函数的具体用法?C++ ASTNode_free怎么用?C++ ASTNode_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASTNode_free函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (void)
{
cvodeSettings_t *options = CvodeSettings_createWithTime(10000, 1000);
odeModel_t *odemodel = ODEModel_createFromFile("MAPK.xml");
integratorInstance_t *ii = IntegratorInstance_create(odemodel, options);
ASTNode_t *f = SBML_parseFormula("MAPK_PP");
ASTNode_t *f2 = SBML_parseFormula("MAPK + MAPK_P");
ASTNode_t *f3 = SBML_parseFormula("MAPK + MAPK_P + MAPK_PP");
cvodeData_t *data = IntegratorInstance_getData(ii);
while( ! IntegratorInstance_timeCourseCompleted(ii) )
if ( IntegratorInstance_integrateOneStep(ii ) )
{
printf(" active MAPK concentration at time %g:\t%7.3f\n",
IntegratorInstance_getTime(ii), evaluateAST(f, data));
printf("inactive MAPK concentration at time %g:\t%7.3f\n",
IntegratorInstance_getTime(ii), evaluateAST(f2, data));
printf(" total:\t%7.3f\n\n",
evaluateAST(f3, data));
}
else
break;
SolverError_dump();
ODEModel_free(odemodel);
IntegratorInstance_free(ii);
ASTNode_free(f);
ASTNode_free(f2);
return (EXIT_SUCCESS);
}
示例2: IntegratorInstance_setVariableValue
SBML_ODESOLVER_API void IntegratorInstance_setVariableValue(integratorInstance_t *engine, variableIndex_t *vi, double value)
{
int i, j;
ASTNode_t *tmp;
odeModel_t *om;
cvodeData_t *data;
cvodeSettings_t *opt;
cvodeSolver_t *solver;
om = engine->om;
opt = engine->opt;
data = engine->data;
solver = engine->solver;
data->value[vi->index] = value;
if ( vi->index < om->neq ) {
/* if (om->algebraic) ?? */
IntegratorInstance_freeCVODESolverStructures(engine);
solver->t0 = solver->t;
IntegratorInstance_createCVODESolverStructures(engine);
}
else if ( vi->index >= om->neq+om->nass ) {
/* optimize ODEs for evaluation */
/*!!! will need adaptation to selected sens.analysis !!!*/
for ( i=0; i<om->neq; i++ ) {
if ( !opt->Sensitivity || om->sensitivity ) {
/* optimize each ODE: replace nconst and simplifyAST */
tmp = copyAST(om->ode[i]);
for ( j=0; j<om->nconst; j++ ) {
AST_replaceNameByValue(tmp,
om->names[om->neq+om->nass+j],
data->value[om->neq+om->nass+j]);
}
if ( data->ode[i] != NULL )
ASTNode_free(data->ode[i]);
data->ode[i] = simplifyAST(tmp);
ASTNode_free(tmp);
}
else {
if ( data->ode[i] != NULL )
ASTNode_free(data->ode[i]);
data->ode[i] = copyAST(om->ode[i]);
}
}
}
}
示例3: START_TEST
END_TEST
START_TEST (test_FunctionDefinition_getArguments)
{
const ASTNode_t *math;
ASTNode_t* math1 = SBML_parseFormula("lambda(x, y, x^y)");
FunctionDefinition_setMath(FD, math1 );
ASTNode_free(math1);
fail_unless( FunctionDefinition_getNumArguments(FD) == 2 );
math = FunctionDefinition_getArgument(FD, 0);
fail_unless( math != NULL );
fail_unless( ASTNode_isName(math) );
fail_unless( !strcmp(ASTNode_getName(math), "x") );
fail_unless( ASTNode_getNumChildren(math) == 0 );
math = FunctionDefinition_getArgument(FD, 1);
fail_unless( math != NULL );
fail_unless( ASTNode_isName(math) );
fail_unless( !strcmp(ASTNode_getName(math), "y") );
fail_unless( ASTNode_getNumChildren(math) == 0 );
fail_unless( FunctionDefinition_getArgument(FD, 0) ==
FunctionDefinition_getArgumentByName(FD, "x") );
fail_unless( FunctionDefinition_getArgument(FD, 1) ==
FunctionDefinition_getArgumentByName(FD, "y") );
}
示例4: START_TEST
END_TEST
START_TEST (test_Rule_setMath1)
{
ASTNode_t *math = ASTNode_createWithType(AST_TIMES);
ASTNode_t *a = ASTNode_create();
ASTNode_t *b = ASTNode_create();
ASTNode_setName(a, "a");
ASTNode_setName(b, "b");
ASTNode_addChild(math, a);
ASTNode_addChild(math, b);
char *formula;
const ASTNode_t *math1;
int i = Rule_setMath(R, math);
fail_unless( i == LIBSBML_OPERATION_SUCCESS);
fail_unless( Rule_isSetMath(R) );
math1 = Rule_getMath(R);
fail_unless( math1 != NULL );
formula = SBML_formulaToString(math1);
fail_unless( formula != NULL );
fail_unless( !strcmp(formula, "a * b") );
ASTNode_free(math);
}
示例5: START_TEST
END_TEST
START_TEST (test_FormulaFormatter_multiOr)
{
StringBuffer_t *sb = StringBuffer_create(42);
char *s = StringBuffer_getBuffer(sb);
ASTNode_t *n = ASTNode_create();
ASTNode_t *c = ASTNode_create();
ASTNode_setType(n, AST_LOGICAL_OR);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "or()"), NULL );
ASTNode_setName(c, "x");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "or(x)"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "y");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "or(x, y)"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "z");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "or(x, y, z)"), NULL );
safe_free(s);
ASTNode_free(n);
}
示例6: START_TEST
END_TEST
START_TEST (test_FormulaFormatter_multiPlus)
{
char *s;
ASTNode_t *n = ASTNode_create();
ASTNode_t *c = ASTNode_create();
ASTNode_setType(n, AST_PLUS);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "0"), NULL );
safe_free(s);
ASTNode_setName(c, "x");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "x"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "y");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "x + y"), NULL );
safe_free(s);
c = ASTNode_create();
ASTNode_setName(c, "z");
ASTNode_addChild(n, c);
s = SBML_formulaToString(n);
fail_unless( !strcmp(s, "x + y + z"), NULL );
safe_free(s);
ASTNode_free(n);
}
示例7: START_TEST
END_TEST
START_TEST (test_SBML_parseFormula_15)
{
ASTNode_t *r = SBML_parseFormula("foo(1, bar)");
ASTNode_t *c;
fail_unless( ASTNode_getType(r) == AST_FUNCTION , NULL );
fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
fail_unless( ASTNode_getNumChildren(r) == 2 , NULL );
c = ASTNode_getLeftChild(r);
fail_unless( ASTNode_getType (c) == AST_INTEGER, NULL );
fail_unless( ASTNode_getInteger (c) == 1, NULL );
fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
c = ASTNode_getRightChild(r);
fail_unless( ASTNode_getType(c) == AST_NAME , NULL );
fail_unless( !strcmp(ASTNode_getName(c), "bar") , NULL );
fail_unless( ASTNode_getNumChildren(c) == 0 , NULL );
ASTNode_free(r);
}
示例8: CvodeData_freeStructures
/* frees all internal stuff of cvodeData */
static void CvodeData_freeStructures(cvodeData_t * data)
{
int i;
if(data == NULL){
return;
}
/* free sensitivity structure */
if ( data->p != NULL )
free(data->p);
if ( data->sensitivity != NULL ) {
for ( i=0; i<data->neq; i++ )
free(data->sensitivity[i]);
free(data->sensitivity);
}
/* free results structure */
CvodeResults_free(data->results);
/* free current values array */
free(data->value);
/* free event trigger flags */
free(data->trigger);
/* free ODEs */
for ( i=0; i<data->neq; i++ )
ASTNode_free(data->ode[i]);
free(data->ode);
}
示例9: START_TEST
END_TEST
START_TEST (test_Rule_setMath)
{
ASTNode_t *math = SBML_parseFormula("1 + 1");
Rule_setMath(R, math);
fail_unless( Rule_getMath(R) != math );
fail_unless( Rule_isSetMath(R) );
/* Reflexive case (pathological) */
Rule_setMath(R, (ASTNode_t *) Rule_getMath(R));
fail_unless( Rule_getMath(R) != math );
Rule_setMath(R, NULL);
fail_unless( !Rule_isSetMath(R) );
if (Rule_getMath(R) != NULL)
{
fail("Rule_setMath(R, NULL) did not clear ASTNode.");
}
ASTNode_free(math);
}
示例10: copied_AST_free
void copied_AST_free(copied_AST *ast) {
unsigned int i;
if (ast == NULL) {
return;
}
for (i = 0; i < ast->num_of_copied_AST; i++) {
ASTNode_free(ast->ast[i]);
}
free(ast);
}
示例11: translateMathML
/**
* Translates the given MathML into an infix formula. The MathML must
* contain no leading whitespace, but an XML header is optional.
*
* @return the infix formula as a string. The caller owns the memory and
* is responsible for freeing it.
*/
char *
translateMathML (const char* xml)
{
char* result;
ASTNode_t* math;
math = readMathMLFromString(xml);
result = SBML_formulaToString(math);
ASTNode_free(math);
return result;
}
示例12: START_TEST
END_TEST
START_TEST (test_Priority_setMath2)
{
ASTNode_t *math = ASTNode_createWithType(AST_DIVIDE);
int i = Priority_setMath(P, math);
fail_unless( i == LIBSBML_INVALID_OBJECT);
fail_unless( !Priority_isSetMath(P) );
ASTNode_free(math);
}
示例13: START_TEST
END_TEST
START_TEST (test_Constraint_setMath2)
{
ASTNode_t *math = ASTNode_createWithType(AST_DIVIDE);
int i = Constraint_setMath(C, math);
fail_unless( i == LIBSBML_INVALID_OBJECT);
fail_unless( !Constraint_isSetMath(C) );
ASTNode_free(math);
}
示例14: START_TEST
END_TEST
START_TEST (test_EventAssignment_setMath2)
{
ASTNode_t *math = ASTNode_createWithType(AST_DIVIDE);
int i = EventAssignment_setMath(E, math);
fail_unless( i == LIBSBML_INVALID_OBJECT);
fail_unless( !EventAssignment_isSetMath(E) );
ASTNode_free(math);
}