public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Alxneit-Kamber Ivo" <ivo.alxneit@psi.ch>
To: <gsl-discuss@sources.redhat.com>
Subject: possible design weekness
Date: Fri, 09 Mar 2007 13:58:00 -0000	[thread overview]
Message-ID: <1173448719.10868.3.camel@pc446.psi.ch> (raw)

[-- Attachment #1: Type: text/plain, Size: 2104 bytes --]

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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2007-03-09 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-09 13:58 Alxneit-Kamber Ivo [this message]
2007-03-12 21:26 ` Brian Gough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1173448719.10868.3.camel@pc446.psi.ch \
    --to=ivo.alxneit@psi.ch \
    --cc=gsl-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).