@@ -8,30 +8,31 @@ class RoundMode(Enum):
8
8
"""
9
9
Enum for IEEE-754 rounding modes.
10
10
11
- Result r is obtained from input v depending on rounding mode as follows
11
+ Result :math:`r` is obtained from input :math:`v` depending on rounding mode as follows
12
+
13
+ Notes on stochastic rounding:
14
+
15
+ StochasticFast implements a stochastic rounding scheme that is unbiased in
16
+ infinite precision, but biased when the quantity to be rounded is computed to
17
+ a finite precision.
18
+
19
+ StochasticFastest implements a stochastic rounding scheme that is biased
20
+ (the rounded value is on average farther from zero than the true value).
21
+
22
+ With a lot of SRbits (say 8 or more), these biases are negligible, and there
23
+ may be some efficiency advantage in using StochasticFast or StochasticFastest.
24
+
12
25
"""
13
26
14
- TowardZero = 1 #: :math:`\max \{ r ~ s.t. ~ |r| \le |v| \} `
15
- TowardNegative = 2 #: :math:`\max \{ r ~ s.t. ~ r \le v \} `
16
- TowardPositive = 3 #: :math:`\min \{ r ~ s.t. ~ r \ge v \} `
27
+ TowardZero = 1 #: Return the largest :math:`r` such that :math:` |r| \le |v|`
28
+ TowardNegative = 2 #: Return the largest :math:`r` such that :math:` r \le v`
29
+ TowardPositive = 3 #: Return the smallest :math:`r` such that :math:` r \ge v`
17
30
TiesToEven = 4 #: Round to nearest, ties to even
18
31
TiesToAway = 5 #: Round to nearest, ties away from zero
19
- Stochastic = 6 #: Stochastic rounding
20
- StochasticFast = 7 #: Stochastic rounding - faster, but biased, see [Note 1].
21
- StochasticFastest = 8 #: Stochastic rounding - incorrect, see [Note 1].
22
- StochasticOdd = 9 #: Stochastic rounding, RTNO before comparison
23
-
24
-
25
- # [Note 1]:
26
- # StochasticFast implements a stochastic rounding scheme that is unbiased in
27
- # infinite precision, but biased when the quantity to be rounded is computed to
28
- # a finite precision.
29
- #
30
- # StochasticFastest implements a stochastic rounding scheme that is biased
31
- # (the rounded value is on average farther from zero than the true value).
32
- #
33
- # With a lot of SRbits (say 8 or more), these biases are negligible, and there
34
- # may be some efficiency advantage in using StochasticFast or StochasticFastest.
32
+ Stochastic = 6 #: Stochastic rounding, RTNE before comparison
33
+ StochasticOdd = 7 #: Stochastic rounding, RTNO before comparison
34
+ StochasticFast = 8 #: Stochastic rounding - faster, but biased
35
+ StochasticFastest = 9 #: Stochastic rounding - even faster, but more biased
35
36
36
37
37
38
class FloatClass (Enum ):
0 commit comments