Opened 11 years ago

Closed 11 years ago

# zero_at() method for RDF/CDF vectors

Reported by: Owned by: Rob Beezer jason, was minor sage-4.7.2 linear algebra Leif Leonhardy sage-4.7.2.alpha3 Rob Beezer Leif Leonhardy N/A

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 to the Sage library.

### comment:1 Changed 11 years ago by Rob Beezer

Authors: → Rob Beezer Leif Leonhardy added; lief removed new → needs_review

### comment:2 follow-up:  3 Changed 11 years ago by Leif Leonhardy

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

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

### comment:3 in reply to:  2 ; follow-up:  4 Changed 11 years ago by Rob Beezer

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

### comment:4 in reply to:  3 Changed 11 years ago by Leif Leonhardy

Description: modified (diff) → Leif Leonhardy

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

Yep, immediately seen it. :)

### comment:5 Changed 11 years ago by Leif Leonhardy

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 sage: A = matrix(RDF, 5, 5, 2) sage: b = vector(RDF, 5, range(5)) sage: A \ b sage: # On at least one platform, we get a "negative zero": sage: v = A \ b sage: v.zero_at(1e-19) (0.0, 0.5, 1.0, 1.5, 2.0) sage: A._backslash_(b) sage: v = A._backslash_(b) sage: v.zero_at(1e-19) (0.0, 0.5, 1.0, 1.5, 2.0) sage: A * BackslashOperator() * b sage: v = A * BackslashOperator() * b sage: v.zero_at(1e-19) (0.0, 0.5, 1.0, 1.5, 2.0) """ 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 Leif Leonhardy

Merged in: → sage-4.7.2.alpha3 → fixed positive_review → closed

### comment:7 Changed 11 years ago by Leif Leonhardy

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.