Description
Test some exceptional cases here We use the principal branch of arccos, corresponding to arccos(-1) = PI arccos( 0) = PI/2 arccos( 1) = 0
Small Model of Type : GAMS
Category : GAMS Test library
Main file : fnacosx.gms includes : fnset_x.inc [html] fntest_x.inc [html]
$title 'Test correctness of arccos intrinsic eXceptions' (FNACOSX,SEQ=271)
$onText
Test some exceptional cases here
We use the principal branch of arccos, corresponding to
arccos(-1) = PI
arccos( 0) = PI/2
arccos( 1) = 0
ENUM VAL
---- ---
rcOK 0
rcFUNC 1
rcGRAD 2
rcHESS 3
rcSYSTEM 4
ecOK 0
ecDOMAIN 1
ecSINGULAR 2
ecOVERFLOW 3
ecSIGLOSS 4
$offText
$include fnset_x.inc
reps = 1e-13;
relToInput = 0;
set T / t1 * t6 /;
$set OFLO 1.e299
table data(T,V)
x f_ fx_ fxx_ rc_ ec_
t1 -2 1 1
t2 -1.5 1 1
t3 -1 3.141592653589793 -%OFLO% %OFLO% 2 2
t4 1 0 -%OFLO% -%OFLO% 2 2
t5 1.5 1 1
t6 2 1 1
;
loop {T,
data(T, 'f') = arccos.value( data(T,'x'));
data(T, 'fx') = arccos.grad(1: data(T,'x'));
data(T,'fxx') = arccos.hess(1:1:data(T,'x'));
data(T, 'rc') = mathlastrc;
data(T, 'ec') = mathlastec;
};
display data;
abort$(execerror lt 6)
'Should get function evaluation errors';
execerror = 0;
$include fntest_x.inc