{"id":16722146,"url":"https://github.com/lostella/liblbfgs","last_synced_at":"2025-07-11T08:30:48.284Z","repository":{"id":35516383,"uuid":"39786754","full_name":"lostella/libLBFGS","owner":"lostella","description":"implemention of the L-BFGS method for smooth unconstrained optimization","archived":false,"fork":false,"pushed_at":"2017-09-09T14:03:34.000Z","size":32,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T22:33:47.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostella.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-27T17:02:54.000Z","updated_at":"2021-04-03T13:49:34.000Z","dependencies_parsed_at":"2022-09-11T14:51:54.234Z","dependency_job_id":null,"html_url":"https://github.com/lostella/libLBFGS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostella%2FlibLBFGS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostella%2FlibLBFGS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostella%2FlibLBFGS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostella%2FlibLBFGS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostella","download_url":"https://codeload.github.com/lostella/libLBFGS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225708257,"owners_count":17511634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T22:33:46.412Z","updated_at":"2024-11-21T09:42:10.535Z","avatar_url":"https://github.com/lostella.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libLBFGS\n\n[![Build Status](https://travis-ci.org/lostella/libLBFGS.svg)](https://travis-ci.org/lostella/libLBFGS)\n\n`libLBFGS` is a small piece of C code computing\nlimited-memory BFGS (also known as L-BFGS) directions for minimizing smooth functions. Contains a MATLAB interface [briefly documented here](#matlab-interface).\n\nThe library implements the necessary functions to allocate a FIFO buffer for some pairs of vectors to be stored;\nto cyclically push and pull pairs `(s, y)` of vectors into the buffer;\nto compute matrix vector products with the resulting approximate inverse Hessian matrix.\n\nFor more information about the L-BFGS method, see:\n\n* J. Nocedal, \"Updating quasi-Newton matrices with limited storage,\" in *Mathematics of Computation*, vol. 35, issue 151, pp. 773-782 (1980). [Available here](http://www.ams.org/journals/mcom/1980-35-151/S0025-5718-1980-0572855-7/)\n* D. Liu, J. Nocedal, \"On the limited memory BFGS method for large scale optimization,\" in *Mathematical Programming*, vol. 45, pp. 503-528 (1989). [Available here](http://link.springer.com/article/10.1007%2FBF01589116)\n\n## MATLAB interface\n\nTo setup `libLBFGS` for MATLAB, navigate to `libLBFGS/matlab` from your MATLAB command line and\n\n```matlab\n\u003e\u003e setup_libLBFGS\n\u003e\u003e test_libLBFGS\n```\n\nNow you can use `libLBFGS`. The easiest way is through the `LBFGS` class:\n\n```matlab\nH = LBFGS(n, mem); % create an operator of dimension n and memory mem\nH.push(s, y);      % push a pair (s, y) into the buffer and update the operator\nd = -(H*grad);     % multiply H by (minus) grad, to obtain a search direction\n```\n\n## C interface (Linux/Unix/MacOS X)\n\nTo compile the library simply navigate to its directory and type `make`.\nThis will produce `libLBFGS.o`, that you will need to statically link to your project.\nThe following routines are exported in `libLBFGS.h`:\n\n* `libLBFGS_buffer * libLBFGS_init (int n, int mem);`\n    Initialize a libLBFGS_buffer structure.\n\n    * Parameters\n\n     `int n`: dimension of the vectors to handle\n\n     `int mem`: memory of the buffer\n\n    * Return value\n\n     `libLBFGS_buffer * b`: pointer to the buffer structure\n\n* `int libLBFGS_push (libLBFGS_buffer * b, double * s, double * y);`\n    Pushes a new pair (s, y) into the buffer, and discards the oldest one if necessary.\n\n    * Parameters\n\n     `libLBFGS_buffer * b`: pointer to the buffer structure\n\n     `double * s`: double vector of length n, containing the difference between to points x and x'\n\n     `double * y`: double vector of length n, containing the difference between the two gradients at x and x'\n\n    * Return value\n\n     `int status`: some integer status code\n\n* `void libLBFGS_matvec (libLBFGS_buffer * b, double H0, double * g, double * d);`\n\n    Performs a MATVEC operation between the inverse Hessian approximation stored so far and a given vector.\n\n    * Parameters\n\n     `libLBFGS_buffer * b`: pointer to the buffer structure\n\n     `double H0`: value of the diagonal initial Hessian approximation to use; can be any positive value, a good choice for this is suggested in Nocedal, Wright, \"Numerical Optimization\", eq. (7.20)\n\n     `double * g`: double vector of length n, containing the vector to multiply with the inverse Hessian approximation\n\n     `double * d`: double vector of length n, where to store the result of the matrix-vector product\n\n* `void libLBFGS_reset (libLBFGS_buffer * b);`\n\n    Resets the memory of the given buffer structure.\n\n    * Parameters\n\n     `libLBFGS_buffer * b`: pointer to the buffer structure\n\n* `void libLBFGS_clear (libLBFGS_buffer * b);`\n\n    Deallocates the given buffer structure: all the referenced memory locations will be cleared, including the buffer itself, and the pointer will no longer be usable.\n\n    * Parameters\n\n     `libLBFGS_buffer * b`: pointer to the buffer structure\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostella%2Fliblbfgs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostella%2Fliblbfgs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostella%2Fliblbfgs/lists"}