From c45367bf6962b090cb87892033a07aefa1b3168d Mon Sep 17 00:00:00 2001 From: stevenj Date: Sat, 25 Aug 2007 13:34:59 -0400 Subject: [PATCH] added simple convex test function darcs-hash:20070825173459-c8de0-c8c1a7b35e0a485dbc9dd535fd18fdab7cef9d00.gz --- test/testfuncs.c | 23 ++++++++++++++++++++++- test/testfuncs.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/test/testfuncs.c b/test/testfuncs.c index fbfbbbc..5e29d92 100644 --- a/test/testfuncs.c +++ b/test/testfuncs.c @@ -270,6 +270,24 @@ static const double sixhumpcamel_lb[2] = {-5,-5}; static const double sixhumpcamel_ub[2] = {5,5}; static const double sixhumpcamel_xmin[2] = {0.08984, -0.71266}; +/****************************************************************************/ +static double convexcosh_f(int n, const double *x, double *grad, void *data) +{ + int i; + double f = 1; + UNUSED(data); + for (i = 0; i < n; ++i) + f *= cosh((x[i] - i) * (i+1)); + if (grad) + for (i = 0; i < n; ++i) + grad[i] = f * tanh((x[i] - i) * (i+1)) * (i+1); + RETURN(f); +} + +static const double convexcosh_lb[10] = {-1,0,0,0,0,0,0,0,0,0}; +static const double convexcosh_ub[10] = {2,3,6,7,8,10,11,13,14,16}; +static const double convexcosh_xmin[10] = {0,1,2,3,4,5,6,7,8,9}; + /****************************************************************************/ /****************************************************************************/ @@ -318,5 +336,8 @@ const testfunc testfuncs[NTESTFUNCS] = { 0.0, "Griewank function" }, { sixhumpcamel_f, NULL, 1, 2, sixhumpcamel_lb, sixhumpcamel_ub, sixhumpcamel_xmin, - -1.03163, "Six-hump camel back function" } + -1.03163, "Six-hump camel back function" }, + { convexcosh_f, NULL, 1, 10, + convexcosh_lb, convexcosh_ub, convexcosh_xmin, + 1.0, "Convex product of cosh functions" } }; diff --git a/test/testfuncs.h b/test/testfuncs.h index 15af0aa..b8256e3 100644 --- a/test/testfuncs.h +++ b/test/testfuncs.h @@ -18,7 +18,7 @@ typedef struct { const char *name; } testfunc; -#define NTESTFUNCS 15 +#define NTESTFUNCS 16 extern const testfunc testfuncs[NTESTFUNCS]; extern int testfuncs_verbose; -- 2.30.2