Opened 7 years ago
Closed 7 years ago
#13929 closed defect (fixed)
Wrong comparison of sparse vectors
Reported by: | tfeulner | Owned by: | jason, was |
---|---|---|---|
Priority: | major | Milestone: | sage-5.7 |
Component: | linear algebra | Keywords: | comparison, sparse, free module |
Cc: | Merged in: | sage-5.7.beta2 | |
Authors: | Thomas Feulner | Reviewers: | Christian Nassau |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The comparison of sparse vectors gives wrong results at the moment:
sage: V = FreeModule( GF(3), 2, sparse=True) sage: a = V([0,1]) sage: b = V([1,0]) sage: cmp(a, b) 1 # should be -1, since we are using the lexicographic order
In particular, this leads to different results when using sparse and dense vectors at the same time:
sage: cmp(a.dense_vector(), b) -1 sage: cmp(a, b.dense_vector()) 1
Attachments (1)
Change History (5)
comment:1 Changed 7 years ago by
- Summary changed from Wrong comparison of sparse to Wrong comparison of sparse vectors
Changed 7 years ago by
comment:2 Changed 7 years ago by
- Status changed from new to needs_review
comment:3 Changed 7 years ago by
- Reviewers set to Christian Nassau
- Status changed from needs_review to positive_review
comment:4 Changed 7 years ago by
- Merged in set to sage-5.7.beta2
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
The patch seems to be correct (tested it against Sage 5.5) and does indeed fix a bug in the sorting order. I would have chosen a more informative doctest, for example
But I think the patch is ready to go as it is, so I'm giving it a positive review.