{"id":32157610,"url":"https://github.com/timweiland/selectedinversion.jl","last_synced_at":"2025-10-21T12:51:30.339Z","repository":{"id":288751009,"uuid":"965741200","full_name":"timweiland/SelectedInversion.jl","owner":"timweiland","description":"Blazing fast selected inversion of sparse matrices","archived":false,"fork":false,"pushed_at":"2025-09-02T21:49:25.000Z","size":441,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T22:13:03.834Z","etag":null,"topics":["cholesky","linear-algebra","sparse-matrices"],"latest_commit_sha":null,"homepage":"https://timweiland.github.io/SelectedInversion.jl","language":"Julia","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/timweiland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2025-04-13T20:03:42.000Z","updated_at":"2025-09-02T20:19:15.000Z","dependencies_parsed_at":"2025-04-19T16:18:35.826Z","dependency_job_id":"bf5241d8-5cac-4954-935b-8adc8bac222f","html_url":"https://github.com/timweiland/SelectedInversion.jl","commit_stats":null,"previous_names":["timweiland/selectedinversion.jl"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/timweiland/SelectedInversion.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweiland%2FSelectedInversion.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweiland%2FSelectedInversion.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweiland%2FSelectedInversion.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweiland%2FSelectedInversion.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timweiland","download_url":"https://codeload.github.com/timweiland/SelectedInversion.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timweiland%2FSelectedInversion.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280264174,"owners_count":26300771,"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-21T02:00:06.614Z","response_time":58,"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":["cholesky","linear-algebra","sparse-matrices"],"created_at":"2025-10-21T12:51:29.520Z","updated_at":"2025-10-21T12:51:30.333Z","avatar_url":"https://github.com/timweiland.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    SelectedInversion.jl\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003e🔥 Quickly compute selected entries of the inverse of a sparse matrix\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://timweiland.github.io/SelectedInversion.jl/stable/)\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://timweiland.github.io/SelectedInversion.jl/dev/)\n[![Build Status](https://github.com/timweiland/SelectedInversion.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/timweiland/SelectedInversion.jl/actions/workflows/CI.yml?query=branch%3Amain)\n[![Coverage](https://codecov.io/gh/timweiland/SelectedInversion.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/timweiland/SelectedInversion.jl)\n[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)\n\n\u003c/div\u003e\n\nSparse matrices are one of the pillars of scientific computing.\nSparse factorization methods allow us to solve linear systems involving the inverse efficiently.\nBut in some applications, we might need *a bunch* of entries of the inverse.\nSelected inversion algorithms efficiently compute those entries of the inverse that correspond to non-zero entries in the factorization.\n\nSelectedInversion.jl directly interfaces with CHOLMOD-based Cholesky\nfactorizations, which are the default for sparse symmetric positive-definite\nmatrices in Julia.\nIt also supports factorizations obtained from LDLFactorizations.jl through a\npackage extension.\n\nThe algorithms implemented here are directly based on SelInv [1].\nThe simplicial formulation is equivalent to the Takahashi recursions [2, 3].\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Performance](#performance)\n- [Contributing](#contributing)\n\n## Installation\n\nSelectedInversion.jl is a registered Julia package.\nYou can install it directly from the Pkg REPL.\nTo do so:\n\n1. [Download Julia (\u003e= version 1.10)](https://julialang.org/downloads/).\n\n2. Launch the Julia REPL and type `] add SelectedInversion`. \n\n## Usage\n\nIt's as simple as it can be:\n\n``` julia\nusing SelectedInversion\n\nA = ... # some sparse matrix\nZ, p = selinv(A) # selected inverse and corresponding permutation vector\n```\n\nThe nonzero entries of `Z` match the corresponding entries in `inv(A[p, p])`.\n\nIf you've already computed a Cholesky factorization of your matrix anyway,\nyou can directly pass it to `selinv` to save the factorization step.\n\n```julia\nC = cholesky(A)\nZ, p = selinv(C)\n```\n\nIf you don't care about this whole permutation business, use this:\n\n```julia\nZ, _ = selinv(A; depermute=true)\n```\n\nNow the nonzero entries of `Z` directly give you the corresponding entries\nof `inv(A)`.\n\n### Computing Only the Diagonal\n\nFor many applications, you only need the diagonal entries of the inverse matrix.\nFor example, in Gaussian Markov Random Fields, the diagonal of the inverse precision matrix gives the marginal variances.\n\n```julia\nd = selinv_diag(A)  # diagonal of inv(A)\n```\n\nThis is much more efficient than computing the full selected inverse and then extracting the diagonal, especially for simplicial factorizations.\n\nYou can also pass pre-computed factorizations:\n\n```julia\nC = cholesky(A)\nd = selinv_diag(C)  # same result, but reuses factorization\n```\n\nThe `selinv_diag` function supports the same `depermute` keyword as `selinv`:\n\n```julia\nd_permuted = selinv_diag(A; depermute=false)  # diagonal of permuted inverse\n```\n\n## Performance\n\n**tl;dr**: It's pretty fast.\n\nBelow is the performance of SelectedInversion.jl on some example problems from\nthe [SuiteSparse matrix collection](http://sparse.tamu.edu).\nThe benchmark was run on my laptop (M1 Max with 32 GB RAM).\n\nTo put these numbers into perspective, feel free to compare to Table III of [[1]](https://dl.acm.org/doi/abs/10.1145/1916461.1916464).\nNote however the hardware difference (they used a Franklin Cray XT4 supercomputer),\nas well as the different factorization algorithm (we use CHOLMOD).\n\n| **Problem**\u003cbr\u003e`String` | **N**\u003cbr\u003e`Int64` | **NNZ**\u003cbr\u003e`Int64` | **Factorization time (sec)**\u003cbr\u003e`Measurement{Float64}` | **SelInv time (sec)**\u003cbr\u003e`Measurement{Float64}` |\n|------------------------:|-----------------:|-------------------:|-------------------------------------------------------:|------------------------------------------------:|\n| bcsstk14                | 1806             | 63454              | 0.00335±0.00033                                        | 0.00295±0.0008                                  |\n| bcsstk24                | 3562             | 159910             | 0.00666±0.00055                                        | 0.0067±0.0014                                   |\n| bcsstk28                | 4410             | 219024             | 0.00905±0.00076                                        | 0.0082±0.0017                                   |\n| bcsstk18                | 11948            | 149090             | 0.0199±0.00073                                         | 0.0466±0.0064                                   |\n| bodyy6                  | 19366            | 134208             | 0.0184±0.0021                                          | 0.042±0.011                                     |\n| crystm03                | 24696            | 583770             | 0.075±0.016                                            | 0.296±0.029                                     |\n| wathen120               | 36441            | 565761             | 0.0481±0.0057                                          | 0.087±0.017                                     |\n| shipsec1                | 140874           | 3568176            | 2.075±0.058                                            | 7.70644±NaN                                     |\n| pwtk                    | 217918           | 11524432           | 1.36±0.25                                              | 2.054±0.066                                     |\n| parabolic\\_fem          | 525825           | 3674625            | 1.002±0.066                                            | 6.63912±NaN                                     |\n| tmt\\_sym                | 726713           | 5080961            | 4.201±0.013                                            | 10.8521±NaN                                     |\n| ecology2                | 999999           | 4995991            | 1.52±0.14                                              | 13.7855±NaN                                     |\n| G3\\_circuit             | 1585478          | 7660826            | 10.42±NaN                                              | 53.636±NaN                                      |\n\n## Contributing\n\nCheck our [contribution guidelines](./CONTRIBUTING.md).\n\n## References\n\n[1] Lin, L., Yang, C., Meza, J. C., Lu, J., Ying, L., \u0026 E, W. (2011). SelInv---An Algorithm for Selected Inversion of a Sparse Symmetric Matrix. *ACM Transactions on Mathematical Software (TOMS)*, 37(4), 1-19.\n\n[2] Erisman, A. M., \u0026 Tinney, W. F. (1975). On computing certain elements of the inverse of a sparse matrix. *Communications of the ACM*, 18(3), 177-179.\n\n[3] Takahashi, K. (1973). Formation of sparse bus impedance matrix and its application to short circuit study. In *Proc. PICA Conference*, June, 1973.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimweiland%2Fselectedinversion.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimweiland%2Fselectedinversion.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimweiland%2Fselectedinversion.jl/lists"}