-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Matrix and Components should have a sparse iterator #29619
Comments
comment:2
Thanks for opening this ticket. I've added a link to it in the "Algebraic part" section of the meta-ticket #18528. |
comment:3
See also: #30309 - Unify free module elements API: methods |
comment:5
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
comment:7
@honglizhaobob This is probably the best ticket for starting |
comment:8
Replying to @mkoeppe:
Is there a set of unit test cases one needs to pass to ensure a justified change of data structure? |
comment:9
To clarify - here on this ticket, the data structure shouldn't be changed but instead methods added. Sage mainly uses doctests - see https://doc.sagemath.org/html/en/developer/doctesting.html |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
comment:12
You can use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Author: Matthias Koeppe |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:23
Thanks for implementing this. LGTM. |
Reviewer: Eric Gourgoulhon |
comment:24
Thanks! |
Changed branch from u/mkoeppe/tensors_should_have_a_sparse_iterator to |
As observed on this Ask SageMath question, it does not seem to be possible to iterate over the non-zero entries of a tensor. This is unfortunate because the entries are stored in a sparse format, in a dictionary.
Since a tensor might have symmetries, this is more involved than just iterating over the dictionary, but such an iterator would immediately be useful for the implementation of the
display()
method, for instance.Here we implement a method
Components.items
, returning an iterable of(indices, value)
. This is compatible with the sparse and dense vectors fromsage.modules
.(Because a
Components
does not currently have a parent, it does not make sense to define the methodmonomial_coefficients
- as defined byModulesWithBasis
.)We also define
Matrix.items
with the same interface.CC: @egourgoulhon @LBrunswic @honglizhaobob @tscrim
Component: linear algebra
Author: Matthias Koeppe
Branch/Commit:
74d9493
Reviewer: Eric Gourgoulhon
Issue created by migration from https://trac.sagemath.org/ticket/29619
The text was updated successfully, but these errors were encountered: