How to use lbfgs from math/lbfgs?

Viewed 69

I'm trying to use the function lbfgs_jlbfgs_ but cannot find a documentation. A naive approach to call this function without arguments gives

'"/usr/share/j/9.01/addons/math/lbfgs/lib/liblbfgs.so" lbfgs_  n *x *x *d *d *d *x *d *x *d *d *d *x'&cd

Is there any indication of n, *x and *d?

A plausible documentation is on github. The number of arguments seems to match, but the order doesn't seem to match. A specification of the particular order of the arguments would be equally helpful.

2 Answers

The math/lbfgs addon has just been updated. Look again and you should see more comments and a test folder with examples.

You don't need to call lbfgs_jlbfgs_; this library also populates the z namespace, so lbfgs is enough to use it. What you see from lbfgs_jlbfgs_ is its definition, which is a string describing an FFI call and cd which invokes the FFI call according to that string, with the arguments you provide.

Such strings are described at https://code.jsoftware.com/wiki/Guides/DLLs/Calling_DLLs

The first n is the return value, and then all the rest are array (*) arguments of either integers (x) or floats (d).

I'm not familiar with this library is supposed to do at all, but here's a successful use of the function with probably meaningless arguments:

   lbfgs 1 1 ; 2 2 ; 3.0 3.0 ; 4.0 4.0 ; 5.0 5.0 ; 6 6 ; 7.0 7.0 ; 8 8 ; 9.0 9.0 ; 10.0 10.0 ; 11.0 1.0 ; 13 13
*************************************************
  N=    1   NUMBER OF CORRECTIONS= 2
       INITIAL VALUES
 F=  4.000E+00   GNORM=  5.000E+00
*************************************************

   I   NFN    FUNC        GNORM       STEPLENGTH

┌─┬───┬───┬────┬───┬───┬───┬───┬───┬───┬─────┬───┬────┐
│0│1 1│2 2│_4 3│4 4│5 5│6 6│3 7│8 8│9 9│10 10│5 1│1 13│
└─┴───┴───┴────┴───┴───┴───┴───┴───┴───┴─────┴───┴────┘
Related