add a limit exp(arg) to the exp function. If arg is larger
than 14 (arbitrarily selected), continue with linear response.
This commit is contained in:
parent
22919ef0bf
commit
8ff478ae45
|
|
@ -166,6 +166,10 @@ typedef struct PTelement {
|
||||||
|
|
||||||
#define PT_STACKSIZE 200
|
#define PT_STACKSIZE 200
|
||||||
|
|
||||||
|
/* limits for exp function */
|
||||||
|
#define EXPARGMAX 14.
|
||||||
|
#define EXPMAX 1202604.284
|
||||||
|
|
||||||
/* And in IFeval.c */
|
/* And in IFeval.c */
|
||||||
|
|
||||||
extern int IFeval(IFparseTree *tree, double gmin, double *result, double *vals, double *derivs);
|
extern int IFeval(IFparseTree *tree, double gmin, double *result, double *vals, double *derivs);
|
||||||
|
|
|
||||||
|
|
@ -434,8 +434,18 @@ static INPparseNode *PTdifferentiate(INPparseNode * p, int varnum)
|
||||||
arg1 = mkf(PTF_SINH, p->left);
|
arg1 = mkf(PTF_SINH, p->left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTF_EXP: /* exp(u) */
|
case PTF_EXP: /* u > EXPARGMAX -> EXPMAX, that is exp(EXPARGMAX), else exp(u) */
|
||||||
arg1 = mkf(PTF_EXP, p->left);
|
arg1 = mkb(PT_TERN,
|
||||||
|
mkf(PTF_GT0, mkb(PT_MINUS, p->left, mkcon(EXPARGMAX))),
|
||||||
|
mkb(PT_COMMA,
|
||||||
|
mkcon(EXPMAX),
|
||||||
|
mkf(PTF_EXP, p->left)));
|
||||||
|
|
||||||
|
#ifdef TRACE
|
||||||
|
printf("debug, %s, returns; ", __func__);
|
||||||
|
printTree(arg1);
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTF_LOG: /* 1 / u */
|
case PTF_LOG: /* 1 / u */
|
||||||
|
|
|
||||||
|
|
@ -217,10 +217,14 @@ PTcosh(double arg)
|
||||||
return (cosh(arg));
|
return (cosh(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Limit the exp: If arg > EXPARGMAX (arbitrarily selected to 14), continue with linear output */
|
||||||
double
|
double
|
||||||
PTexp(double arg)
|
PTexp(double arg)
|
||||||
{
|
{
|
||||||
return (exp(arg));
|
if (arg > EXPARGMAX)
|
||||||
|
return EXPMAX * (arg - EXPARGMAX + 1.);
|
||||||
|
else
|
||||||
|
return (exp(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue