eval03.gms : test constant compile time evaluation functions

**Description**

Functions: abs ceil cos exp fact floor frac IfThen log log2 log10 max mod mod PI power round sign sin sleep sqr sqrt tan trunc ** ** Additional tests are welcome ** ** ** Contributor: Alex

**Small Model of Type : ** GAMS

**Category :** GAMS Test library

**Main file : ** eval03.gms

```
$title test constant compile time evaluation functions (EVAL03,SEQ=462)
$ontext
Functions:
abs ceil cos exp fact floor frac IfThen log log2
log10 max mod mod PI power round sign sin sleep
sqr sqrt tan trunc
** ** ** Additional tests are welcome ** ** **
Contributor: Alex
$offtext
$ondollar
set f / abs,ceil,cos,exp,fact,floor,frac,ifthen,log,log2,log10,max,min,mod,
power,round,sign,sin,sqr,sqrt,tan,trunc /
c / 1*15 /
v / calculated, expected /;
$onundf
table res(f,c,v) calculated and expected function values
calculated expected
abs.1 [abs(-inf)] inf
abs.2 [abs(+inf)] inf
abs.3 [abs(undf)] undf
ceil.1 [ceil(-inf)] -inf
ceil.2 [ceil(+inf)] inf
ceil.3 [ceil(undf)] undf
ceil.4 [ceil(0)] 0
ceil.5 [ceil(1.5)] 2
ceil.6 [ceil(-1.5)] -1
cos.1 [cos(-inf)] undf
cos.2 [cos(+inf)] undf
cos.3 [cos(undf)] undf
exp.1 [exp(-inf)] 0
exp.2 [exp(+inf)] inf
exp.3 [exp(undf)] undf
exp.4 [exp(0)] 1
fact.1 [fact(-inf)] undf
fact.2 [fact(+inf)] undf
fact.3 [fact(undf)] undf
fact.4 [fact(0)] 1
fact.5 [fact(167)] undf
floor.1 [floor(-inf)] -inf
floor.2 [floor(+inf)] inf
floor.3 [floor(undf)] undf
floor.4 [floor(0)] 0
floor.5 [floor(1.5)] 1
floor.6 [floor(-1.5)] -2
frac.1 [frac(-inf)] undf
frac.2 [frac(+inf)] undf
frac.3 [frac(undf)] undf
ifthen.1 [ifthen(-inf,1,2)] 1
ifthen.2 [ifthen(+inf,1,2)] 1
ifthen.3 [ifthen(undf,1,2)] undf
ifthen.4 [ifthen(0,undf,4)] 4
ifthen.5 [ifthen(1,undf,5)] undf
ifthen.6 [ifthen(0,6,undf)] undf
ifthen.7 [ifthen(1,7,undf)] 7
log.1 [log(-inf)] undf
log.2 [log(-1)] undf
log.3 [log(0)] -inf
log.4 [log(+inf)] inf
log.5 [log(undf)] undf
log2.1 [log2(-inf)] undf
log2.2 [log2(-1)] undf
log2.3 [log2(0)] -inf
log2.4 [log2(+inf)] inf
log2.5 [log2(undf)] undf
log10.1 [log10(-inf)] undf
log10.2 [log10(-1)] undf
log10.3 [log10(0)] -inf
log10.4 [log10(+inf)] inf
log10.5 [log10(undf)] undf
max.1 [max(-inf,inf)] inf
max.2 [max(undf,0)] undf
max.3 [max(0,undf)] undf
max.4 [max(-1,1)] 1
max.5 [max(-inf,1)] 1
max.6 [max(inf,1)] inf
max.7 [max(-inf,1,inf)] inf
min.1 [min(-inf,inf)] -inf
min.2 [min(undf,0)] undf
min.3 [min(0,undf)] undf
min.4 [min(-1,1)] -1
min.5 [min(-inf,1)] -inf
min.6 [min(inf,1)] 1
min.7 [min(inf,1,5)] 1
mod.1 [mod(-inf,inf)] undf
mod.2 [mod(undf,0)] undf
mod.3 [mod(0,undf)] undf
mod.4 [mod(-1,1)] 0
mod.5 [mod(-inf,1)] undf
mod.6 [mod(inf,1)] undf
power.1 [power(-inf,inf)] inf
power.2 [power(undf,0)] undf
power.3 [power(0,undf)] undf
power.4 [power(-1,1)] -1
power.5 [power(-inf,2)] inf
power.6 [power(inf,2)] inf
power.7 [power(3,1.5)] undf
power.8 [power(10,0)] 1
power.9 [power(-10,0)] 1
power.10 [power(0,0)] 1
power.11 [power(0.5,inf)] 0
power.12 [power(-0.5,inf)] 0
power.13 [power(0.5,-1)] 2
power.14 [power(-inf,3)] -inf
power.15 [power(0,-inf)] inf
round.1 [round(-inf,inf)] undf
round.2 [round(undf,0)] undf
round.3 [round(55.75,inf)] undf
round.4 [round(inf,2)] inf
round.5 [round(-inf,-10)] -inf
* the 55.55 caused problems, isolated in eval07
* round.6 [round(55.55,1)] 55.5
round.6 [round(55.75,1)] 55.8
round.7 [round(55.75,0)] 56
round.8 [round(55.75,-1)] 60
round.9 [round(55.75,-2)] 100
round.10 [round(55.75,-3)] 0
sign.1 [sign(-inf)] -1
sign.2 [sign(+inf)] 1
sign.3 [sign(undf)] undf
sign.4 [sign(0)] 0
sin.1 [sin(-inf)] undf
sin.2 [sin(+inf)] undf
sin.3 [sin(undf)] undf
sin.4 [sin(0)] 0
sqr.1 [sqr(-inf)] inf
sqr.2 [sqr(+inf)] inf
sqr.3 [sqr(undf)] undf
sqr.4 [sqr(0)] 0
sqrt.1 [sqrt(-inf)] undf
sqrt.2 [sqrt(+inf)] inf
sqrt.3 [sqrt(undf)] undf
sqrt.4 [sqrt(0)] 0
sqrt.5 [sqrt(-1)] undf
tan.1 [tan(-inf)] undf
tan.2 [tan(+inf)] undf
tan.3 [tan(undf)] undf
tan.4 [tan(0)] 0
trunc.1 [trunc(-inf)] -inf
trunc.2 [trunc(+inf)] inf
trunc.3 [trunc(undf)] undf
trunc.4 [trunc(55.55)] 55
trunc.5 [trunc(-55.55)] -55
Parameters diff(f,c,v) differences; set fc(f,c) differences;
fc(f,c) = res(f,c,'calculated') <> res(f,c,'expected');
diff(fc,v) = res(fc,v);
display diff;
abort$card(diff) 'results do not match';
```