{"id":13413760,"url":"https://github.com/james-bowman/sparse","last_synced_at":"2026-01-23T07:32:05.586Z","repository":{"id":48374634,"uuid":"91464295","full_name":"james-bowman/sparse","owner":"james-bowman","description":"Sparse matrix formats for linear algebra supporting scientific and machine learning applications","archived":false,"fork":false,"pushed_at":"2021-07-29T09:01:28.000Z","size":332,"stargazers_count":157,"open_issues_count":4,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-07-31T20:52:49.968Z","etag":null,"topics":["bit-vector","blas","coo","csc","csr","dictionary-of-keys","go","golang","gonum","machine-learning","matrices","matrix","matrix-format","matrix-multiplication","scientific-computing","sparse-linear-systems","sparse-matrices","sparse-matrix","sparse-representations","vector"],"latest_commit_sha":null,"homepage":"","language":"Go","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/james-bowman.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}},"created_at":"2017-05-16T13:54:36.000Z","updated_at":"2024-07-23T17:09:40.000Z","dependencies_parsed_at":"2022-09-26T22:11:45.274Z","dependency_job_id":null,"html_url":"https://github.com/james-bowman/sparse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/james-bowman/sparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-bowman%2Fsparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-bowman%2Fsparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-bowman%2Fsparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-bowman%2Fsparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james-bowman","download_url":"https://codeload.github.com/james-bowman/sparse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-bowman%2Fsparse/sbom","scorecard":{"id":503477,"data":{"date":"2025-08-11","repo":{"name":"github.com/james-bowman/sparse","commit":"1e6c7dd483e9df5ffa126cf03422e8964849cb0e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T22:38:20.492Z","repository_id":48374634,"created_at":"2025-08-19T22:38:20.492Z","updated_at":"2025-08-19T22:38:20.492Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28683384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: 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":["bit-vector","blas","coo","csc","csr","dictionary-of-keys","go","golang","gonum","machine-learning","matrices","matrix","matrix-format","matrix-multiplication","scientific-computing","sparse-linear-systems","sparse-matrices","sparse-matrix","sparse-representations","vector"],"created_at":"2024-07-30T20:01:48.429Z","updated_at":"2026-01-23T07:32:05.568Z","avatar_url":"https://github.com/james-bowman.png","language":"Go","readme":"# Sparse matrix formats\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GoDoc](https://godoc.org/github.com/james-bowman/sparse?status.svg)](https://godoc.org/github.com/james-bowman/sparse)\n[![Build Status](https://travis-ci.org/james-bowman/sparse.svg?branch=master)](https://travis-ci.org/james-bowman/sparse)\n[![Go Report Card](https://goreportcard.com/badge/github.com/james-bowman/sparse)](https://goreportcard.com/report/github.com/james-bowman/sparse)\n[![codecov](https://codecov.io/gh/james-bowman/sparse/branch/master/graph/badge.svg)](https://codecov.io/gh/james-bowman/sparse)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)\n[![Sourcegraph](https://sourcegraph.com/github.com/james-bowman/sparse/-/badge.svg)](https://sourcegraph.com/github.com/james-bowman/sparse?badge)\n\nImplementations of selected sparse matrix formats for linear algebra supporting scientific and machine learning applications.  Compatible with the APIs in the [Gonum](http://www.gonum.org/) package and interoperable with Gonum dense matrix types.\n\n## Overview\n\nMachine learning applications typically model entities as vectors of numerical features so that they may be compared and analysed quantitively.  Typically the majority of the elements in these vectors are zeros. In the case of text mining applications, each document within a corpus is represented as a vector and its features represent the vocabulary of unique words.  A corpus of several thousand documents might utilise a vocabulary of hundreds of thousands (or perhaps even millions) of unique words but each document will typically only contain a couple of hundred unique words.  This means the number of non-zero values in the matrix might only be around 1%.\n\nSparse matrix formats capitalise on this premise by only storing the non-zero values thereby reducing both storage/memory requirements and processing effort for manipulating the data.\n\n## Features\n\n* Implementations of [Sparse BLAS](http://www.netlib.org/blas/blast-forum/chapter3.pdf) standard routines.\n* Compatible with [Gonum's APIs](https://godoc.org/gonum.org/v1/gonum/mat) and interoperable with Gonum's dense matrix types.\n* Implemented Formats:\n    * Sparse Matrix Formats:\n        * [DOK (Dictionary Of Keys)](https://en.wikipedia.org/wiki/Sparse_matrix#Dictionary_of_keys_(DOK)) format\n        * [COO (COOrdinate)](https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_(COO)) format (sometimes referred to as 'triplet')\n        * [CSR (Compressed Sparse Row)](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format)) format\n        * [CSC (Compressed Sparse Column)](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS)) format\n        * [DIA (DIAgonal)](https://en.wikipedia.org/wiki/Sparse_matrix#Diagonal) format\n        * sparse vectors\n    * Other Formats:\n        * [Binary (Bit) vectors](https://en.wikipedia.org/wiki/Bit_array) and matrices\n* Matrix multiplication, addition and subtraction and vector dot products.\n\n## Usage\n\nThe sparse matrices in this package implement the Gonum `Matrix` interface and so are fully interoperable and mutually compatible with the Gonum APIs and dense matrix types.\n\n``` go\n// Construct a new 3x2 DOK (Dictionary Of Keys) matrix\ndokMatrix := sparse.NewDOK(3, 2)\n\n// Populate it with some non-zero values\ndokMatrix.Set(0, 0, 5)\ndokMatrix.Set(2, 1, 7)\n\n// Demonstrate accessing values (could use Gonum's mat.Formatted()\n// function to pretty print but this demonstrates element access)\nm, n := dokMatrix.Dims()\nfor i := 0; i \u003c m; i++ {\n    for j := 0; j \u003c n; j++ {\n        fmt.Printf(\"%.0f,\", dokMatrix.At(i, j))\n    }\n    fmt.Printf(\"\\n\")\n}\n\n// Convert DOK matrix to CSR (Compressed Sparse Row) matrix\n// just for fun (not required for upcoming multiplication operation)\ncsrMatrix := dokMatrix.ToCSR()\n\n// Create a random 2x3 COO (COOrdinate) matrix with\n// density of 0.5 (half the elements will be non-zero)\ncooMatrix := sparse.Random(sparse.COOFormat, 2, 3, 0.5)\n\n// Convert CSR matrix to Gonum mat.Dense matrix just for fun\n// (not required for upcoming multiplication operation)\n// then transpose so it is the right shape/dimensions for\n// multiplication with the original CSR matrix\ndenseMatrix := csrMatrix.ToDense().T()\n\n// Multiply the 2 matrices together and store the result in the\n// sparse receiver (multiplication with sparse product)\nvar csrProduct sparse.CSR\ncsrProduct.Mul(csrMatrix, cooMatrix)\n\n// As an alternative, use the sparse BLAS routines for efficient\n// sparse matrix multiplication with a Gonum mat.Dense product\n// (multiplication with dense product)\ndenseProduct := sparse.MulMatMat(false, 1, csrMatrix, denseMatrix, nil)\n```\n\n## Installation\n\nWith Go installed, package installation is performed using go get.\n\n```\ngo get -u github.com/james-bowman/sparse/...\n```\n\n## Acknowledgements\n\n* [Gonum](http://www.gonum.org/)\n* [Netlib. BLAS. Chapter 3: Sparse BLAS](http://www.netlib.org/blas/blast-forum/chapter3.pdf)\n* J.R. Gilbert, C. Moler, and R. Schreiber. Sparse matrices in\nMATLAB: Design and implementation. SIAM Journal on Matrix Analysis and\nApplications, 13:333–356, 1992.\n* F.G. Gustavson. Some basic techniques for solving sparse systems\nof linear equations. In D.J. Rose and R.A. Willoughby, eds., Sparse Matrices and\nTheir Applications, 41–52, New York: Plenum Press, 1972.\n* F.G. Gustavson. Efficient algorithm to perform sparse matrix\nmultiplication. IBM Technical Disclosure Bulletin, 20:1262–1264, 1977.\n* [Wikipedia. Sparse Matrix](https://en.wikipedia.org/wiki/Sparse_matrix)\n* [A. Fog. 2. Optimizing subroutines in assembly language An optimization guide for x86 platforms, 1996.](https://www.agner.org/optimize/optimizing_assembly.pdf)\n\n## See Also\n\n* [gonum/gonum](https://github.com/gonum/gonum)\n\n## License\n\nMIT","funding_links":[],"categories":["Linear Algebra","Science and Data Analysis","科学和数据分析","\u003cspan id=\"科学和数据分析-science-and-data-analysis\"\u003e科学和数据分析 Science and Data Analysis\u003c/span\u003e","科学与数据分析","Relational Databases"],"sub_categories":["Vector Database","HTTP Clients","Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","HTTP客户端","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-bowman%2Fsparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames-bowman%2Fsparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-bowman%2Fsparse/lists"}