{"id":17222959,"url":"https://github.com/cheind/cppopt","last_synced_at":"2026-03-15T01:56:53.106Z","repository":{"id":14576043,"uuid":"17292288","full_name":"cheind/cppopt","owner":"cheind","description":"Numerical optimization in C++","archived":false,"fork":false,"pushed_at":"2014-03-15T18:26:25.000Z","size":368,"stargazers_count":40,"open_issues_count":1,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-10T01:33:43.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cheind.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":"2014-02-28T16:35:02.000Z","updated_at":"2025-04-03T14:49:11.000Z","dependencies_parsed_at":"2022-09-19T01:31:58.412Z","dependency_job_id":null,"html_url":"https://github.com/cheind/cppopt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cheind/cppopt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fcppopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fcppopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fcppopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fcppopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheind","download_url":"https://codeload.github.com/cheind/cppopt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fcppopt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013591,"owners_count":26085389,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-15T04:06:53.223Z","updated_at":"2025-10-13T04:11:08.872Z","avatar_url":"https://github.com/cheind.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cppopt\n\ncppopt is lightweight library for numerical optimization in C++11. The main focus of this library is to provide concise and easy to follow implementations of various optimization algorithms. The library can easily be integrated into other projects as it is header only.\n\n## Coverage\n\nCurrently the following algorithms are implemented for univariate and multivariate functions\n - Gradient Descent\n - Newton-Raphson\n - Gauss-Newton for non-linear least squares.\n\n## Conventions\n\nLet *f* be a [function](http://en.wikipedia.org/wiki/Function_(mathematics)) with N dimensional input variables and M dimensional outputs. \nWe say that \n - *f* is univariate if `N == 1` and multivariate if `N \u003e 1`\n - *f* is scalar valued if `M == 1` and vector valued if `M \u003e 1`\n\nThe first order derivatives of a multivariate scalar valued function is called the [gradient vector](http://en.wikipedia.org/wiki/Gradient). \nThe first order derivatives of a vector valued function is called the [Jacobian](http://de.wikipedia.org/wiki/Jacobi-Matrix) matrix. \nThe second order derivatives of a multivariate scalar valued function is called the [Hessian](http://en.wikipedia.org/wiki/Hessian_matrix) matrix.\n\nThroughout cppopt we use the following conventions\n - input variables are repesented by `Nx1` column vectors\n - outputs are represented by `Mx1` column vectors\n - gradients are represented by `Nx1` column vectors\n - Jacobians are represented by `MxN` matrices\n - Hessians are represented by `NxN` matrices\n\n## Usage\n\nWith cppopt functions and derivatives are defined through lambda expression. For example the lambda expression for evaluating the gradient of the multivariate polynom\n    \n    f(x,y) = x^2 + y^2 + 2x + 8y\n\nwith \n\n    df/dx = 2x + 2\n    df/dy = 2y + 8\n\nis given by\n\n    // Gradient of f(x,y) = x^2 + y^2 + 2x + 8y\n    cppopt::F df = [](const cppopt::Matrix \u0026x) -\u003e cppopt::Matrix {\n        cppopt::Matrix d(2, 1);\n        \n        d(0) = 2.f * x(0) + 2.f;\n        d(1) = 2.f * x(1) + 8.f;\n        \n        return d;\n    };\n\n\nThis lambda expression can then be passed as an argument to various optimization routines as shown below.\n\n    // Start solution\n    cppopt::Matrix x(2, 1);\n    x(0) = -3.f;\n    x(1) = -2.f;\n\n    // Perform one step using gradient descent\n    cppopt::gradientDescent(df, x, 0.01f);\n\n\n## Dependencies\n\nThe only dependency for cppopt is the header only Eigen library (http://eigen.tuxfamily.org).\n\n## Unclassified Links\nLinks of interest I found during the course of developing cppopt\n\nhttp://pages.cs.wisc.edu/~ferris/cs730/chap3.pdf\nhttp://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf\nhttp://www.itl.nist.gov/div898/handbook/pmd/section1/pmd143.htm\nhttp://www.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf\nhttp://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.47.8633\u0026rep=rep1\u0026type=pdf\nhttp://www2.imm.dtu.dk/pubdb/views/edoc_download.php/3215/pdf/imm3215.pdf\n\nRegularization and weighting\nhttp://see.stanford.edu/materials/lsoeldsee263/07-ls-reg.pdf\n\nConvergence issues:\nhttps://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_model_sect039.htm\nhttp://www.trentfguidry.net/post/2009/08/12/Nonlinear-Least-Squares-Regression-Levenberg-Marquardt.aspx","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fcppopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheind%2Fcppopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fcppopt/lists"}