{"id":20141872,"url":"https://github.com/yixuan/rspectra","last_synced_at":"2025-04-06T20:10:34.447Z","repository":{"id":56936698,"uuid":"52744498","full_name":"yixuan/RSpectra","owner":"yixuan","description":"R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems","archived":false,"fork":false,"pushed_at":"2024-07-21T04:34:27.000Z","size":363,"stargazers_count":81,"open_issues_count":7,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-04T22:46:56.883Z","etag":null,"topics":["eigenvalues","spectra","svd"],"latest_commit_sha":null,"homepage":"http://cran.r-project.org/package=RSpectra","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/yixuan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-28T21:14:11.000Z","updated_at":"2025-02-11T00:55:02.000Z","dependencies_parsed_at":"2024-11-12T09:42:29.316Z","dependency_job_id":null,"html_url":"https://github.com/yixuan/RSpectra","commit_stats":{"total_commits":98,"total_committers":4,"mean_commits":24.5,"dds":"0.37755102040816324","last_synced_commit":"18739edad0eb3c77b2663281a9633322efb21431"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yixuan%2FRSpectra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yixuan%2FRSpectra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yixuan%2FRSpectra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yixuan%2FRSpectra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yixuan","download_url":"https://codeload.github.com/yixuan/RSpectra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543591,"owners_count":20955865,"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":["eigenvalues","spectra","svd"],"created_at":"2024-11-13T21:59:49.770Z","updated_at":"2025-04-06T20:10:34.410Z","avatar_url":"https://github.com/yixuan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Solvers for Large Scale Eigenvalue and SVD Problems \u003cimg src=\"https://statr.me/images/sticker-rspectra.png\" alt=\"RSpectra\" height=\"150px\" align=\"right\" /\u003e\n\n### Introduction\n\n**RSpectra** is an R interface to the\n[Spectra library](https://spectralib.org/).\nIt is typically used to compute a few eigenvalues/vectors of an `n` by `n`\nmatrix, e.g., the `k` largest eigen values, which\nis usually more efficient than `eigen()` if `k \u003c\u003c n`.\n\nCurrently this package provides the function `eigs()` for eigenvalue/eigenvector\nproblems, and `svds()` for truncated SVD. Different matrix types in R,\nincluding sparse matrices, are supported. Below is a list of implemented ones:\n\n- `matrix` (defined in base R)\n- `dgeMatrix` (defined in **Matrix** package, for general matrices)\n- `dgCMatrix` (defined in **Matrix** package, for column oriented sparse matrices)\n- `dgRMatrix` (defined in **Matrix** package, for row oriented sparse matrices)\n- `dsyMatrix` (defined in **Matrix** package, for symmetric matrices)\n- `dsCMatrix` (defined in **Matrix** package, for symmetric column oriented sparse matrices)\n- `dsRMatrix` (defined in **Matrix** package, for symmetric row oriented sparse matrices)\n- `function` (implicitly specify the matrix by providing a function that calculates matrix product `A %*% x`)\n\n### Examples\n\nWe first generate some matrices:\n\n```r\nlibrary(Matrix)\nn = 20\nk = 5\n\nset.seed(111)\nA1 = matrix(rnorm(n^2), n)  ## class \"matrix\"\nA2 = Matrix(A1)             ## class \"dgeMatrix\"\n```\n\nGeneral matrices have complex eigenvalues:\n\n```r\neigs(A1, k)\neigs(A2, k, opts = list(retvec = FALSE))  ## eigenvalues only\n```\n\n**RSpectra** also works on sparse matrices:\n\n```r\nA1[sample(n^2, n^2 / 2)] = 0\nA3 = as(A1, \"dgCMatrix\")\nA4 = as(A1, \"dgRMatrix\")\n\neigs(A3, k)\neigs(A4, k)\n```\n\nFunction interface is also supported:\n\n```r\nf = function(x, args)\n{\n    as.numeric(args %*% x)\n}\neigs(f, k, n = n, args = A3)\n```\n\nSymmetric matrices have real eigenvalues.\n\n```r\nA5 = crossprod(A1)\neigs_sym(A5, k)\n```\n\nTo find the smallest (in absolute value) `k` eigenvalues of `A5`,\nwe have two approaches:\n\n```r\neigs_sym(A5, k, which = \"SM\")\neigs_sym(A5, k, sigma = 0)\n```\n\nThe results should be the same, but the latter method is far more\nstable on large matrices.\n\nFor SVD problems, you can specify the number of singular values\n(`k`), number of left singular vectors (`nu`) and number of right\nsingular vectors(`nv`).\n\n```r\nm = 100\nn = 20\nk = 5\nset.seed(111)\nA = matrix(rnorm(m * n), m)\n\nsvds(A, k)\nsvds(t(A), k, nu = 0, nv = 3)\n```\n\nSimilar to `eigs()`, `svds()` supports sparse matrices:\n\n```r\nA[sample(m * n, m * n / 2)] = 0\nAsp1 = as(A, \"dgCMatrix\")\nAsp2 = as(A, \"dgRMatrix\")\n\nsvds(Asp1, k)\nsvds(Asp2, k, nu = 0, nv = 0)\n```\n\nand function interface\n\n```r\nf = function(x, args)\n{\n    as.numeric(args %*% x)\n}\ng = function(x, args)\n{\n    as.numeric(crossprod(args, x))\n}\nsvds(f, k, Atrans = g, dim = c(m, n), args = Asp1)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyixuan%2Frspectra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyixuan%2Frspectra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyixuan%2Frspectra/lists"}