[plt-scheme] Specifying a callback that takes a f64vector

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu Apr 30 10:53:18 EDT 2009

Another question...

I'm attempting to wrap a fairly simple optimisation library[1] with
the FFI. The main function, lm_minimize, optimises the parameters of a
user supplied function (pointer). I'd like to specify this function in
Scheme. The typedef is:

typedef void (lm_evaluate_ftype) (double *par, int m_dat, double *fvec,
				  void *data, int *info);

The wrapping I'm using is:

(define _lm_evaluate_ftype
  (_fun (params : (_f64vector i))
        (n-points : _int)
        (_f64vector i)
        _scheme
        (_ptr i _int)
    -> _void))

I don't see how this can possibly work -- the FFI won't know the size
of the arrays to allocate. However the FFI won't let me specify the
size of an input f64vector [very bad error message here, BTW.] So what
am I supposed to do?

N.

[1] http://www.messen-und-deuten.de/lmfit/index.html


Posted on the users mailing list.