{"id":18046584,"url":"https://github.com/ltla/cppirlba","last_synced_at":"2025-04-10T04:53:49.374Z","repository":{"id":39849019,"uuid":"379184194","full_name":"LTLA/CppIrlba","owner":"LTLA","description":"A C++ port of the IRLBA algorithm, based on the C code in the R package.","archived":false,"fork":false,"pushed_at":"2025-01-16T19:24:43.000Z","size":2556,"stargazers_count":15,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T06:05:00.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ltla.github.io/CppIrlba/","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}},"created_at":"2021-06-22T07:42:43.000Z","updated_at":"2025-01-16T20:29:31.000Z","dependencies_parsed_at":"2022-09-05T08:00:38.075Z","dependency_job_id":"6475c6ae-32ec-412c-b9dd-41dbe6378206","html_url":"https://github.com/LTLA/CppIrlba","commit_stats":{"total_commits":89,"total_committers":2,"mean_commits":44.5,"dds":"0.011235955056179803","last_synced_commit":"dc10a5d34edbb458082896a13fbc419cb9e2eb99"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2FCppIrlba","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2FCppIrlba/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2FCppIrlba/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTLA%2FCppIrlba/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LTLA","download_url":"https://codeload.github.com/LTLA/CppIrlba/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161255,"owners_count":21057553,"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-30T19:08:01.899Z","updated_at":"2025-04-10T04:53:49.348Z","avatar_url":"https://github.com/LTLA.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ library for IRLBA\n\n![Unit tests](https://github.com/LTLA/CppIrlba/actions/workflows/run-tests.yaml/badge.svg)\n![Documentation](https://github.com/LTLA/CppIrlba/actions/workflows/doxygenate.yaml/badge.svg)\n![Irlba comparison](https://github.com/LTLA/CppIrlba/actions/workflows/compare-irlba.yaml/badge.svg)\n[![Codecov](https://codecov.io/gh/LTLA/CppIrlba/branch/master/graph/badge.svg?token=E2AFGW2XDB)](https://codecov.io/gh/LTLA/CppIrlba)\n\n## Overview\n\nThis repository contains a header-only C++ library implementing the Augmented Implicitly Restarted Lanczos Bidiagonalization Algorithm (IRLBA) from Baglama and Reichel (2005).\nIRLBA is a fast and memory-efficient method for truncated singular value decomposition, and is particularly useful for approximate principal components analysis of large matrices.\nThe code here is derived from the C code in the [**irlba** R package](https://github.com/bwlewis/irlba), refactored to use the [Eigen](http://eigen.tuxfamily.org/) library for matrix algebra.\n\n## Quick start\n\nUsing this library is as simple as including the header file in your source code:\n\n```cpp\n#include \"irlba/irlba.hpp\"\n\nirlba::Options opt;\n// optional; specify the workspace, etc.\nopt.extra_work = 20;\nopt.max_iterations = 50;\n\n// Get the first 5 singular triplets:\nauto result = irlba::compute(mat, 5, opt);\nresult.U; // left singular vectors\nresult.V; // right singular vectors\nresult.S; // singular values\n```\n\nTo perform a PCA:\n\n```cpp\n// Get the first 5 principal components without scaling:\nauto res = irlba::compute(mat, true, false, 5, opt);\nEigen::MatrixXd components = res.U;\ncomponents *= res.S.asDiagonal();\n```\n\nSee the [reference documentation](https://ltla.github.io/CppIrlba) for more details.\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  irlba \n  GIT_REPOSITORY https://github.com/LTLA/CppIrlba\n  GIT_TAG master # or any version of interest\n)\n\nFetchContent_MakeAvailable(irlba)\n```\n\nThen you can link to **irlba** to make the headers available during compilation:\n\n```cmake\n# For executables:\ntarget_link_libraries(myexe ltla::irlba)\n\n# For libaries\ntarget_link_libraries(mylib INTERFACE ltla::irlba)\n```\n\n### CMake with `find_package()`\n\n```cmake\nfind_package(ltla_irlba CONFIG REQUIRED)\ntarget_link_libraries(mylib INTERFACE ltla::irlba)\n```\n\nTo install the library use:\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake .. -DIRLBA_TESTS=OFF\ncmake --build . --target install\n```\n\nBy default, this will use `FetchContent` to fetch all external dependencies.\nIf you want to install them manually, use `-DPOWERIT_FETCH_EXTERN=OFF`.\nSee the commit hashes in [`extern/CMakeLists.txt`](extern/CMakeLists.txt) to find compatible versions of each dependency.\n\n### Manual\n\nIf you're not using CMake, the simple approach is to just copy the files - either directly or with Git submodules - and include their path during compilation with, e.g., GCC's `-I`.\nNote that this requires manual management of a few dependencies:\n\n- [**Eigen**](https://gitlab.com/libeigen/eigen), for matrix manipulations.\n- [**aarand**](https://github.com/LTLA/aarand), for system-agnostic random distribution functions.\n\nSee [`extern/CMakeLists.txt`](extern/CMakeLists.txt) for more details.\n\n## References\n\nBaglama, James and Reichel, Lothar (2005).\nAugmented implicitly restarted Lanczos bidiagonalization methods.\n_SIAM J. Sci. Comput._, 27(1), 19-42.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltla%2Fcppirlba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltla%2Fcppirlba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltla%2Fcppirlba/lists"}