Hi everyone,
First of all, thanks very much for GSLL. It's impressively
comprehensive, and it's making my life a lot easier.
I've been using `gsl:make-multi-dimensional-minimizer-f' in one of my
projects for a while now, and I'm looking at switching to one of the
gradient-based methods instead. However, I can't figure out how
SCALARSP works with the f-and-gradient function.
As a very simple example, consider the function F(x1 x2) = x1^2 + x2^3:
(defun f (x1 x2)
(+ (* x1 x1) (* x2 x2 x2)))
For the function-and-gradient function, I need to return the value at
[x1 x2], plus a vector of 2 partial derivatives. In total that's 3
items, so I had thought that the following function would work:
(defun h (x1 x2)
(values (+ (* x1 x1) (* x2 x2 x2))
(* 2 x1)
(* 3 x2 x2)))
However, when I try to use it like so:
(gsl:make-multi-dimensional-minimizer-fdf gsl:+vector-bfgs2+ 2 '(f g
h) #m(9.0 9.0) 0.1d0 0.1d0 t)
I get a TYPE-ERROR: The value NIL is not of type DOUBLE-FLOAT. I'm
fairly sure that my definition of H is the problem here, because when
I trace F, G, and H, H is the only function that gets called.
I've also tried having H return F(X) as the first value and the
gradient vector as the second value, but no dice. (SBCL complains
that a double-float vector is not a double-float, which is true. :)
I'm running SBCL and the most recent version of GSLL (I pulled from
the master branch about an hour ago). Could anyone give me a hint as
to what I'm doing wrong here? I could always implement using
non-scalarsp functions, but if that's the only fix, then it seems
pointless for make-multi-dimensional-minimizer-fdf to take a scalarsp
argument in the first place.
Thanks very much!
James