{"id":18046594,"url":"https://github.com/ltla/powerit","last_synced_at":"2026-03-10T01:32:36.067Z","repository":{"id":82716820,"uuid":"486783776","full_name":"LTLA/powerit","owner":"LTLA","description":"Lightweight C++ library for power iterations","archived":false,"fork":false,"pushed_at":"2024-09-02T19:36:35.000Z","size":723,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-12T15:03:38.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ltla.github.io/powerit","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LTLA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-29T00:03:10.000Z","updated_at":"2024-09-02T19:36:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e7d1b8c-0a5d-46df-a340-bdfc79156218","html_url":"https://github.com/LTLA/powerit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/LTLA/powerit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2Fpowerit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2Fpowerit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2Fpowerit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2Fpowerit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LTLA","download_url":"https://codeload.github.com/LTLA/powerit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2Fpowerit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30320889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-30T19:08:04.406Z","updated_at":"2026-03-10T01:32:36.047Z","avatar_url":"https://github.com/LTLA.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Power iterations in C++\n\n![Unit tests](https://github.com/LTLA/powerit/actions/workflows/run-tests.yaml/badge.svg)\n![Documentation](https://github.com/LTLA/powerit/actions/workflows/doxygenate.yaml/badge.svg)\n[![Codecov](https://codecov.io/gh/LTLA/powerit/branch/master/graph/badge.svg?token=quUWNz5h2u)](https://codecov.io/gh/LTLA/powerit)\n\n## Overview\n\nNot much to say here, this repository just contains a header-only C++ library to perform power iterations.\nIt's a quick-and-dirty method of getting the first eigenvector from a diagonalizable matrix - most typically from a covariance matrix, to get the first principal component.\nWell, maybe it's not so quick, but it doesn't add any dependencies and it'll get the job done.\nAnd sometimes that's enough.\n\n## Quick start\n\nThis is a header-only library, so usage is pretty simple:\n\n```cpp\n#include \"powerit/powerit.hpp\"\n#include \u003crandom\u003e\n\n// Fill up the input matrix (row-major).\nsize_t ndim = 10;\nstd::vector\u003cdouble\u003e matrix(ndim * ndim);\n\n// Compute the power iterations.\nstd::vector\u003cdouble\u003e eigenvector(ndim);\nstd::mt19937_64 rng(10);\n\nauto info = powerit::compute(\n    order, \n    matrix.data(), \n    /* row_major = */ true, \n    eigenvector.data(), \n    rng, \n    powerit::Options()\n);\n\ninfo.value; // estimate of the first eigenvalue\ninfo.iterations; // number of iterations required for convergence.\n```\n\nUsers can tune the number of iterations, tolerance, and number of threads via the `Options` argument.\nCheck out the [API reference](https://ltla.github.io/powerit) for more information.\n\n## Building projects \n\n### CMake with `FetchContent`\n\nIf you're using CMake, you just need to add something like this to your `CMakeLists.txt`:\n\n```cmake\ninclude(FetchContent)\n\nFetchContent_Declare(\n  powerit \n  GIT_REPOSITORY https://github.com/LTLA/powerit\n  GIT_TAG master # or any version of interest\n)\n\nFetchContent_MakeAvailable(powerit)\n```\n\nThen you can link to **powerit** to make the headers available during compilation:\n\n```cmake\n# For executables:\ntarget_link_libraries(myexe ltla::powerit)\n\n# For libaries\ntarget_link_libraries(mylib INTERFACE ltla::powerit)\n```\n\n### CMake with `find_package()`\n\nTo install the library, clone the desired version of this repository and run:\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake .. -DPOWERIT_TESTS=OFF\ncmake --build . --target install\n```\n\nThen, we can use `find_package()` as usual:\n\n```cmake\nfind_package(ltla_powerit CONFIG REQUIRED)\ntarget_link_libraries(mylib INTERFACE ltla::powerit)\n```\n\nBy default, this will use `FetchContent` to fetch all external dependencies (listed in [`extern/CMakeLists.txt`](extern/CMakeLists.txt)).\nIf you want to install them manually, use `-DPOWERIT_FETCH_EXTERN=OFF`.\n\n### Manual\n\nIf you're not using CMake, the simple approach is to just copy the files in `include/` - either directly or with Git submodules - and include their path during compilation with, e.g., GCC's `-I`.\nThis requires the external dependencies listed in [`extern/CMakeLists.txt`](extern/CMakeLists.txt), which also need to be made available during compilation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltla%2Fpowerit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltla%2Fpowerit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltla%2Fpowerit/lists"}