fntest_x.inc : intrinsics tests for f(x)

File : fntest_x.inc  used by :  fnsqr.gms [html]   fnexp.gms [htmlfnlog.gms [html]   fnlog2.gms [htmlfnlog10.gms [html]   fnsqrt.gms [htmlfncos.gms [html]   fnsin.gms [htmlfnsinh.gms [html]   fncosh.gms [htmlfntanh.gms [html]   fnfact.gms [htmlfngamma.gms [html]   fngamma2.gms [html]   fnatan.gms [htmlfnerrf.gms [html]   fnerrf2.gms [htmlfnentro.gms [html]   fnentro2.gms [html]   fnsigmo.gms [htmlfnsigmo2.gms [html]   fntan.gms [htmlfnacos.gms [html]   fnacosx.gms [htmlfnasin.gms [html]   fnasinx.gms [htmlfncentr.gms [html]   fncentr2.gms [html]   fncentr3.gms [html]   fnloggamma.gms [html]   fnlogit.gms [html]

* N.B.  This file may be included multiple times,
*       so put declarations in fnset_x.inc if necessary

$if not defined reps  reps  = 0;
$if not defined reps0 reps0 = reps;
$if not defined reps1 reps1 = reps;
$if not defined reps2 reps2 = reps;
$if not defined aeps  aeps  = 0;
$if not defined aeps0 aeps0 = aeps;
$if not defined aeps1 aeps1 = aeps;
$if not defined aeps2 aeps2 = aeps;
$if not defined relToInput relToInput = 0;

* option zeroRes = 2.0e-299;
set TT(T);

data(T,  'f_a') = abs(data(T,  'f')-data(T,  'f_'));
data(T, 'fx_a') = abs(data(T, 'fx')-data(T, 'fx_'));
data(T,'fxx_a') = abs(data(T,'fxx')-data(T,'fxx_'));
if {relToInput,
  tmp(T) = max(1,abs(data(T,'x')));
  data(T,  'f_r') = data(T,  'f_a') / tmp(T);
  data(T, 'fx_r') = data(T, 'fx_a') / tmp(T);
  data(T,'fxx_r') = data(T,'fxx_a') / tmp(T);
else
  tmp(T) = abs(data(T,'f_'));
  TT(T) = tmp(T) > 0;
  data(T,   'f_r') = INF;
  data(T ,  'f_r')$(data(T,  'f_a') eq 0) = 0;
  data(TT,  'f_r') = data(TT,   'f_a') / tmp(TT);

  tmp(T) = abs(data(T,'fx_'));
  TT(T) = tmp(T) > 0;
  data(T,  'fx_r') = INF;
  data(T , 'fx_r')$(data(T, 'fx_a') eq 0) = 0;
  data(TT, 'fx_r') = data(TT,  'fx_a') / tmp(TT);

  tmp(T) = abs(data(T,'fxx_'));
  TT(T) = tmp(T) > 0;
  data(T, 'fxx_r') = INF;
  data(T ,'fxx_r')$(data(T,'fxx_a') eq 0) = 0;
  data(TT,'fxx_r') = data(TT, 'fxx_a') / tmp(TT);
};
data(T,'rc_e') = abs(data(T,'rc')-data(T,'rc_'));
data(T,'ec_e') = abs(data(T,'ec')-data(T,'ec_'));

badTV(T,V) = no;
badTV(T,fV(V))   = ((data(T,  'f_a') > aeps0) and (data(T,  'f_r') > reps0));
badTV(T,fxV(V))  = ((data(T, 'fx_a') > aeps1) and (data(T, 'fx_r') > reps1));
badTV(T,fxxV(V)) = ((data(T,'fxx_a') > aeps2) and (data(T,'fxx_r') > reps2));
badTV(T,rcV(V))  = data(T,'rc_e');
badTV(T,ecV(V))  = data(T,'ec_e');
badT(T) = sum{badTV(T,V), yes};
badTV(badT,inV) = yes;
failures(T,V) = 0;
fail2(T,V) = 0;
failures(badT,V) = data(badT,V);
fail2(badTV) = failures(badTV);
display 'failed tests', failures, fail2;
* display data;
scalar nTests, nErrors;
nTests = card(T);
nErrors = card(badT);
display 'absolute tolerance: ', aeps0, aeps1, aeps2;
display 'relative tolerance: ', reps0, reps1, reps2;
display 'data points tested: ', nTests;
display '            errors: ', nErrors;
$if set FAILGDX   execute_unload '%FAILGDX%', badT, failures, fail2, aeps, aeps0, aeps1, aeps2, reps, reps0, reps1, reps2;

abort$(nErrors) 'There were errors';