fnslrec.gms : Test correctness of slrec intrinsic

Description

slrec(x,S) = 1/x           if x >= S
             1/S - r/S^2   otherwise, r = x - S
for S >= 1e-10, default S = 1e-10.

Contributor: Steve, Mar 2017


Small Model of Type : GAMS


Category : GAMS Test library


Main file : fnslrec.gms   includes :   fnset_xy.inc [htmlfntest_xy.inc [html]

$title 'Test correctness of slrec intrinsic' (FNSLREC,SEQ=725)

$ontext
slrec(x,S) = 1/x           if x >= S
             1/S - r/S^2   otherwise, r = x - S
for S >= 1e-10, default S = 1e-10.

Contributor: Steve, Mar 2017
$offtext

$include fnset_xy.inc

$gdxin fnslrec
$load aeps reps relToInput T data
$gdxin

loop {T,
  data(T,  'f')  = slrec.value(   data(T,'x'),data(T,'y'));
  data(T, 'fx')  = slrec.grad(1:  data(T,'x'),data(T,'y'));
  data(T, 'fy')  = slrec.grad(2:  data(T,'x'),data(T,'y'));
  data(T,'fxx')  = slrec.hess(1:1:data(T,'x'),data(T,'y'));
  data(T,'fxy')  = slrec.hess(1:2:data(T,'x'),data(T,'y'));
  data(T,'fyx')  = slrec.hess(2:1:data(T,'x'),data(T,'y'));
  data(T,'fyy')  = slrec.hess(2:2:data(T,'x'),data(T,'y'));
  data(T, 'rc')  = mathlastrc;
  data(T, 'ec')  = mathlastec;
};

$include fntest_xy.inc