On Wed, Apr 7, 2010 at 4:38 PM, Piet de Jong <[email protected]> wrote: > Thanks for the response. I downloaded the routine using the package manager > and J6.02. > > What I don't get is that the in the example lbfgs_test the routine is > called with parameter > values that do not correspond to what is stated in the provided > FORTRAN description of the calling sequence.
So... looking at math/lbfgs, I see: path=: jpath '~addons\math\lbfgs\' dll=:'"',path,'lbfgs.dll" ' ... call=: 4 : 0 xx=. dll,x,' + i ',(+:#y)$' *' r=. xx cd LASTIN=: , each y ... and, I see: 'N M X F G DIAGCO DIAG IPRINT EPS XTOL W IFLAG'=.r=.'lbfgs_' call (N;M;X;F;G;DIAGCO;DIAG;IPRINT;EPS;XTOL;W;IFLAG) So that means that the calling signature will be "...lbfgs.dll" lbfgs_ + i * * * * * * * * * * * * According to http://www.jsoftware.com/help/user/call_procedure.htm this means that under windows this routine uses the __cdecl calling convention, returns a 4 byte integer result and takes 12 pointers as arguments. I modified lbfgs_test to capture the data being passed to "call" and when I interrupted the program the values were all one dimension arrays, with dimensions: N: 1 M: 1 X: 2000 F: 1 G: 2000 DIAGCO: 1 DIAG: 2000 IPRINT: 2 EPS: 1 XTOL: 1 W: 60000 IFLAG: 1 Now... I do not know how lbfgs works, and I do not know if there is some windows magic that happens to pass the size of these arrays in a __cdecl call, or if the pointers to these values are treated as pointers regions of memory where extra values off the end would be ignored. But it very much looks like this code is directly calling lbfgs.dll and not doing much of any thing special to the data on its way out. > In particular and as an example, the dimension on X does not appear to > be N but something much bigger. Hence the example is hard, if not > impossible to follow. It might be useful to have a much simpler > example. I still can't get a simple example to work since I don't > appear to understand the calling parameters. My current best guess is that (if N is supposed to be the number of elements provided by X), values after the first 100 (the value for N) are ignored by lbfgs.dll. Do you see anything which would contradict this point of view? Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
