This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

possible design weekness


Dear all

I have recently been bitten by what seems to be a design weekness in how
the functions (function to be minimized, or system of ODE's) are
defined. These function do not return a status value but the function
value. This prevents to easily notifiy the caller (iterate) of a failure
such as e.g. a domain error of one of its arguments or a failed
malloc().

The function used in the non-linear least squares fit, however is
implemented better as it returns a status value to the caller. Other
parts of the GSL library, multi-dimensional root finding or
one-dimensional minimization, e.g., take a slightly less optimal
aprroach. Here the caller (iterate) checks, if the function value or its
derivative, if applicable, is finite and issues an error otherwise.

I think it would be worthwhile (maybe for a version 2.0) to implement
a common definition for these functions like

status = f(double *result, 'arguments', (void*) parameters);

For a status different from 'GSL_SUCCESS' let the driver either take
care of the failure (this depends on the application/algorithm) or let
it fail propagating the status from the function to the user. Then the
user can handle the situation in his main loop.

I currently have no real idea how to prevent breaking of old user code
by implementing this new interface while keeping the old in place:

- for the 'GSL_XXX_EVAL_YYY' family of macros a simple wrapper would
  do the job. (allways return GSL_SUCCESS for the old style or analyze
  the result and then assign the status to be returned).

- the fact that the new interface has one more argument could probably
  be handled by variable argument functions (never used these).

- how to deal with the fact that the new style function is of different
  type (int instead of double)?

Comments or suggestions?

-- 
Dr. Ivo Alxneit
Laboratory for Solar Technology   phone: +41 56 310 4092
Paul Scherrer Institute             fax: +41 56 310 2688
CH-5232 Villigen                   http://solar.web.psi.ch
Switzerland                   gnupg key: 0x515E30C7

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]