Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: add support for sparse matrices #2866

Open
3 tasks done
varshil-shah opened this issue Sep 6, 2024 · 2 comments
Open
3 tasks done

RFC: add support for sparse matrices #2866

varshil-shah opened this issue Sep 6, 2024 · 2 comments
Labels
Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes.

Comments

@varshil-shah
Copy link

varshil-shah commented Sep 6, 2024

Description

I would like to propose adding a sparse matrix utility under the utility section of stdlib.io. In many cases, when users create 2D matrices, they often do not fully utilize all the cells, leading to unnecessary storage consumption. Sparse matrices can optimize this by only storing non-zero (or meaningful) values, thereby reducing memory usage.

Why is this needed?
A sparse matrix is useful in scenarios where the matrix has a large number of zero (or default) values, which is common in scientific computing, machine learning, and other data-heavy operations. With a sparse matrix implementation, users can:

  • Save memory by only storing the necessary values.
  • Improve computational efficiency with large, sparsely populated matrices.

Proposed Solution: The solution will involve creating a 1D array, which will be used to simulate a 2D matrix via a mathematical formula. This approach ensures that only the non-default values are stored, significantly optimizing memory usage. The utility will:

  • Allow users to interact with the matrix as if it were a standard 2D array.
  • Provide methods for adding, removing, and accessing values.
  • Use an internal mapping function to translate 2D indices into the 1D array.

Looking forward to your feedback!

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@stdlib-bot
Copy link
Contributor

👋 Hi there! 👋

And thank you for opening your first issue! We will get back to you shortly. 🏃 💨

@kgryte kgryte added RFC Request for comments. Feature requests and proposed changes. Needs Discussion Needs further discussion. labels Sep 6, 2024
@kgryte kgryte changed the title RFC: Add a Sparse Matrix Utility to stdlib.io RFC: add support for sparse matrices Sep 6, 2024
@kgryte
Copy link
Member

kgryte commented Sep 6, 2024

@varshil-shah Thanks for raising this issue. I think the main concern I have with implementing sparse arrays is that, in order to perform computation efficiently, you need a sparse array compiler in order to be able to handle the different sparse matrix formats, operator fusion, fill values, and internal structure. This is non-trivial to do well.

In general, I am not opposed; however, undertaking this effort would require considerable R&D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

No branches or pull requests

3 participants