funcs5.gms : Test correctness of intrinsic functions

Description


Small Model of Type : GAMS


Category : GAMS Test library


Main file : funcs5.gms

$title test correctness of intrinsic functions (FUNCS5,SEQ=149)

set fn 'intrinsic functions with tests that pass' /
  sqr
  exp
  log
  log2
  log10
  sqrt
  cos
  sin
  atan       'arctan'
  errf
  errf2      'errf'
  power
  fact
  pi
  ncpf
  ncpf2      'ncpf'
  ncpcm
  ncpcm2     'ncpcm'
  entro      'entropy'
  entro2     'entropy'
  sigmo      'sigmoid'
  sigmo2     'sigmoid'
  rpow       'rpower'
  rpow2      'rpower'
  rpow3      'rpower'
* edist       not yet implemented
  sllog10    'sllog10'
  sllog102   'sllog10'
  sqlog10    'sqlog10'
  sqlog102   'sqlog10'
  slexp      'slexp'
  slexp2     'slexp'
  sqexp      'sqexp'
  sqexp2     'sqexp'
  slrec      'slrec'
  slrec2     'slrec'
  sqrec      'sqrec'
  sqrec2     'sqrec'
* cvpower     not yet implemented
  vcpow      'vcpower'
  vcpow2     'vcpower'
*  centr      'centropy, large x'
*  centr2     'centropy, small x'
  centr3     'centropy, typical inputs'
  centr4     'centropy, typical inputs'
  centr5     'centropy, nice inputs'
  centr6     'centropy, very small inputs'
*  centrx     'centropy eXceptions'
  centry     'centropy exceptions'
  gamma      'gamma, positive inputs'
* gamma2      DOES NOT PASS THE TEST
  loggamma   'loggamma, exceptional and normal inputs'
  beta       'beta, easy inputs and wide tols'
  logbeta    'logbeta, easy inputs and wide tols'
* gammareg    not yet implemented
* betareg     not yet implemented
  sinh
  cosh
  tanh
  spowx      'signpower'
  spown      'signpower'
  ncpvus     'NcpVUsin'
  ncpvup     'NcpVUpow'
  ncpvux     'NcpVUsin and NcpVUpow'
  binomial   'binomial'
  tan
  acos       'arccos'
  acosx      'arccos eXceptions'
  asin       'arcsin'
  asinx      'arcsin eXceptions'
  atan2      'arctan2'
  atan2n     'arctan2 compared to numerical derivs'
  atan2x     'arctan2 eXceptions'
  sincosintrv  'sin/cos func/grad interval evals'
  logit      'ln(p/(1-p)'
  lse        'Log of Sum of Exponents max/min'
  lsemax     'ln(exp(x1)+exp(x2)+ ...)'
  lsemaxsc   'ln(exp(t*x1)+exp(t*x2)+ ...) / t'
  lsemin     '-ln(exp(-x1)+exp(-x2)+ ...)'
  lseminsc   '-ln(exp(-t*x1)+exp(-t*x2)+ ...) / t'
/;
SET tfn(fn)    'functions to test';

$if not set FN $goTo allfuncs
SET tfn(fn) / %FN% /;
$goTo have_tfn

$label allfuncs
tfn(fn) = yes;

$label have_tfn

file fp /'fnscript.gms'/;
put fp '$onDollar' /;

loop {fn(tfn),
  put '$call =testlib -q fn' fn.tl:0 /;
  put '$if errorlevel 1 $abort Could not retrieve test fn' fn.tl:0 /;
  put '$call =gams fn' fn.tl:0 ' lo=2 ZeroRes=2e-299 FDDelta=1e-3' /;
  put '$if errorlevel 1 $abort Error running test fn' fn.tl:0 /;
};
putclose fp;

scalar rc;
execute '=gams fnscript lo=%GAMS.lo%';
rc=errorlevel;
abort$rc 'intrinsic function test failed';