#11848 closed enhancement (fixed)
zero_at() method for RDF/CDF vectors
Reported by:  Rob Beezer  Owned by:  jason, was 

Priority:  minor  Milestone:  sage4.7.2 
Component:  linear algebra  Keywords:  
Cc:  Leif Leonhardy  Merged in:  sage4.7.2.alpha3 
Authors:  Rob Beezer  Reviewers:  Leif Leonhardy 
Report Upstream:  N/A  Work issues:  
Branch:  Commit:  
Dependencies:  Stopgaps: 
Description (last modified by )
This patch adds a method to replace small entries of a floatingpoint vector with zeros, according to a provided tolerance. It mirrors the matrix method of the same name.
Apply only trac_11848zeroatvectorsv2.patch to the Sage library.
Attachments (2)
Change History (9)
Changed 11 years ago by
Attachment:  trac_11848zeroatvectors.patch added 

comment:1 Changed 11 years ago by
Authors:  → Rob Beezer 

Cc:  Leif Leonhardy added; lief removed 
Status:  new → needs_review 
comment:2 followup: 3 Changed 11 years ago by
Changed 11 years ago by
Attachment:  trac_11848zeroatvectorsv2.patch added 

comment:3 followup: 4 Changed 11 years ago by
Replying to leif:
Thanks for the editorial work. ;) v2 patch includes indicated changes.
comment:4 Changed 11 years ago by
Description:  modified (diff) 

Reviewers:  → Leif Leonhardy 
comment:5 Changed 11 years ago by
Status:  needs_review → positive_review 

This function is (e.g.) required by a doctest fix for #7852:

sage/misc/preparser.py
diff git a/sage/misc/preparser.py b/sage/misc/preparser.py
a b 1383 1383 1384 1384 sage: A = matrix(RDF, 5, 5, 2) 1385 1385 sage: b = vector(RDF, 5, range(5)) 1386 sage: A \ b 1386 sage: # On at least one platform, we get a "negative zero": 1387 sage: v = A \ b 1388 sage: v.zero_at(1e19) 1387 1389 (0.0, 0.5, 1.0, 1.5, 2.0) 1388 sage: A._backslash_(b) 1390 sage: v = A._backslash_(b) 1391 sage: v.zero_at(1e19) 1389 1392 (0.0, 0.5, 1.0, 1.5, 2.0) 1390 sage: A * BackslashOperator() * b 1393 sage: v = A * BackslashOperator() * b 1394 sage: v.zero_at(1e19) 1391 1395 (0.0, 0.5, 1.0, 1.5, 2.0) 1392 1396 """ 1393 1397 return self.left._backslash_(right)
With both patches applied, the tests now pass on the Skynet machine "cleo" (Linux IA64 / Itanium 2), where they previously failed, so positive review.
comment:6 Changed 11 years ago by
Merged in:  → sage4.7.2.alpha3 

Resolution:  → fixed 
Status:  positive_review → closed 
comment:7 Changed 11 years ago by
Now also used in sage/matrix/matrix_double_dense.pyx
, to fix another doctest error introduced by #7852 (noisy zero in a vector result).
(Not yet tested, will do shortly...)