Opened 12 years ago
Closed 12 years ago
#5198 closed defect (fixed)
[with patch, positive review] apply_map skips zeroes in sparse vectors and matrices
Reported by: | cwitty | Owned by: | was |
---|---|---|---|
Priority: | blocker | Milestone: | sage-3.3 |
Component: | linear algebra | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Consider:
sage: vector(ZZ, range(3)).apply_map(lambda x: x+1) (1, 2, 3) sage: vector(ZZ, range(3), sparse=True).apply_map(lambda x: x+1) (0, 2, 3)
and
sage: matrix(ZZ, range(3)).apply_map(lambda x: x+1) [1 2 3] sage: matrix(ZZ, range(3), sparse=True).apply_map(lambda x: x+1) [0 2 3]
Attachments (1)
Change History (4)
Changed 12 years ago by
comment:1 Changed 12 years ago by
- Summary changed from apply_map skips zeroes in sparse vectors and matrices to [with patch, needs review] apply_map skips zeroes in sparse vectors and matrices
comment:2 Changed 12 years ago by
- Summary changed from [with patch, needs review] apply_map skips zeroes in sparse vectors and matrices to [with patch, positive review] apply_map skips zeroes in sparse vectors and matrices
Ouch...that is a pretty bad bug.
The patch fixes the above issues and works well for me (including the subdivisions fix).
comment:3 Changed 12 years ago by
- Resolution set to fixed
- Status changed from new to closed
Merged in Sage 3.3.alpha6.
Cheers,
Michael
Note: See
TracTickets for help on using
tickets.
The attached patch fixes the problem, and adds a sparse=True/False? argument to apply_map that may be useful if you know that the result will have a different sparsity than the input.
I also fixed a bug along the way: apply_map didn't preserve subdivisions for sparse matrices. Sorry, reviewer, whoever you are.