Ticket #11848 (closed enhancement: fixed)

Opened 20 months ago

Last modified 20 months ago

zero_at() method for RDF/CDF vectors

Reported by: rbeezer Owned by: jason, was
Priority: minor Milestone: sage-4.7.2
Component: linear algebra Keywords:
Cc: leif Work issues:
Report Upstream: N/A Reviewers: Leif Leonhardy
Authors: Rob Beezer Merged in: sage-4.7.2.alpha3
Dependencies: Stopgaps:

Description (last modified by leif) (diff)

This patch adds a method to replace small entries of a floating-point vector with zeros, according to a provided tolerance. It mirrors the matrix method of the same name.


Apply only trac_11848-zero-at-vectors-v2.patch Download to the Sage library.

Attachments

trac_11848-zero-at-vectors.patch Download (2.2 KB) - added by rbeezer 20 months ago.
trac_11848-zero-at-vectors-v2.patch Download (2.2 KB) - added by rbeezer 20 months ago.

Change History

Changed 20 months ago by rbeezer

comment:1 Changed 20 months ago by rbeezer

  • Cc leif added; lief removed
  • Status changed from new to needs_review
  • Authors set to Rob Beezer

comment:2 follow-up: ↓ 3 Changed 20 months ago by leif

if
    s/complex matrices/complex vectors/
    s/imaginaryparts/imaginary parts/
then
    ok

(Not yet tested, will do shortly...)

Changed 20 months ago by rbeezer

comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 20 months ago by rbeezer

Replying to leif:

Thanks for the editorial work. ;-) v2 patch includes indicated changes.

comment:4 in reply to: ↑ 3 Changed 20 months ago by leif

  • Reviewers set to Leif Leonhardy
  • Description modified (diff)

Replying to rbeezer:

Replying to leif:

Thanks for the editorial work. ;-) v2 patch includes indicated changes.

Yep, immediately seen it. :)

comment:5 Changed 20 months ago by leif

  • Status changed from needs_review to 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  
    13831383 
    13841384            sage: A = matrix(RDF, 5, 5, 2) 
    13851385            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(1e-19) 
    13871389            (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(1e-19) 
    13891392            (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(1e-19) 
    13911395            (0.0, 0.5, 1.0, 1.5, 2.0) 
    13921396        """ 
    13931397        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 20 months ago by leif

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.7.2.alpha3

comment:7 Changed 20 months ago by leif

Now also used in sage/matrix/matrix_double_dense.pyx, to fix another doctest error introduced by #7852 (noisy zero in a vector result).

Note: See TracTickets for help on using tickets.